Implement a more powerful, simpler, pass system. This pass system can figure
out how to run a collection of passes optimially given their behaviors and
charactaristics.
Convert code to use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1507 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 8a2208d..7f9acf0 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -34,14 +34,13 @@
indvars, instcombine, sccp, adce, raise,
// Interprocedural optimizations...
- globaldce, swapstructs,
+ globaldce, swapstructs, sortstructs,
};
struct {
enum Opts OptID;
Pass *ThePass;
} OptTable[] = {
- { swapstructs, 0 },
{ dce , new opt::DeadCodeElimination() },
{ constprop , new opt::ConstantPropogation() },
{ inlining , new opt::MethodInlining() },
@@ -55,8 +54,11 @@
{ raise , new RaisePointerReferences() },
{ trace , new InsertTraceCode(true, true) },
{ tracem , new InsertTraceCode(false, true) },
- { print , new PrintModulePass("Current Method: \n",&cerr) },
+ { print , new PrintMethodPass("Current Method: \n",&cerr) },
{ cleangcc , new CleanupGCCOutput() },
+ { globaldce , new GlobalDCE() },
+ { swapstructs, new SimpleStructMutation(SimpleStructMutation::SwapElements) },
+ { sortstructs, new SimpleStructMutation(SimpleStructMutation::SortElements) },
};
cl::String InputFilename ("", "Load <arg> file to optimize", cl::NoFlags, "-");
@@ -78,6 +80,7 @@
clEnumVal(globaldce , "Remove unreachable globals"),
clEnumVal(swapstructs, "Swap structure types around"),
+ clEnumVal(sortstructs, "Sort structure elements"),
clEnumVal(cleangcc , "Cleanup GCC Output"),
clEnumVal(raise , "Raise to Higher Level"),
@@ -95,18 +98,7 @@
return;
}
- // Special cases that haven't been fit into a consistent framework yet...
- switch (Opt) {
- case globaldce: {
- GlobalDCE GDCE; GDCE.run(M); return;
- }
- case swapstructs: {
- PrebuiltStructMutation SM(M, PrebuiltStructMutation::SortElements);
- SM.run(M); return;
- }
- default:
- cerr << "Optimization tables inconsistent!!\n";
- }
+ cerr << "Optimization tables inconsistent!!\n";
}
int main(int argc, char **argv) {
@@ -118,6 +110,8 @@
return 1;
}
+ PassManager Passes;
+
// Run all of the optimizations specified on the command line
for (unsigned i = 0; i < OptimizationList.size(); ++i)
RunOptimization(M.get(), OptimizationList[i]);