Open Quuxplusone opened 4 years ago
Bugzilla Link | PR43949 |
Status | CONFIRMED |
Importance | P enhancement |
Reported by | Shuo Ding (shuo.d@outlook.com) |
Reported on | 2019-11-08 17:38:23 -0800 |
Last modified on | 2019-11-11 04:52:05 -0800 |
Version | trunk |
Hardware | PC Linux |
CC | aprantl@apple.com, dblaikie@gmail.com, ditaliano@apple.com, greg.bedwell@sony.com, jeremy.morse.llvm@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, paul.robinson@am.sony.com, richard-llvm@metafoo.co.uk, vsk@apple.com |
Fixed by commit(s) | |
Attachments | |
Blocks | PR38768 |
Blocked by | |
See also |
Many thanks for the report -- this is a really interesting reproducer that
exhibits interesting debug behaviour. First thing to note is that everything in
the program gets inlined and completely unrolled. In gdb, there's no indication
that the first five (unrolled and inlined) calls to 'h' happen: entering "next"
steps over all of them:
19 h((char)i);
(gdb) n
22 h(d[i]); // optimize_me_not0
And if you're inside of of the inlined function scope and enter "next", you
enter a new inlining instance without any indication from gdb, which surprised
me:
(gdb) n
8 e(g >> 8);
(gdb) n
7 b = b & 4095 ^ a[(b ^ g) & 255];
(gdb) n
8 e(g >> 8);
(gdb) n
7 b = b & 4095 ^ a[(b ^ g) & 255];
(gdb) n
8 e(g >> 8);
(gdb) n
7 b = b & 4095 ^ a[(b ^ g) & 255];
(gdb) n
8 e(g >> 8);
(Each pair of lines here is a different inlining instance).
I've added this to the "bad debug experiences" umbrella bug, as IMO this is
something we can use in dexter tests in the future.
On to the actual problem reported: it looks like the machine-scheduler pass re-
orders some of the DBG_VALUEs, llvm-dwarfdump --name=i gives me, at the end of
the location list:
DW_OP_consts +5, DW_OP_stack_value
DW_OP_consts +1, DW_OP_stack_value
DW_OP_consts +0, DW_OP_stack_value
DW_OP_consts +2, DW_OP_stack_value)
Which should of course be in the order {5, 0, 1, 2}.
I'm not familiar with the machine-scheduler pass, but I think there are related
bugs open about the fact that it re-orders CFI instructions in this way too.
(This might also be an example of variable-locations and line-numbers being
completely separate causing variable locations to cover line numbers they
shouldn't).