File: unused-merged-value.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (46 lines) | stat: -rw-r--r-- 1,786 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Location for variable "parama" optimized out.
// Previously it would carry incorrect location
// information in debug-info, see PR48719.
// Now, the location is simply not emitted.

// REQUIRES: lldb
// UNSUPPORTED: system-windows
// RUN: %dexter --fail-lt 0.1 -w --debugger lldb \
// RUN:     --builder 'clang-c'  --cflags "-O3 -glldb" -- %s
// See NOTE at end for more info about the RUN command.

// 1. SROA/mem2reg fully promotes parama.
// 2. parama's value in the final block is the merge of values for it coming
//    out of entry and if.then. If the variable were used later in the function
//    mem2reg would insert a PHI here and add a dbg.value to track the merged
//    value in debug info. Because it is not used there is no PHI (the merged
//    value is implicit) and subsequently no dbg.value.
// 3. SimplifyCFG later folds the blocks together (if.then does nothing besides
//    provide debug info so it is removed and if.end is folded into the entry
//    block).

// The debug info is not updated to account for the implicit merged value prior
// to (e.g. during mem2reg) or during SimplifyCFG so we end up seeing parama=5
// for the entire function, which is incorrect.

__attribute__((optnone))
void fluff() {}

__attribute__((noinline))
int fun(int parama, int paramb) {
  if (parama)
    parama = paramb;
  fluff();            // DexLabel('s0')
  return paramb;
}

int main() {
  return fun(5, 20);
}

// DexExpectWatchValue('parama', 20, on_line=ref('s0'))
//
// NOTE: the dexter command uses --fail-lt 0.1 (instead of the standard 1.0)
// because seeing 'optimized out' would still be a win; it's the best we can do
// without using conditional DWARF operators in the location expression. Seeing
// 'optimized out' should result in a score higher than 0.1.