| 1 | // XFAIL:* |
| 2 | //// See PR47946. |
| 3 | |
| 4 | // REQUIRES: lldb |
| 5 | // UNSUPPORTED: system-windows |
| 6 | // RUN: %clang -std=gnu11 -O2 -glldb %s -o %t |
| 7 | // RUN: %dexter --fail-lt 1.0 -w --debugger lldb --binary %t -- %s |
| 8 | // |
| 9 | //// Check that once-escaped variable 'param' can still be read after we |
| 10 | //// perform inlining + mem2reg, and that we see the DSE'd value 255. |
| 11 | |
| 12 | |
| 13 | int g; |
| 14 | __attribute__((__always_inline__)) |
| 15 | static void use(int* p) { |
| 16 | g = *p; |
| 17 | *p = 255; |
| 18 | volatile int step = 0; // DexLabel('use1') |
| 19 | } |
| 20 | |
| 21 | __attribute__((__noinline__)) |
| 22 | void fun(int param) { |
| 23 | //// Make sure first step is in 'fun'. |
| 24 | volatile int step = 0; // DexLabel('fun1') |
| 25 | use(p: ¶m); |
| 26 | return; // DexLabel('fun2') |
| 27 | } |
| 28 | |
| 29 | int main() { |
| 30 | fun(param: 5); |
| 31 | } |
| 32 | |
| 33 | /* |
| 34 | # Expect param == 5 before stepping through inlined 'use'. |
| 35 | DexExpectWatchValue('param', '5', on_line=ref('fun1')) |
| 36 | |
| 37 | # Expect param == 255 after assignment in inlined frame 'use'. |
| 38 | DexExpectProgramState({ |
| 39 | 'frames': [ |
| 40 | { 'function': 'use', |
| 41 | 'location': { 'lineno': ref('use1') }, |
| 42 | }, |
| 43 | { 'function': 'fun', |
| 44 | 'location': { 'lineno': 20 }, |
| 45 | 'watches': { 'param': '255' } |
| 46 | }, |
| 47 | ] |
| 48 | }) |
| 49 | |
| 50 | # Expect param == 255 after inlined call to 'use'. |
| 51 | DexExpectWatchValue('param', '255', on_line=ref('fun2')) |
| 52 | */ |
| 53 | |