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

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 03:02:41 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());
----------------
OCHyams wrote:

I think we need to move `SIW.eraseFromParent()` after this line?

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


More information about the llvm-commits mailing list