summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-03-19 22:01:00 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-03-19 22:01:00 +0000
commit070843d60bb12ed4d4b16e278621cf08cd68f6a5 (patch)
tree4772e1b25c74818383280f18bf7f1a185e432f9a /llvm/lib/LTO
parent3a00691f3d6d281b5bf13564b81aef1d3e408c51 (diff)
downloadbcm5719-llvm-070843d60bb12ed4d4b16e278621cf08cd68f6a5.tar.gz
bcm5719-llvm-070843d60bb12ed4d4b16e278621cf08cd68f6a5.zip
libLTO, llvm-lto, gold: Introduce flag for controlling optimization level.
This change also introduces a link-time optimization level of 1. This optimization level runs only the globaldce pass as well as cleanup passes for passes that run at -O0, specifically simplifycfg which cleans up lowerbitsets. http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150316/266951.html llvm-svn: 232769
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 990b578acde..797c64941ef 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -71,7 +71,7 @@ LTOCodeGenerator::LTOCodeGenerator()
LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
: OwnedContext(std::move(Context)), Context(*OwnedContext),
- IRLinker(new Module("ld-temp.o", *OwnedContext)) {
+ IRLinker(new Module("ld-temp.o", *OwnedContext)), OptLevel(2) {
initialize();
}
@@ -291,12 +291,11 @@ const void *LTOCodeGenerator::compileOptimized(size_t *length,
bool LTOCodeGenerator::compile_to_file(const char **name,
- bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
bool disableVectorization,
std::string &errMsg) {
- if (!optimize(disableOpt, disableInline, disableGVNLoadPRE,
+ if (!optimize(disableInline, disableGVNLoadPRE,
disableVectorization, errMsg))
return false;
@@ -304,12 +303,11 @@ bool LTOCodeGenerator::compile_to_file(const char **name,
}
const void* LTOCodeGenerator::compile(size_t *length,
- bool disableOpt,
bool disableInline,
bool disableGVNLoadPRE,
bool disableVectorization,
std::string &errMsg) {
- if (!optimize(disableOpt, disableInline, disableGVNLoadPRE,
+ if (!optimize(disableInline, disableGVNLoadPRE,
disableVectorization, errMsg))
return nullptr;
@@ -363,9 +361,25 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
MCpu = "cyclone";
}
+ CodeGenOpt::Level CGOptLevel;
+ switch (OptLevel) {
+ case 0:
+ CGOptLevel = CodeGenOpt::None;
+ break;
+ case 1:
+ CGOptLevel = CodeGenOpt::Less;
+ break;
+ case 2:
+ CGOptLevel = CodeGenOpt::Default;
+ break;
+ case 3:
+ CGOptLevel = CodeGenOpt::Aggressive;
+ break;
+ }
+
TargetMach = march->createTargetMachine(TripleStr, MCpu, FeatureStr, Options,
RelocModel, CodeModel::Default,
- CodeGenOpt::Aggressive);
+ CGOptLevel);
return true;
}
@@ -512,8 +526,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
}
/// Optimize merged modules using various IPO passes
-bool LTOCodeGenerator::optimize(bool DisableOpt,
- bool DisableInline,
+bool LTOCodeGenerator::optimize(bool DisableInline,
bool DisableGVNLoadPRE,
bool DisableVectorization,
std::string &errMsg) {
@@ -542,8 +555,7 @@ bool LTOCodeGenerator::optimize(bool DisableOpt,
if (!DisableInline)
PMB.Inliner = createFunctionInliningPass();
PMB.LibraryInfo = new TargetLibraryInfoImpl(TargetTriple);
- if (DisableOpt)
- PMB.OptLevel = 0;
+ PMB.OptLevel = OptLevel;
PMB.VerifyInput = true;
PMB.VerifyOutput = true;
OpenPOWER on IntegriCloud