- // Now that composite has been compiled, scan through the module, looking
- // for a main function. If main is defined, mark all other functions
- // internal.
- addPass(Passes, createInternalizePass(!DisableInternalize));
-
- // Now that we internalized some globals, see if we can hack on them!
- addPass(Passes, createGlobalOptimizerPass());
-
- // Linking modules together can lead to duplicated global constants, only
- // 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());
-
- if (!DisableInline)
- addPass(Passes, createFunctionInliningPass()); // Inline small functions
-
- addPass(Passes, createPruneEHPass()); // Remove dead EH info
- addPass(Passes, createGlobalDCEPass()); // Remove dead functions
-
- // If we didn't decide to inline a function, check to see if we can
- // transform it to pass arguments by value instead of by reference.
- addPass(Passes, createArgumentPromotionPass());
-
- // The IPO passes may leave cruft around. Clean up after them.
- addPass(Passes, createInstructionCombiningPass());
-
- addPass(Passes, createScalarReplAggregatesPass()); // Break up allocas
-
- // 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
- addPass(Passes, createDeadStoreEliminationPass()); // Nuke dead stores
-
- // Cleanup and simplify the code after the scalar optimizations.