From f6456a560c2d483608372890ac125d79ba7572e2 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 19 Feb 2015 21:24:23 +0000 Subject: [PATCH] Remove a call to TargetMachine::getSubtarget from the inline asm support in the asm printer. If we can get a subtarget from the machine function then we should do so, otherwise we can go ahead and create a default one since we're at the module level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229916 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index 4dd41ca678e..a8b00561fe7 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -92,7 +92,17 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, !OutStreamer.isIntegratedAssemblerRequired()) { emitInlineAsmStart(); OutStreamer.EmitRawText(Str); - emitInlineAsmEnd(TM.getSubtarget(), nullptr); + // If we have a machine function then grab the MCSubtarget off of that, + // otherwise we're at the module level and want to construct one from + // the default CPU and target triple. + if (MF) { + emitInlineAsmEnd(MF->getSubtarget(), nullptr); + } else { + std::unique_ptr STI(TM.getTarget().createMCSubtargetInfo( + TM.getTargetTriple(), TM.getTargetCPU(), + TM.getTargetFeatureString())); + emitInlineAsmEnd(*STI, nullptr); + } return; }