[llvm] [DebugInfo][RemoveDIs] Cope with instructions moving after themselves (PR #74113)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 06:03:38 PST 2023


================
@@ -200,8 +200,9 @@ void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I,
   // If we've been given the "Preserve" flag, then just move the DPValues with
   // the instruction, no more special handling needed.
   if (BB.IsNewDbgInfoFormat && DbgMarker && !Preserve) {
-    if (I != this->getIterator()) {
-      // "this" is definitely moving; detach any existing DPValues.
+    if (I != this->getIterator() || InsertAtHead) {
+      // "this" is definitely moving in the list, or it's moving ahead of it's
+      // attached DPValues. Detach any existing DPValues.
----------------
jmorse wrote:

Eeeshh, that's a big question, as it leads into the greater question of "does the movement of instructions like this actually _need_ to affect debug-info in any way". If an instruction is moving like this, it probably shouldn't have a line number attached, and so there should be no visible effect to the developer of these debug records moving or not. That then naturally moves onto the question of... shouldn't the debug records be linked in some way to the line numbers that they implicitly cover?

Something we can answer in the future, for now, I think it's not-a-bug to precisely match what happens in dbg.value mode.

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


More information about the llvm-commits mailing list