[llvm-commits] [llvm] r76199 - /llvm/trunk/tools/opt/opt.cpp
Daniel Dunbar
daniel at zuster.org
Fri Jul 17 11:09:41 PDT 2009
Author: ddunbar
Date: Fri Jul 17 13:09:39 2009
New Revision: 76199
URL: http://llvm.org/viewvc/llvm-project?rev=76199&view=rev
Log:
opt: Add -std-link-opts argument, matches llvm-ld's optimizations.
Modified:
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=76199&r1=76198&r2=76199&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Fri Jul 17 13:09:39 2009
@@ -81,11 +81,19 @@
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 @@
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 @@
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 @@
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();
More information about the llvm-commits
mailing list