| 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. |
| 5 | |
| 6 | // REQUIRES: lldb |
| 7 | // UNSUPPORTED: system-windows |
| 8 | // RUN: %clang -std=gnu11 -O3 -glldb %s -o %t |
| 9 | // RUN: %dexter --fail-lt 0.1 -w --debugger lldb --binary %t -- %s |
| 10 | // See NOTE at end for more info about the RUN command. |
| 11 | |
| 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). |
| 21 | |
| 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. |
| 25 | |
| 26 | __attribute__((optnone)) |
| 27 | void fluff() {} |
| 28 | |
| 29 | __attribute__((noinline)) |
| 30 | int fun(int parama, int paramb) { |
| 31 | if (parama) |
| 32 | parama = paramb; |
| 33 | fluff(); // DexLabel('s0') |
| 34 | return paramb; |
| 35 | } |
| 36 | |
| 37 | int main() { |
| 38 | return fun(parama: 5, paramb: 20); |
| 39 | } |
| 40 | |
| 41 | // DexExpectWatchValue('parama', 20, on_line=ref('s0')) |
| 42 | // |
| 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. |
| 47 | |