[llvm] [DebugInfo][SimpleLoopUnswitch] Fix missing debug location updates for new terminators (PR #98789)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 03:03:12 PDT 2024


================
@@ -973,7 +978,8 @@ static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT,
     }
     // Now nuke the switch and replace it with a direct branch.
     SIW.eraseFromParent();
-    BranchInst::Create(CommonSuccBB, BB);
+    Instruction *NewBI = BranchInst::Create(CommonSuccBB, BB);
+    NewBI->setDebugLoc(SIW->getDebugLoc());
----------------
SLTozer wrote:

Same here as above, `SIW` is deleted by `eraseFromParent` so we should copy its DebugLoc before erasing it.

https://github.com/llvm/llvm-project/pull/98789


More information about the llvm-commits mailing list