For the below test:
int main() { volatile int foo = 4; int read1 = foo; int read2 = foo; switch ((read1 == 4) ? 3 : 1) { case 1: read1 *= read2; break; case 3: read1 /= read2; break; } return read1; }
Debug location information for 'read1' is wrong with -O2.
When in the debugger, on the line "return read1;", the value of "read1"
is reported as '4', where it should be '1', as described by:
How about:
/// Find all DBG_VALUEs immediately following this instruction that point to a register def in this instruction and point them to \p Reg instead.
Looking at the implementation of collectDebugValues() I'm somewhat puzzled how it works. Perhaps I'm misunderstanding what it is supposed to do, please let me know. It's scanning for DBG_VALUEs that point to Op0 of the instruction. Is Op0 always going to be a def? Or should it be improved?