NewExit and epilog PreHeader should has the same debug loc as the original loop
body, instead of original loop exit.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
test/Transforms/LoopUnroll/runtime-loop1.ll | ||
---|---|---|
16 | The test is now defining BODY_LOC three times in the EPILOG run. Once should be enough. (The unmodified test incorrectly defines it twice, and you've added a third.) |
lib/Transforms/Utils/LoopUnrollRuntime.cpp | ||
---|---|---|
651–652 | Am I right that this will set more DebugLoc for epilog case than for prolog? If so, why? NewExit->getTerminator()->setDebugLoc( Header->getTerminator()->getDebugLoc()); If not - reuse it in the line 654 and give wider name (like NewExitTerminator). | |
test/Transforms/LoopUnroll/runtime-epilog-debuginfo.ll | ||
3 | Please add a comment on what test is checking. |
lib/Transforms/Utils/LoopUnrollRuntime.cpp | ||
---|---|---|
651–652 | NewExit gets its DebugLoc from LatchExit. This DebugLoc is not part of the original loop, it's after the original loop (say loc A). The conditional branch deciding if epilog will be added to NewExit, which should be part of the original loop in lexical sense. If a later pass search for debuginfo in RPOT order, it will first find loc A at the conditional branch rather than the merge point of unrolled and epilog loop. On the other hand, PrologPreHeader gets its debug info from original PreHeader. |
lib/Transforms/Utils/LoopUnrollRuntime.cpp | ||
---|---|---|
651–652 | Thanks for detailed explanation. Now it is clear for me. I'd add this as a comment: |
The change makes sense to me. It should not affect SamplePGO as terminator instructions is not used in profile annotation.
Am I right that this will set more DebugLoc for epilog case than for prolog? If so, why?
If "TI" is supposed to be used only once I wouldn't create it at all:
If not - reuse it in the line 654 and give wider name (like NewExitTerminator).
EpilogPreHeader = SplitBlock(NewExit, NewExitTerminator, DT, LI);