[llvm] r344770 - [CodeGen] Fix for PR39094.
Hsiangkai Wang via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 18 18:52:54 PDT 2018
Author: hsiangkai
Date: Thu Oct 18 18:52:54 2018
New Revision: 344770
URL: http://llvm.org/viewvc/llvm-project?rev=344770&view=rev
Log:
[CodeGen] Fix for PR39094.
When using MachineInstr to get SlotIndex, the MI could not be a debug
instruction. mi2iMap does not contain debug instructions in it.
After enabling DBG_LABEL in the generated code, the first instruction in
the bundle may be a debug instruction. In this patch, I use the first
non-debug instruction in the bundle to query SlotIndex in mi2iMap.
Bugzilla report: https://bugs.llvm.org/show_bug.cgi?id=39094
Differential revision: https://reviews.llvm.org/D52927
Modified:
llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=344770&r1=344769&r2=344770&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Thu Oct 18 18:52:54 2018
@@ -413,10 +413,14 @@ class raw_ostream;
/// Returns the base index for the given instruction.
SlotIndex getInstructionIndex(const MachineInstr &MI) const {
// Instructions inside a bundle have the same number as the bundle itself.
- const MachineInstr &BundleStart = *getBundleStart(MI.getIterator());
- assert(!BundleStart.isDebugInstr() &&
+ auto BundleStart = getBundleStart(MI.getIterator());
+ auto BundleEnd = getBundleEnd(MI.getIterator());
+ // Use the first non-debug instruction in the bundle to get SlotIndex.
+ const MachineInstr &BundleNonDebug =
+ *skipDebugInstructionsForward(BundleStart, BundleEnd);
+ assert(!BundleNonDebug.isDebugInstr() &&
"Could not use a debug instruction to query mi2iMap.");
- Mi2IndexMap::const_iterator itr = mi2iMap.find(&BundleStart);
+ Mi2IndexMap::const_iterator itr = mi2iMap.find(&BundleNonDebug);
assert(itr != mi2iMap.end() && "Instruction not found in maps.");
return itr->second;
}
More information about the llvm-commits
mailing list