[llvm] [DebugInfo][RemoveDIs] Support maintaining DPValues in CodeGenPrepare (PR #73660)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 08:28:43 PST 2023


================
@@ -2829,34 +2836,46 @@ class TypePromotionTransaction {
       Instruction *PrevInst;
       BasicBlock *BB;
     } Point;
+    std::optional<DPValue::self_iterator> beforeDPValue = std::nullopt;
 
     /// Remember whether or not the instruction had a previous instruction.
     bool HasPrevInstruction;
 
   public:
     /// Record the position of \p Inst.
     InsertionHandler(Instruction *Inst) {
-      BasicBlock::iterator It = Inst->getIterator();
-      HasPrevInstruction = (It != (Inst->getParent()->begin()));
-      if (HasPrevInstruction)
-        Point.PrevInst = &*--It;
-      else
-        Point.BB = Inst->getParent();
+      HasPrevInstruction = (Inst != &*(Inst->getParent()->begin()));
+      BasicBlock *BB = Inst->getParent();
+
+      // Record where we would have to re-insert the instruction in the sequence
+      // of DPValues, if we ended up reinserting.
+      if (BB->IsNewDbgInfoFormat) {
+        DPMarker *DPM = BB->createMarker(Inst);
+        beforeDPValue = DPM->getReinsertionPosition();
----------------
jmorse wrote:

(Will remangle with the other patch too)

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


More information about the llvm-commits mailing list