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.

llvm-svn: 229916
This commit is contained in:
Eric Christopher 2015-02-19 21:24:23 +00:00
parent 4343922dde
commit 457864178f
1 changed files with 11 additions and 1 deletions

View File

@ -92,7 +92,17 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
!OutStreamer.isIntegratedAssemblerRequired()) {
emitInlineAsmStart();
OutStreamer.EmitRawText(Str);
emitInlineAsmEnd(TM.getSubtarget<MCSubtargetInfo>(), 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<MCSubtargetInfo>(), nullptr);
} else {
std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo(
TM.getTargetTriple(), TM.getTargetCPU(),
TM.getTargetFeatureString()));
emitInlineAsmEnd(*STI, nullptr);
}
return;
}