[llvm] r216211 - Move some logic to populateLTOPassManager.
Rafael Espindola
rafael.espindola at gmail.com
Thu Aug 21 13:03:45 PDT 2014
Author: rafael
Date: Thu Aug 21 15:03:44 2014
New Revision: 216211
URL: http://llvm.org/viewvc/llvm-project?rev=216211&view=rev
Log:
Move some logic to populateLTOPassManager.
This will avoid code duplication in the next commit which calls it directly
from the gold plugin.
Modified:
llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h
llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h?rev=216211&r1=216210&r2=216211&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO/PassManagerBuilder.h Thu Aug 21 15:03:44 2014
@@ -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
Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=216211&r1=216210&r2=216211&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Thu Aug 21 15:03:44 2014
@@ -458,32 +458,21 @@ bool LTOCodeGenerator::generateObjectFil
// 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;
Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=216211&r1=216210&r2=216211&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Thu Aug 21 15:03:44 2014
@@ -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::populateModuleP
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::populateLTOPass
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);
}
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=216211&r1=216210&r2=216211&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Thu Aug 21 15:03:44 2014
@@ -254,18 +254,12 @@ static void AddStandardCompilePasses(Pas
}
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);
More information about the llvm-commits
mailing list