[llvm] [DebugInfo][RemoveDIs] Add local-utility plumbing for DPValues (PR #72276)
Jeremy Morse via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 03:21:46 PST 2023
================
@@ -2266,6 +2504,33 @@ static bool rewriteDebugUsers(
UndefOrSalvage.insert(DII);
}
}
+
+ // DPValue implementation of the above.
+ // RemoveDIs misery: The above loop of intrinsic-users are ordered by the
+ // use-list of the corresponding metadata-as-value: in reverse order of when
+ // they were added. Wheras DPUsers are ordered by when they were added to
+ // the replaceable-metadata map, i.e., in the order they were added. Thus to
+ // have matching orders between the two, we have to reverse here. For
+ // RemoveDIs we might in the long run need to consider whether this implicit
+ // ordering is relied upon by any other part of LLVM.
+ for (auto *DPV : llvm::reverse(DPUsers)) {
+ Instruction *MarkedInstr = DPV->getMarker()->MarkedInstr;
+ Instruction *NextNonDebug = MarkedInstr;
+ // The next instruction might still be a dbg.declare, skip over it.
+ if (isa<DbgVariableIntrinsic>(NextNonDebug))
+ NextNonDebug = NextNonDebug->getNextNonDebugInstruction();
+
+ if (DomPointAfterFrom && NextNonDebug == &DomPoint) {
+ LLVM_DEBUG(dbgs() << "MOVE: " << *DPV << '\n');
+ DPV->removeFromParent();
+ // Ensure there's a marker.
+ DomPoint.getParent()->createMarker(std::next(DomPoint.getIterator()));
+ DomPoint.getParent()->insertDPValueAfter(DPV, &DomPoint);
----------------
jmorse wrote:
I agree, moved. (This is all part of a theme of the TrailingDPValues stuff flushing out various places that need to explicitly create DPMarkers).
https://github.com/llvm/llvm-project/pull/72276
More information about the llvm-commits
mailing list