When loops are deleted, we don't keep track of variables modified inside the loops, so the DI will contain the wrong value for these.
e.g.
int b() {
int i; for (i = 0; i < 2; i++) ; patatino(); return a;
-> 6 patatino();
7 return a; 8 } 9 int main() { b(); }
(lldb) frame var i
(int) i = 0
We mark instead these values as unavailable inserting a @llvm.dbg.value(undef to make sure we don't end up printing an incorrect value in the debugger. We could consider doing something fancier, for, e.g. constants, in the future.
PR39868.
rdar://problem/46418795
I'd add:
// Since debug values in the loop have been deleted, inserting an undef dbg.value truncates the range of any dbg.value before the loop where the loop used to be. This is particularly important for constant values.