[PATCH] D50621: [DebugInfo] Fix bug in LiveDebugVariables.
Hsiangkai Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 12 23:44:32 PDT 2018
HsiangKai updated this revision to Diff 160291.
Repository:
rL LLVM
https://reviews.llvm.org/D50621
Files:
include/llvm/CodeGen/SlotIndexes.h
lib/CodeGen/LiveDebugVariables.cpp
Index: lib/CodeGen/LiveDebugVariables.cpp
===================================================================
--- lib/CodeGen/LiveDebugVariables.cpp
+++ lib/CodeGen/LiveDebugVariables.cpp
@@ -583,10 +583,16 @@
continue;
}
// DBG_VALUE has no slot index, use the previous instruction instead.
- SlotIndex Idx =
- MBBI == MBB->begin()
- ? LIS->getMBBStartIdx(MBB)
- : LIS->getInstructionIndex(*std::prev(MBBI)).getRegSlot();
+ SlotIndex Idx;
+ if (MBBI == MBB->begin()) {
+ Idx = LIS->getMBBStartIdx(MBB);
+ } else {
+ const MachineInstr &PrevMI = *std::prev(MBBI);
+ if (PrevMI.isDebugInstr())
+ Idx = LIS->getMBBStartIdx(MBB);
+ else
+ Idx = LIS->getInstructionIndex(PrevMI).getRegSlot();
+ }
// Handle consecutive DBG_VALUE instructions with the same slot index.
do {
if (handleDebugValue(*MBBI, Idx)) {
Index: include/llvm/CodeGen/SlotIndexes.h
===================================================================
--- include/llvm/CodeGen/SlotIndexes.h
+++ include/llvm/CodeGen/SlotIndexes.h
@@ -414,7 +414,12 @@
SlotIndex getInstructionIndex(const MachineInstr &MI) const {
// Instructions inside a bundle have the same number as the bundle itself.
const MachineInstr &BundleStart = *getBundleStart(MI.getIterator());
- Mi2IndexMap::const_iterator itr = mi2iMap.find(&BundleStart);
+ // Skip debug instructions.
+ const MachineInstr &BundleNonDebug = *skipDebugInstructionsForward(
+ BundleStart.getIterator(), MI.getIterator());
+ assert(!BundleNonDebug.isDebugInstr() &&
+ "There is no non-debug instruction in the bundle.");
+ Mi2IndexMap::const_iterator itr = mi2iMap.find(&BundleNonDebug);
assert(itr != mi2iMap.end() && "Instruction not found in maps.");
return itr->second;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50621.160291.patch
Type: text/x-patch
Size: 1945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180813/86c49d9a/attachment.bin>
More information about the llvm-commits
mailing list