Give gccld more guts
[oota-llvm.git] / tools / gccld / GenerateCode.cpp
index 26b115f26290190991c301b2dfb6571a82c33677..bf32400c6348c4298abce134e1453f4e36ff155d 100644 (file)
@@ -16,6 +16,7 @@
 #include "gccld.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
+#include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Bytecode/WriteBytecodePass.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Transforms/IPO.h"
@@ -84,6 +85,13 @@ GenerateBytecode (Module *M, bool Strip, bool Internalize, std::ostream *Out) {
   if (!DisableInline)
     Passes.add(createFunctionInliningPass());   // Inline small functions
 
+  // Run a few AA driven optimizations here and now, to cleanup the code.
+  // Eventually we should put an IP AA in place here.
+
+  Passes.add(createLICMPass());                 // Hoist loop invariants
+  Passes.add(createLoadValueNumberingPass());   // GVN for load instructions
+  Passes.add(createGCSEPass());                 // Remove common subexprs
+
   // The FuncResolve pass may leave cruft around if functions were prototyped
   // differently than they were defined.  Remove this cruft.
   Passes.add(createInstructionCombiningPass());