[llvm] [DebugInfo][JumpThreading] Fix missing debug location updates (PR #91581)

Shan Huang via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 07:48:38 PDT 2024


================
@@ -1278,9 +1278,12 @@ bool JumpThreadingPass::simplifyPartiallyRedundantLoad(LoadInst *LoadI) {
     // only happen in dead loops.
     if (AvailableVal == LoadI)
       AvailableVal = PoisonValue::get(LoadI->getType());
-    if (AvailableVal->getType() != LoadI->getType())
+    if (AvailableVal->getType() != LoadI->getType()) {
       AvailableVal = CastInst::CreateBitOrPointerCast(
           AvailableVal, LoadI->getType(), "", LoadI->getIterator());
+      if (Instruction *CI = dyn_cast<Instruction>(AvailableVal))
+        CI->setDebugLoc(LoadI->getDebugLoc());
----------------
Apochens wrote:

Ok, I will try other codebases. (Actually, I have tried to remove the assertion out of the `then` branch and found [a test file](https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/JumpThreading/thread-loads.ll) (test8). But I cannot modify it to obtain the desired one.)

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


More information about the llvm-commits mailing list