[PATCH] D52927: [CodeGen] Fix for PR39094.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 5 00:41:13 PDT 2018


HsiangKai created this revision.
HsiangKai added reviewers: mstorsjo, aprantl, probinson, dblaikie.
Herald added a subscriber: arphaman.

When using MachineInstr to get SlotIndex, the MI could not be a debug
instruction. mi2iMap does not contain debug instructions in it.

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


Repository:
  rL LLVM

https://reviews.llvm.org/D52927

Files:
  include/llvm/CodeGen/SlotIndexes.h


Index: include/llvm/CodeGen/SlotIndexes.h
===================================================================
--- include/llvm/CodeGen/SlotIndexes.h
+++ include/llvm/CodeGen/SlotIndexes.h
@@ -413,10 +413,16 @@
     /// 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() &&
+      MachineBasicBlock::const_iterator BundleStart = getBundleStart(
+                                                          MI.getIterator());
+      MachineBasicBlock::const_iterator 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;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52927.168439.patch
Type: text/x-patch
Size: 1430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181005/8cabf1a8/attachment.bin>


More information about the llvm-commits mailing list