From 97ea7622b5001e08c76f35b2d9ca7cde5d520f94 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 20 Feb 2015 06:35:21 +0000 Subject: Remove the MCInstrInfo cached variable as it was only used in a single place and replace calls to getSubtargetImpl with calls to get the subtarget from the MachineFunction where valid. llvm-svn: 229971 --- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index d24a2a23d46..2ece39a73f6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -32,6 +32,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSubtargetInfo.h" @@ -151,10 +152,13 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, // 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. + const MCInstrInfo *MII = MF + ? MII = static_cast( + MF->getSubtarget().getInstrInfo()) + : MII = static_cast( + TM.getTarget().createMCInstrInfo()); std::unique_ptr TAP(TM.getTarget().createMCAsmParser( - *STI, *Parser, MII ? *MII : *static_cast( - TM.getTarget().createMCInstrInfo()), - TM.Options.MCOptions)); + *STI, *Parser, *MII, 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"); -- cgit v1.2.3