diff options
Diffstat (limited to 'lib/CodeGen/LLVMTargetMachine.cpp')
-rw-r--r-- | lib/CodeGen/LLVMTargetMachine.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index 61face2..9c23368 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -12,23 +12,23 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetMachine.h" - #include "llvm/Analysis/JumpInstrTableInfo.h" #include "llvm/Analysis/Passes.h" #include "llvm/CodeGen/AsmPrinter.h" +#include "llvm/CodeGen/BasicTTIImpl.h" #include "llvm/CodeGen/ForwardControlFlowIntegrity.h" #include "llvm/CodeGen/JumpInstrTables.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/IR/IRPrintingPasses.h" +#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Verifier.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSubtargetInfo.h" -#include "llvm/PassManager.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" @@ -78,8 +78,10 @@ LLVMTargetMachine::LLVMTargetMachine(const Target &T, StringRef Triple, CodeGenInfo = T.createMCCodeGenInfo(Triple, RM, CM, OL); } -void LLVMTargetMachine::addAnalysisPasses(PassManagerBase &PM) { - PM.add(createBasicTargetTransformInfoPass(this)); +TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() { + return TargetIRAnalysis([this](Function &F) { + return TargetTransformInfo(BasicTTIImpl(this, F)); + }); } /// addPassesToX helper drives creation and initialization of TargetPassConfig. @@ -90,7 +92,7 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM, AnalysisID StopAfter) { // Add internal analysis passes from the target machine. - TM->addAnalysisPasses(PM); + PM.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis())); // Targets may override createPassConfig to provide a target-specific // subclass. @@ -114,7 +116,7 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM, // all the per-module stuff we're generating, including MCContext. MachineModuleInfo *MMI = new MachineModuleInfo( *TM->getMCAsmInfo(), *TM->getSubtargetImpl()->getRegisterInfo(), - &TM->getSubtargetImpl()->getTargetLowering()->getObjFileLowering()); + TM->getObjFileLowering()); PM.add(MMI); // Set up a MachineFunction for the rest of CodeGen to work on. @@ -222,13 +224,11 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, } // Create the AsmPrinter, which takes ownership of AsmStreamer if successful. - FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer); + FunctionPass *Printer = + getTarget().createAsmPrinter(*this, std::move(AsmStreamer)); if (!Printer) return true; - // If successful, createAsmPrinter took ownership of AsmStreamer. - AsmStreamer.release(); - PM.add(Printer); return false; @@ -262,20 +262,16 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, if (!MCE || !MAB) return true; - std::unique_ptr<MCStreamer> AsmStreamer; - AsmStreamer.reset(getTarget() - .createMCObjectStreamer(getTargetTriple(), *Ctx, *MAB, - Out, MCE, STI, - Options.MCOptions.MCRelaxAll)); + std::unique_ptr<MCStreamer> AsmStreamer(getTarget().createMCObjectStreamer( + getTargetTriple(), *Ctx, *MAB, Out, MCE, STI, + Options.MCOptions.MCRelaxAll)); // Create the AsmPrinter, which takes ownership of AsmStreamer if successful. - FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer); + FunctionPass *Printer = + getTarget().createAsmPrinter(*this, std::move(AsmStreamer)); if (!Printer) return true; - // If successful, createAsmPrinter took ownership of AsmStreamer. - AsmStreamer.release(); - PM.add(Printer); return false; // success! |