[llvm] [DebugInfo][SimpleLoopUnswitch] Fix missing debug location updates (PR #97662)
Shan Huang via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 07:14:54 PDT 2024
================
@@ -2334,21 +2338,25 @@ static void unswitchNontrivialInvariants(
// nuke the initial terminator placed in the split block.
SplitBB->getTerminator()->eraseFromParent();
if (FullUnswitch) {
- // Splice the terminator from the original loop and rewrite its
- // successors.
- TI.moveBefore(*SplitBB, SplitBB->end());
-
// Keep a clone of the terminator for MSSA updates.
Instruction *NewTI = TI.clone();
NewTI->insertInto(ParentBB, ParentBB->end());
+ // Splice the terminator from the original loop and rewrite its
+ // successors.
+ TI.moveBefore(*SplitBB, SplitBB->end());
+ TI.dropLocation();
----------------
Apochens wrote:
`TI` is moved out of the loop and its debug location should be dropped. However, `NewTI` (the code moved up) which is cloned from `TI` should preserve `TI`'s debugl location, because `NewTI` is inserted into the original place where `TI` is at. In addition, `NewTI` will be replaced by a new branch instruction, which should inherit the debug location of `NewTI`.
So, I move the code down after the clone to preserve the debug location so that `NewTI` can preserve the right debug location while the debug location of `TI` can be correctly dropped.
https://github.com/llvm/llvm-project/pull/97662
More information about the llvm-commits
mailing list