[PATCH] D28390: [DWARF] LICM should null out the debug loc of hoisted loop invariant instructions
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 21:40:48 PDT 2019
vsk added a comment.
Herald added a subscriber: asbirlea.
Herald added a project: LLVM.
As an alternative to removing the debug location, what about setting a line 0 location (with appropriate scope/inlinedAt info) to the hoisted instruction? It seems like that allows debuggers to give more helpful/specific backtraces. It also doesn't affect stepping (at least not in lldb, which collapses line 0 ranges). Example:
int load(int *p) { return *p; }
int licm(int seed, int n, int *p /* Points to garbage memory. */) {
int hash = seed;
for (int i = 0; i < n; ++i)
hash ^= hash + (seed >> i) + load(p); // <- Crash occurs here.
return hash;
}
With no location (current behavior, the crash looks like it occurs somewhere in 'main'):
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xdead)
* frame #0: 0x0000000100000f73 licm`main at licm.cc:0:3 [opt]
frame #1: 0x0000000100000f6c licm`main(argc=<unavailable>, argv=<unavailable>) at licm.cc:18 [opt]
With line 0 location:
* frame #0: 0x0000000100000f73 licm`main [inlined] load(p=<unavailable>) at licm.cc:0:3 [opt]
...
(lldb) up
frame #1: 0x0000000100000f73 licm`main at licm.cc:9 [opt]
6 int licm(int seed, int n, int *p /* Points to garbage memory. */) {
7 int hash = seed;
8 for (int i = 0; i < n; ++i)
-> 9 hash ^= hash + (seed >> i) + load(p); // <- Crash occurs here.
@danielcdh @wolfgangp -- Would switching to line 0 locations for hoisted instructions have an adverse effect on Sample PGO?
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D28390/new/
https://reviews.llvm.org/D28390
More information about the llvm-commits
mailing list