[lld] r263851 - [ELF] Refactor run of LTO passes into an helper. NFC.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 18 16:22:40 PDT 2016
Author: davide
Date: Fri Mar 18 18:22:40 2016
New Revision: 263851
URL: http://llvm.org/viewvc/llvm-project?rev=263851&view=rev
Log:
[ELF] Refactor run of LTO passes into an helper. NFC.
Requested by: Rui Ueyama.
Modified:
lld/trunk/ELF/SymbolTable.cpp
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=263851&r1=263850&r2=263851&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Mar 18 18:22:40 2016
@@ -119,6 +119,27 @@ static void saveBCFile(Module &M, String
WriteBitcodeToFile(&M, OS, /* ShouldPreserveUseListOrder */ true);
}
+static void runLTOPasses(Module &M, TargetMachine &TM) {
+ // Run LTO passes.
+ // FIXME: Reduce code duplication by sharing this code with the gold plugin.
+ legacy::PassManager LtoPasses;
+ LtoPasses.add(
+ createTargetTransformInfoWrapperPass(TM.getTargetIRAnalysis()));
+ PassManagerBuilder PMB;
+ PMB.LibraryInfo = new TargetLibraryInfoImpl(Triple(TM.getTargetTriple()));
+ PMB.Inliner = createFunctionInliningPass();
+ PMB.VerifyInput = true;
+ PMB.VerifyOutput = true;
+ PMB.LoopVectorize = true;
+ PMB.SLPVectorize = true;
+ PMB.OptLevel = 2; // FIXME: This should be an option.
+ PMB.populateLTOPassManager(LtoPasses);
+ LtoPasses.run(M);
+
+ if (Config->SaveTemps)
+ saveBCFile(M, ".lto.opt.bc");
+}
+
// Codegen the module M and returns the resulting InputFile.
template <class ELFT>
std::unique_ptr<InputFile> SymbolTable<ELFT>::codegen(Module &M) {
@@ -139,24 +160,7 @@ std::unique_ptr<InputFile> SymbolTable<E
std::unique_ptr<TargetMachine> TM(
TheTarget->createTargetMachine(TripleStr, "", "", Options, R));
- // Run LTO passes.
- // FIXME: Reduce code duplication by sharing this code with the gold plugin.
- legacy::PassManager LtoPasses;
- LtoPasses.add(
- createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
- PassManagerBuilder PMB;
- PMB.LibraryInfo = new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()));
- PMB.Inliner = createFunctionInliningPass();
- PMB.VerifyInput = true;
- PMB.VerifyOutput = true;
- PMB.LoopVectorize = true;
- PMB.SLPVectorize = true;
- PMB.OptLevel = 2; // FIXME: This should be an option.
- PMB.populateLTOPassManager(LtoPasses);
- LtoPasses.run(M);
-
- if (Config->SaveTemps)
- saveBCFile(M, ".lto.opt.bc");
+ runLTOPasses(M, *TM);
raw_svector_ostream OS(OwningLTOData);
legacy::PassManager CodeGenPasses;
More information about the llvm-commits
mailing list