[DebugInfo][NFC] Refactor debug intrinsic copy and delete to instead just move
authorOCHyams <orlando.hyams@sony.com>
Thu, 20 Oct 2022 13:17:47 +0000 (14:17 +0100)
committerOCHyams <orlando.hyams@sony.com>
Thu, 20 Oct 2022 14:12:49 +0000 (15:12 +0100)
Reviewed By: jryans

Differential Revision: https://reviews.llvm.org/D133304

llvm/lib/Transforms/Utils/LoopUtils.cpp

index 75a755c..c007a59 100644 (file)
@@ -636,15 +636,14 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
     // Since debug values in the loop have been deleted, inserting an undef
     // dbg.value truncates the range of any dbg.value before the loop where the
     // loop used to be. This is particularly important for constant values.
-    DIBuilder DIB(*ExitBlock->getModule());
     Instruction *InsertDbgValueBefore = ExitBlock->getFirstNonPHI();
     assert(InsertDbgValueBefore &&
            "There should be a non-PHI instruction in exit block, else these "
            "instructions will have no parent.");
-    for (auto *DVI : DeadDebugInst)
-      DIB.insertDbgValueIntrinsic(UndefValue::get(Builder.getInt32Ty()),
-                                  DVI->getVariable(), DVI->getExpression(),
-                                  DVI->getDebugLoc(), InsertDbgValueBefore);
+    for (auto *DVI : DeadDebugInst) {
+      DVI->setUndef();
+      DVI->moveBefore(InsertDbgValueBefore);
+    }
   }
 
   // Remove the block from the reference counting scheme, so that we can