[llvm] [DebugInfo][RemoveDIs] Don't allocate one DPMarker per instruction (PR #79345)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 03:32:45 PST 2024


================
@@ -212,14 +208,13 @@ void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I,
   BB.getInstList().splice(I, getParent()->getInstList(), getIterator());
 
   if (BB.IsNewDbgInfoFormat && !Preserve) {
-    if (!DbgMarker)
-      BB.createMarker(this);
     DPMarker *NextMarker = getParent()->getNextMarker(this);
 
     // If we're inserting at point I, and not in front of the DPValues attached
     // there, then we should absorb the DPValues attached to I.
-    if (NextMarker && !InsertAtHead)
-      DbgMarker->absorbDebugValues(*NextMarker, false);
+    if (!InsertAtHead && NextMarker && !NextMarker->empty()) {
+      adoptDbgValues(&BB, I, false);
----------------
OCHyams wrote:

Given that (most? all?) other uses of `adoptDbgValues` involve a check-if-not-then-cleanup-something, can this get a comment explaining why it isn't needed?

Do we want to make `adoptDbgValues` nodiscard, or is that too severe?

+1 to what @SLTozer said:

> it's not easy to intuit what's happening in each case and what the difference is without really digging into it ... [can  we] extract common behaviour out to other functions [in a future patch].

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


More information about the llvm-commits mailing list