mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 06:00:28 +00:00
Move some logic to populateLTOPassManager.
This will avoid code duplication in the next commit which calls it directly from the gold plugin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9db660ecaa
commit
7b4eb02b6d
@ -20,6 +20,7 @@
|
||||
namespace llvm {
|
||||
class Pass;
|
||||
class TargetLibraryInfo;
|
||||
class TargetMachine;
|
||||
|
||||
// The old pass manager infrastructure is hidden in a legacy namespace now.
|
||||
namespace legacy {
|
||||
@ -119,6 +120,9 @@ public:
|
||||
bool RerollLoops;
|
||||
bool LoadCombine;
|
||||
bool DisableGVNLoadPRE;
|
||||
bool VerifyInput;
|
||||
bool VerifyOutput;
|
||||
bool StripDebug;
|
||||
|
||||
private:
|
||||
/// ExtensionList - This is list of all of the extensions that are registered.
|
||||
@ -136,6 +140,7 @@ public:
|
||||
private:
|
||||
void addExtensionsToPM(ExtensionPointTy ETy, PassManagerBase &PM) const;
|
||||
void addInitialAliasAnalysisPasses(PassManagerBase &PM) const;
|
||||
void addLTOOptimizationPasses(PassManagerBase &PM);
|
||||
|
||||
public:
|
||||
/// populateFunctionPassManager - This fills in the function pass manager,
|
||||
@ -145,7 +150,7 @@ public:
|
||||
|
||||
/// populateModulePassManager - This sets up the primary pass manager.
|
||||
void populateModulePassManager(PassManagerBase &MPM);
|
||||
void populateLTOPassManager(PassManagerBase &PM);
|
||||
void populateLTOPassManager(PassManagerBase &PM, TargetMachine *TM = nullptr);
|
||||
};
|
||||
|
||||
/// Registers a function for adding a standard set of passes. This should be
|
||||
|
@ -458,32 +458,21 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
|
||||
// Instantiate the pass manager to organize the passes.
|
||||
PassManager passes;
|
||||
|
||||
// Start off with a verification pass.
|
||||
passes.add(createVerifierPass());
|
||||
passes.add(createDebugInfoVerifierPass());
|
||||
|
||||
// Add an appropriate DataLayout instance for this module...
|
||||
mergedModule->setDataLayout(TargetMach->getSubtargetImpl()->getDataLayout());
|
||||
passes.add(new DataLayoutPass(mergedModule));
|
||||
|
||||
TargetMach->addAnalysisPasses(passes);
|
||||
|
||||
Triple TargetTriple(TargetMach->getTargetTriple());
|
||||
// Enabling internalize here would use its AllButMain variant. It
|
||||
// keeps only main if it exists and does nothing for libraries. Instead
|
||||
// we create the pass ourselves with the symbol list provided by the linker.
|
||||
if (!DisableOpt) {
|
||||
PassManagerBuilder PMB;
|
||||
PMB.DisableGVNLoadPRE = DisableGVNLoadPRE;
|
||||
if (!DisableInline)
|
||||
PMB.Inliner = createFunctionInliningPass();
|
||||
PMB.LibraryInfo = new TargetLibraryInfo(TargetTriple);
|
||||
PMB.populateLTOPassManager(passes);
|
||||
}
|
||||
PassManagerBuilder PMB;
|
||||
PMB.DisableGVNLoadPRE = DisableGVNLoadPRE;
|
||||
if (!DisableInline)
|
||||
PMB.Inliner = createFunctionInliningPass();
|
||||
PMB.LibraryInfo = new TargetLibraryInfo(TargetTriple);
|
||||
if (DisableOpt)
|
||||
PMB.OptLevel = 0;
|
||||
PMB.VerifyInput = true;
|
||||
PMB.VerifyOutput = true;
|
||||
|
||||
// Make sure everything is still good.
|
||||
passes.add(createVerifierPass());
|
||||
passes.add(createDebugInfoVerifierPass());
|
||||
PMB.populateLTOPassManager(passes, TargetMach);
|
||||
|
||||
PassManager codeGenPasses;
|
||||
|
||||
|
@ -17,11 +17,14 @@
|
||||
#include "llvm-c/Transforms/PassManagerBuilder.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Target/TargetLibraryInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
#include "llvm/Transforms/IPO.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Vectorize.h"
|
||||
@ -78,6 +81,9 @@ PassManagerBuilder::PassManagerBuilder() {
|
||||
RerollLoops = RunLoopRerolling;
|
||||
LoadCombine = RunLoadCombine;
|
||||
DisableGVNLoadPRE = false;
|
||||
VerifyInput = false;
|
||||
VerifyOutput = false;
|
||||
StripDebug = false;
|
||||
}
|
||||
|
||||
PassManagerBuilder::~PassManagerBuilder() {
|
||||
@ -313,11 +319,7 @@ void PassManagerBuilder::populateModulePassManager(PassManagerBase &MPM) {
|
||||
addExtensionsToPM(EP_OptimizerLast, MPM);
|
||||
}
|
||||
|
||||
void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM) {
|
||||
// Add LibraryInfo if we have some.
|
||||
if (LibraryInfo)
|
||||
PM.add(new TargetLibraryInfo(*LibraryInfo));
|
||||
|
||||
void PassManagerBuilder::addLTOOptimizationPasses(PassManagerBase &PM) {
|
||||
// Provide AliasAnalysis services for optimizations.
|
||||
addInitialAliasAnalysisPasses(PM);
|
||||
|
||||
@ -408,6 +410,35 @@ void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM) {
|
||||
PM.add(createGlobalDCEPass());
|
||||
}
|
||||
|
||||
void PassManagerBuilder::populateLTOPassManager(PassManagerBase &PM,
|
||||
TargetMachine *TM) {
|
||||
if (TM) {
|
||||
const DataLayout *DL = TM->getSubtargetImpl()->getDataLayout();
|
||||
PM.add(new DataLayoutPass(*DL));
|
||||
TM->addAnalysisPasses(PM);
|
||||
}
|
||||
|
||||
if (LibraryInfo)
|
||||
PM.add(new TargetLibraryInfo(*LibraryInfo));
|
||||
|
||||
if (VerifyInput)
|
||||
PM.add(createVerifierPass());
|
||||
|
||||
if (StripDebug)
|
||||
PM.add(createStripSymbolsPass(true));
|
||||
|
||||
if (VerifyInput)
|
||||
PM.add(createDebugInfoVerifierPass());
|
||||
|
||||
if (OptLevel != 0)
|
||||
addLTOOptimizationPasses(PM);
|
||||
|
||||
if (VerifyOutput) {
|
||||
PM.add(createVerifierPass());
|
||||
PM.add(createDebugInfoVerifierPass());
|
||||
}
|
||||
}
|
||||
|
||||
inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
|
||||
return reinterpret_cast<PassManagerBuilder*>(P);
|
||||
}
|
||||
|
@ -254,18 +254,12 @@ static void AddStandardCompilePasses(PassManagerBase &PM) {
|
||||
}
|
||||
|
||||
static void AddStandardLinkPasses(PassManagerBase &PM) {
|
||||
PM.add(createVerifierPass()); // Verify that input is correct
|
||||
|
||||
// If the -strip-debug command line option was specified, do it.
|
||||
if (StripDebug)
|
||||
addPass(PM, createStripSymbolsPass(true));
|
||||
|
||||
// Verify debug info only after it's (possibly) stripped.
|
||||
PM.add(createDebugInfoVerifierPass());
|
||||
|
||||
if (DisableOptimizations) return;
|
||||
|
||||
PassManagerBuilder Builder;
|
||||
Builder.VerifyInput = true;
|
||||
Builder.StripDebug = StripDebug;
|
||||
if (DisableOptimizations)
|
||||
Builder.OptLevel = 0;
|
||||
|
||||
if (!DisableInline)
|
||||
Builder.Inliner = createFunctionInliningPass();
|
||||
Builder.populateLTOPassManager(PM);
|
||||
|
Loading…
Reference in New Issue
Block a user