Revert "[Dexter] Remove builder from Dexter"
[llvm-project.git] / cross-project-tests / debuginfo-tests / dexter-tests / memvars / unused-merged-value.c
blobf689aaeb9ada7977c14eab141e80a5b8f713efb8
1 // Location for variable "parama" optimized out.
2 // Previously it would carry incorrect location
3 // information in debug-info, see PR48719.
4 // Now, the location is simply not emitted.
6 // REQUIRES: lldb
7 // UNSUPPORTED: system-windows
8 // RUN: %dexter --fail-lt 0.1 -w --debugger lldb \
9 // RUN: --builder 'clang-c' --cflags "-O3 -glldb" -- %s
10 // See NOTE at end for more info about the RUN command.
12 // 1. SROA/mem2reg fully promotes parama.
13 // 2. parama's value in the final block is the merge of values for it coming
14 // out of entry and if.then. If the variable were used later in the function
15 // mem2reg would insert a PHI here and add a dbg.value to track the merged
16 // value in debug info. Because it is not used there is no PHI (the merged
17 // value is implicit) and subsequently no dbg.value.
18 // 3. SimplifyCFG later folds the blocks together (if.then does nothing besides
19 // provide debug info so it is removed and if.end is folded into the entry
20 // block).
22 // The debug info is not updated to account for the implicit merged value prior
23 // to (e.g. during mem2reg) or during SimplifyCFG so we end up seeing parama=5
24 // for the entire function, which is incorrect.
26 __attribute__((optnone))
27 void fluff() {}
29 __attribute__((noinline))
30 int fun(int parama, int paramb) {
31 if (parama)
32 parama = paramb;
33 fluff(); // DexLabel('s0')
34 return paramb;
37 int main() {
38 return fun(5, 20);
41 // DexExpectWatchValue('parama', 20, on_line=ref('s0'))
43 // NOTE: the dexter command uses --fail-lt 0.1 (instead of the standard 1.0)
44 // because seeing 'optimized out' would still be a win; it's the best we can do
45 // without using conditional DWARF operators in the location expression. Seeing
46 // 'optimized out' should result in a score higher than 0.1.