aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugVariables.cpp
diff options
context:
space:
mode:
authorHsiangkai Wang <hsiangkai@gmail.com>2018-09-05 05:58:53 +0000
committerHsiangkai Wang <hsiangkai@gmail.com>2018-09-05 05:58:53 +0000
commitb2b7f5f6d76d256331827f6cbc8e835282f30ed5 (patch)
treea99ad5abf24fa948a8ced7de72980b222ba1a4ad /llvm/lib/CodeGen/LiveDebugVariables.cpp
parentc3d1d107ffad20d33f5088ced13482a0ea7dd53f (diff)
downloadllvm-b2b7f5f6d76d256331827f6cbc8e835282f30ed5.zip
llvm-b2b7f5f6d76d256331827f6cbc8e835282f30ed5.tar.gz
llvm-b2b7f5f6d76d256331827f6cbc8e835282f30ed5.tar.bz2
[DebugInfo] Fix bug in LiveDebugVariables.
In lib/CodeGen/LiveDebugVariables.cpp, it uses std::prev(MBBI) to get DebugValue's SlotIndex. However, the previous instruction may be also a debug instruction. It could not use a debug instruction to query SlotIndex in mi2iMap. Scan all debug instructions and use the first debug instruction to query SlotIndex for following debug instructions. Only handle DBG_VALUE in handleDebugValue(). Differential Revision: https://reviews.llvm.org/D50621 llvm-svn: 341446
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveDebugVariables.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index b258a0e..4c002d4 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -578,23 +578,28 @@ bool LDVImpl::collectDebugValues(MachineFunction &mf) {
MachineBasicBlock *MBB = &*MFI;
for (MachineBasicBlock::iterator MBBI = MBB->begin(), MBBE = MBB->end();
MBBI != MBBE;) {
- if (!MBBI->isDebugValue()) {
+ // Use the first debug instruction in the sequence to get a SlotIndex
+ // for following consecutive debug instructions.
+ if (!MBBI->isDebugInstr()) {
++MBBI;
continue;
}
- // DBG_VALUE has no slot index, use the previous instruction instead.
+ // Debug instructions has no slot index. Use the previous
+ // non-debug instruction's SlotIndex as its SlotIndex.
SlotIndex Idx =
MBBI == MBB->begin()
? LIS->getMBBStartIdx(MBB)
: LIS->getInstructionIndex(*std::prev(MBBI)).getRegSlot();
- // Handle consecutive DBG_VALUE instructions with the same slot index.
+ // Handle consecutive debug instructions with the same slot index.
do {
- if (handleDebugValue(*MBBI, Idx)) {
+ // Only handle DBG_VALUE in handleDebugValue(). Skip all other
+ // kinds of debug instructions.
+ if (MBBI->isDebugValue() && handleDebugValue(*MBBI, Idx)) {
MBBI = MBB->erase(MBBI);
Changed = true;
} else
++MBBI;
- } while (MBBI != MBBE && MBBI->isDebugValue());
+ } while (MBBI != MBBE && MBBI->isDebugInstr());
}
}
return Changed;