Unconditionally create a new MCInstrInfo in the asm printer for
authorEric Christopher <echristo@gmail.com>
Sat, 21 Feb 2015 09:09:15 +0000 (09:09 +0000)
committerEric Christopher <echristo@gmail.com>
Sat, 21 Feb 2015 09:09:15 +0000 (09:09 +0000)
asm parsing since it's not subtarget dependent and we can't depend
upon the one hanging off the MachineFunction's subtarget still
being around.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230135 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

index c95777e40d1b7c993c2cc3d35a15927f2eee1da9..e6e7c973c18f7c6a04581b7b7270d0db3cd15e46 100644 (file)
@@ -149,12 +149,11 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
   // emitInlineAsmEnd().
   MCSubtargetInfo STIOrig = *STI;
 
-  // We may create a new MCInstrInfo here since we might be at the module level
+  // We create a new MCInstrInfo here since we might be at the module level
   // and not have a MachineFunction to initialize the TargetInstrInfo from and
-  // we only need MCInstrInfo for asm parsing.
-  const MCInstrInfo *MII =
-      MF ? static_cast<const MCInstrInfo *>(MF->getSubtarget().getInstrInfo())
-         : static_cast<const MCInstrInfo *>(TM.getTarget().createMCInstrInfo());
+  // we only need MCInstrInfo for asm parsing. We create one unconditionally
+  // because it's not subtarget dependent.
+  std::unique_ptr<MCInstrInfo> MII(TM.getTarget().createMCInstrInfo());
   std::unique_ptr<MCTargetAsmParser> TAP(TM.getTarget().createMCAsmParser(
       *STI, *Parser, *MII, TM.Options.MCOptions));
   if (!TAP)