[llvm-commits] CVS: llvm/tools/llvm-ld/Optimize.cpp
Reid Spencer
reid at x10sys.com
Thu Feb 8 10:14:17 PST 2007
Changes in directory llvm/tools/llvm-ld:
Optimize.cpp updated: 1.16 -> 1.17
---
Log message:
For PR1153: http://llvm.org/PR1153 :
Make llvm-ld more gccld-like by having it run the same set of passes. The
delta was probably due to lack of llvm-ld being maintained. Just another
reason to have only one optimizing linker in in LLVM.
---
Diffs of the changes: (+32 -13)
Optimize.cpp | 45 ++++++++++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 13 deletions(-)
Index: llvm/tools/llvm-ld/Optimize.cpp
diff -u llvm/tools/llvm-ld/Optimize.cpp:1.16 llvm/tools/llvm-ld/Optimize.cpp:1.17
--- llvm/tools/llvm-ld/Optimize.cpp:1.16 Mon Feb 5 14:47:21 2007
+++ llvm/tools/llvm-ld/Optimize.cpp Thu Feb 8 12:13:59 2007
@@ -73,13 +73,22 @@
static cl::opt<bool> VerifyEach("verify-each",
cl::desc("Verify intermediate results of all passes"));
-static cl::opt<bool> Strip("s",
- cl::desc("Strip symbol info from executable"));
-
static cl::alias ExportDynamic("export-dynamic",
cl::aliasopt(DisableInternalize),
cl::desc("Alias for -disable-internalize"));
+static cl::opt<bool> Strip("strip-all",
+ cl::desc("Strip all symbol info from executable"));
+
+static cl::alias A0("s", cl::desc("Alias for --strip-all"),
+ cl::aliasopt(Strip));
+
+static cl::opt<bool> StripDebug("strip-debug",
+ cl::desc("Strip debugger symbol info from executable"));
+
+static cl::alias A1("S", cl::desc("Alias for --strip-debug"),
+ cl::aliasopt(StripDebug));
+
// A utility function that adds a pass to the pass manager but will also add
// a verifier pass after if we're supposed to verify.
static inline void addPass(PassManager &PM, Pass *P) {
@@ -114,6 +123,11 @@
// internal.
addPass(Passes, createInternalizePass(!DisableInternalize));
+ // Propagate constants at call sites into the functions they call. This
+ // opens opportunities for globalopt (and inlining) by substituting function
+ // pointers passed as arguments to direct uses of functions.
+ addPass(Passes, createIPSCCPPass());
+
// Now that we internalized some globals, see if we can hack on them!
addPass(Passes, createGlobalOptimizerPass());
@@ -121,22 +135,20 @@
// keep one copy of each constant...
addPass(Passes, createConstantMergePass());
- // If the -s command line option was specified, strip the symbols out of the
- // resulting program to make it smaller. -s is a GLD option that we are
- // supporting.
- if (Strip)
- addPass(Passes, createStripSymbolsPass());
-
- // Propagate constants at call sites into the functions they call.
- addPass(Passes, createIPConstantPropagationPass());
-
// Remove unused arguments from functions...
addPass(Passes, createDeadArgEliminationPass());
+ // Reduce the code after globalopt and ipsccp. Both can open up significant
+ // simplification opportunities, and both can propagate functions through
+ // function pointers. When this happens, we often have to resolve varargs
+ // calls, etc, so let instcombine do this.
+ addPass(Passes, createInstructionCombiningPass());
+
if (!DisableInline)
addPass(Passes, createFunctionInliningPass()); // Inline small functions
addPass(Passes, createPruneEHPass()); // Remove dead EH info
+ addPass(Passes, createGlobalOptimizerPass()); // Optimize globals again.
addPass(Passes, createGlobalDCEPass()); // Remove dead functions
// If we didn't decide to inline a function, check to see if we can
@@ -148,8 +160,9 @@
addPass(Passes, createScalarReplAggregatesPass()); // Break up allocas
- // Run a few AA driven optimizations, to cleanup the code.
+ // Run a few AA driven optimizations here and now, to cleanup the code.
addPass(Passes, createGlobalsModRefPass()); // IP alias analysis
+
addPass(Passes, createLICMPass()); // Hoist loop invariants
addPass(Passes, createLoadValueNumberingPass()); // GVN for load instrs
addPass(Passes, createGCSEPass()); // Remove common subexprs
@@ -165,6 +178,12 @@
addPass(Passes, createGlobalDCEPass());
}
+ // If the -s or -S command line options were specified, strip the symbols out
+ // of the resulting program to make it smaller. -s and -S are GNU ld options
+ // that we are supporting; they alias -strip-all and -strip-debug.
+ if (Strip || StripDebug)
+ addPass(Passes, createStripSymbolsPass(StripDebug && !Strip));
+
// Create a new optimization pass for each one specified on the command line
std::auto_ptr<TargetMachine> target;
for (unsigned i = 0; i < OptimizationList.size(); ++i) {
More information about the llvm-commits
mailing list