[llvm] 2f7c050 - [DebugInfo][RemoveDIs] Allow speculative-DPMarker creation

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 24 07:18:28 PST 2023


Author: Jeremy Morse
Date: 2023-11-24T15:17:32Z
New Revision: 2f7c050e1943f63af0823c1327b44579d0bdb584

URL: https://github.com/llvm/llvm-project/commit/2f7c050e1943f63af0823c1327b44579d0bdb584
DIFF: https://github.com/llvm/llvm-project/commit/2f7c050e1943f63af0823c1327b44579d0bdb584.diff

LOG: [DebugInfo][RemoveDIs] Allow speculative-DPMarker creation

There's good justification for having a function specifying "I need there to be
a marker here, so return the marker there or create a new one". This was going
to come later in the series, but it's starting to become necessary much eariler
alas.

Make use of it in spliceDebugInfo, where we can occasionally splice DPValues
onto the end() iterator of a block while it's been edited.

Added: 
    

Modified: 
    llvm/lib/IR/BasicBlock.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 7037f5f524ee069..6c08ca1efc65288 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -39,8 +39,8 @@ cl::opt<bool>
 DPMarker *BasicBlock::createMarker(Instruction *I) {
   assert(IsNewDbgInfoFormat &&
          "Tried to create a marker in a non new debug-info block!");
-  assert(I->DbgMarker == nullptr &&
-         "Tried to create marker for instuction that already has one!");
+  if (I->DbgMarker)
+    return I->DbgMarker;
   DPMarker *Marker = new DPMarker();
   Marker->MarkedInstr = I;
   I->DbgMarker = Marker;
@@ -918,8 +918,8 @@ void BasicBlock::spliceDebugInfo(BasicBlock::iterator Dest, BasicBlock *Src,
   // move their markers onto Last. They remain in the Src block. No action
   // needed.
   if (!ReadFromHead) {
-    DPMarker *OntoLast = Src->getMarker(Last);
-    DPMarker *FromFirst = Src->getMarker(First);
+    DPMarker *OntoLast = Src->createMarker(Last);
+    DPMarker *FromFirst = Src->createMarker(First);
     OntoLast->absorbDebugValues(*FromFirst,
                                 true); // Always insert at head of it.
   }


        


More information about the llvm-commits mailing list