diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-17 18:09:39 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-17 18:09:39 +0000 |
commit | 53459d710bd50d526ba78e43e66d9183c145d05b (patch) | |
tree | 539d4d6002c15089a28241e10d300f347a2395e5 | |
parent | edd7d11690027b9ff9387d85b7c235cd7fd2cf20 (diff) | |
download | external_llvm-53459d710bd50d526ba78e43e66d9183c145d05b.zip external_llvm-53459d710bd50d526ba78e43e66d9183c145d05b.tar.gz external_llvm-53459d710bd50d526ba78e43e66d9183c145d05b.tar.bz2 |
opt: Add -std-link-opts argument, matches llvm-ld's optimizations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76199 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/opt/opt.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index abfeace..b962ad9 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -81,11 +81,19 @@ static cl::opt<bool> DisableOptimizations("disable-opt", cl::desc("Do not run any optimization passes")); +static cl::opt<bool> +DisableInternalize("disable-internalize", + cl::desc("Do not mark all symbols as internal")); + static cl::opt<bool> StandardCompileOpts("std-compile-opts", cl::desc("Include the standard compile time optimizations")); static cl::opt<bool> +StandardLinkOpts("std-link-opts", + cl::desc("Include the standard link time optimizations")); + +static cl::opt<bool> OptLevelO1("O1", cl::desc("Optimization level 1. Similar to llvm-gcc -O1")); @@ -311,6 +319,20 @@ void AddStandardCompilePasses(PassManager &PM) { InliningPass); } +void AddStandardLinkPasses(PassManager &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)); + + if (DisableOptimizations) return; + + createStandardLTOPasses(&PM, /*Internalize=*/ !DisableInternalize, + /*RunInliner=*/ !DisableInline, + /*VerifyEach=*/ VerifyEach); +} + } // anonymous namespace @@ -404,6 +426,12 @@ int main(int argc, char **argv) { StandardCompileOpts = false; } + if (StandardLinkOpts && + StandardLinkOpts.getPosition() < PassList.getPosition(i)) { + AddStandardLinkPasses(Passes); + StandardLinkOpts = false; + } + if (OptLevelO1 && OptLevelO1.getPosition() < PassList.getPosition(i)) { AddOptimizationPasses(Passes, *FPasses, 1); OptLevelO1 = false; @@ -458,17 +486,22 @@ int main(int argc, char **argv) { StandardCompileOpts = false; } + if (StandardLinkOpts) { + AddStandardLinkPasses(Passes); + StandardLinkOpts = false; + } + if (OptLevelO1) { - AddOptimizationPasses(Passes, *FPasses, 1); - } + AddOptimizationPasses(Passes, *FPasses, 1); + } if (OptLevelO2) { - AddOptimizationPasses(Passes, *FPasses, 2); - } + AddOptimizationPasses(Passes, *FPasses, 2); + } if (OptLevelO3) { - AddOptimizationPasses(Passes, *FPasses, 3); - } + AddOptimizationPasses(Passes, *FPasses, 3); + } if (OptLevelO1 || OptLevelO2 || OptLevelO3) { for (Module::iterator I = M.get()->begin(), E = M.get()->end(); |