CodeGen: Create a proper ModuleSlotTracker for MachineInstr
[oota-llvm.git] / lib / CodeGen / MachineInstr.cpp
index 39a395081db7ad85849c93780cb6230fd81b2e4e..fdc4226ad9267e62afb8035b46be5e75d0c0c48b 100644 (file)
@@ -1532,8 +1532,13 @@ void MachineInstr::dump() const {
 }
 
 void MachineInstr::print(raw_ostream &OS, bool SkipOpers) const {
-  ModuleSlotTracker DummyMST(nullptr);
-  print(OS, DummyMST, SkipOpers);
+  const Module *M = nullptr;
+  if (const MachineBasicBlock *MBB = getParent())
+    if (const MachineFunction *MF = MBB->getParent())
+      M = MF->getFunction()->getParent();
+
+  ModuleSlotTracker MST(M);
+  print(OS, MST, SkipOpers);
 }
 
 void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST,