From 2105ae98f6c84a133e5298cea4e53bd9bebb6ca2 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 19 Feb 2015 23:52:35 +0000 Subject: [PATCH] Only use the initialized MCInstrInfo if it's been initialized already during SetupMachineFunction. This is also the single use of MII and it'll be changing to TargetInstrInfo (which is MachineFunction based) in the next commit here. llvm-svn: 229931 --- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index a2e5460..57f05be 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -148,8 +148,12 @@ 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 + // and not have a MachineFunction to initialize the TargetInstrInfo from and + // we only need MCInstrInfo for asm parsing. std::unique_ptr TAP(TM.getTarget().createMCAsmParser( - *STI, *Parser, *MII, TM.Options.MCOptions)); + *STI, *Parser, MII ? *MII : *TM.getTarget().createMCInstrInfo(), + TM.Options.MCOptions)); if (!TAP) report_fatal_error("Inline asm not supported by this streamer because" " we don't have an asm parser for this target\n"); -- 2.7.4