Spill/reload instructions are automatically generated by the compiler
and have no relation to the original source code. So it would be better
to not attach any debug location to them. The X86/AArch64/ARM/Thumb
backends all follow this way.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Please check X86/ARM 's loadRegFromStackSlot and storeRegToStackSlot, they all use empty DebugLoc() instead of MachineBasicBlock::iterator::getDebugLoc().
Looks good at first glance but would it be better to have some test coverage (if feasible)?
It is not easy to compose a proper test case for that, for example,
int foo; int as(int a) { foo += a; return foo; }
Build it with clang a.c -O0 -g --target=loongarch32, the difference is as following
We can see a .loc is eliminated by my patch. It is not good to test my patch with CHECK-NOT: .loc ***. We have to commit the test in another patch and then we can see the difference. But is it worthy to do so? This is just a tiny change.
Fine with me then, it's not one of those non-trivial changes that would benefit very much from test coverage anyway. I said "if feasible" in my original comment too ;-)