aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugVariables.cpp
diff options
context:
space:
mode:
authorDavid Stenberg <david.stenberg@ericsson.com>2024-09-20 13:04:45 +0200
committerDavid Stenberg <david.stenberg@ericsson.com>2024-10-15 11:36:24 +0200
commit97861981cccce546b37f56e3e99e68d37c7586c7 (patch)
treed3e61373c00f6baee7a0c3cf0c8e69871277a7c5 /llvm/lib/CodeGen/LiveDebugVariables.cpp
parentf719886e1aa0d09cab1298d22495cdacb2ed4b5f (diff)
downloadllvm-97861981cccce546b37f56e3e99e68d37c7586c7.zip
llvm-97861981cccce546b37f56e3e99e68d37c7586c7.tar.gz
llvm-97861981cccce546b37f56e3e99e68d37c7586c7.tar.bz2
[LiveDebugVariables] Fix a DBG_VALUE reordering issue (#111124)
LDV could reorder reinserted fragment and non-fragment debug values for the same variable (compared to the input order), potentially resulting in stale values being presented. For example, before: DBG_VALUE 1001, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 16) DBG_VALUE 1002, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 16, 16) DBG_VALUE %0, $noreg, !13, !DIExpression() After (without this patch): DBG_VALUE %stack.0, 0, !13, !DIExpression() DBG_VALUE 1002, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 16, 16) DBG_VALUE 1001, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 16) It would also reorder DBG_VALUEs for different variables. Although that does not matter for the debug information output, it resulted in some noise in before/after pass diffs. This should hopefully align so that instruction referencing and DBG_VALUE emit debug instructions in the same order (see the sdag-salvage-add.ll change).
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugVariables.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 822a1be..2ff346d 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -1625,8 +1625,9 @@ findInsertLocation(MachineBasicBlock *MBB, SlotIndex Idx, LiveIntervals &LIS,
}
// Don't insert anything after the first terminator, though.
- return MI->isTerminator() ? MBB->getFirstTerminator() :
- std::next(MachineBasicBlock::iterator(MI));
+ auto It = MI->isTerminator() ? MBB->getFirstTerminator()
+ : std::next(MachineBasicBlock::iterator(MI));
+ return skipDebugInstructionsForward(It, MBB->end());
}
/// Find an iterator for inserting the next DBG_VALUE instruction