diff options
author | Chris Lattner <sabre@nondot.org> | 2002-01-31 00:45:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-01-31 00:45:11 +0000 |
commit | 793c6b80d3e322c3fefb3c7314b054c7880d1691 (patch) | |
tree | c2d24f4cc875a6e1bf9bf3b3227464448850666f /lib | |
parent | 9c9be48b8396e7244e47d2af8890da8eec71c72d (diff) | |
download | external_llvm-793c6b80d3e322c3fefb3c7314b054c7880d1691.zip external_llvm-793c6b80d3e322c3fefb3c7314b054c7880d1691.tar.gz external_llvm-793c6b80d3e322c3fefb3c7314b054c7880d1691.tar.bz2 |
Convert xforms over to new pass structure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1605 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/IPO/ConstantMerge.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/DeadTypeElimination.cpp | 24 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalDCE.cpp | 17 | ||||
-rw-r--r-- | lib/Transforms/IPO/MutateStructTypes.cpp | 18 | ||||
-rw-r--r-- | lib/Transforms/IPO/SimpleStructMutation.cpp | 33 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 24 | ||||
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 16 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InductionVars.cpp | 34 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerAllocations.cpp | 1 |
9 files changed, 115 insertions, 54 deletions
diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index acb3b6b..0951c73 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -16,6 +16,8 @@ #include "llvm/Transforms/ConstantMerge.h" #include "llvm/GlobalVariable.h" +#include "llvm/Module.h" +#include "llvm/Method.h" // mergeDuplicateConstants - Workhorse for the pass. This eliminates duplicate // constants, starting at global ConstantNo, and adds vars to the map if they diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index c170e15..297eadd 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -13,7 +13,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/CleanupGCCOutput.h" +#include "llvm/Analysis/FindUsedTypes.h" #include "TransformInternals.h" +#include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" #include "llvm/iPHINode.h" @@ -225,8 +227,6 @@ static inline bool ShouldNukeSymtabEntry(const std::pair<string, Value*> &E) { bool CleanupGCCOutput::doInitialization(Module *M) { bool Changed = false; - FUT.doInitialization(M); - if (PtrSByte == 0) PtrSByte = PointerType::get(Type::SByteTy); @@ -491,19 +491,17 @@ static bool fixLocalProblems(Method *M) { // doPerMethodWork - This method simplifies the specified method hopefully. // bool CleanupGCCOutput::runOnMethod(Method *M) { - bool Changed = fixLocalProblems(M); - - FUT.runOnMethod(M); - return Changed; + return fixLocalProblems(M); } bool CleanupGCCOutput::doFinalization(Module *M) { bool Changed = false; - FUT.doFinalization(M); + if (M->hasSymbolTable()) { SymbolTable *ST = M->getSymbolTable(); - const std::set<const Type *> &UsedTypes = FUT.getTypes(); + const std::set<const Type *> &UsedTypes = + getAnalysis<FindUsedTypes>().getTypes(); // Check the symbol table for superfluous type entries that aren't used in // the program @@ -529,3 +527,13 @@ bool CleanupGCCOutput::doFinalization(Module *M) { } return Changed; } + +// getAnalysisUsageInfo - This function needs the results of the +// FindUsedTypes and FindUnsafePointerTypes analysis passes... +// +void CleanupGCCOutput::getAnalysisUsageInfo(Pass::AnalysisSet &Required, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + // FIXME: Invalidates the CFG + Required.push_back(FindUsedTypes::ID); +} diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index 664381c..1b64a0b 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -46,8 +46,17 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph &CallGraph) { } bool GlobalDCE::run(Module *M) { - // TODO: FIXME: GET THE CALL GRAPH FROM THE PASS! - // Create a call graph if one is not already available... - cfg::CallGraph CallGraph(M); - return RemoveUnreachableMethods(M, CallGraph); + return RemoveUnreachableMethods(M, getAnalysis<cfg::CallGraph>()); +} + +// getAnalysisUsageInfo - This function works on the call graph of a module. +// It is capable of updating the call graph to reflect the new state of the +// module. +// +void GlobalDCE::getAnalysisUsageInfo(Pass::AnalysisSet &Required, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Required.push_back(cfg::CallGraph::ID); + // FIXME: This should update the callgraph, not destroy it! + Destroyed.push_back(cfg::CallGraph::ID); } diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index 8beac2f..7710933 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -13,6 +13,7 @@ #include "llvm/Transforms/IPO/MutateStructTypes.h" #include "llvm/DerivedTypes.h" +#include "llvm/Module.h" #include "llvm/Method.h" #include "llvm/GlobalVariable.h" #include "llvm/SymbolTable.h" @@ -25,6 +26,12 @@ using std::map; using std::vector; +//FIXME: These headers are only included because the analyses are killed!!! +#include "llvm/Analysis/CallGraph.h" +#include "llvm/Analysis/FindUsedTypes.h" +#include "llvm/Analysis/FindUnsafePointerTypes.h" +//FIXME end + // To enable debugging, uncomment this... //#define DEBUG_MST(x) x @@ -515,3 +522,14 @@ bool MutateStructTypes::run(Module *M) { removeDeadGlobals(M); return true; } + +// getAnalysisUsageInfo - This function needs the results of the +// FindUsedTypes and FindUnsafePointerTypes analysis passes... +// +void MutateStructTypes::getAnalysisUsageInfo(Pass::AnalysisSet &Required, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Destroyed.push_back(FindUsedTypes::ID); + Destroyed.push_back(FindUnsafePointerTypes::ID); + Destroyed.push_back(cfg::CallGraph::ID); +} diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index 7e28af3..8583e3e 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -89,24 +89,16 @@ static inline void GetTransformation(const StructType *ST, SimpleStructMutation::TransformsType SimpleStructMutation::getTransforms(Module *M, enum Transform XForm) { - - // FIXME: These should be calculated by the Pass framework! - // We need to know which types to modify, and which types we CAN'T modify - FindUsedTypes *FUT = new FindUsedTypes(/*true*/); // TODO: Do symbol tables as well - FindUnsafePointerTypes *FUPT = new FindUnsafePointerTypes(); - - // Simutaneously find all of the types used, and all of the types that aren't - // safe. - // - PassManager Analyses; - Analyses.add(FUT); - Analyses.add(FUPT); - Analyses.run(M); // Do analyses + // TODO: Do symbol tables as well // Get the results out of the analyzers... - const set<PointerType*> &UnsafePTys = FUPT->getUnsafeTypes(); - const set<const Type *> &UsedTypes = FUT->getTypes(); + FindUsedTypes &FUT = getAnalysis<FindUsedTypes>(); + const set<const Type *> &UsedTypes = FUT.getTypes(); + + FindUnsafePointerTypes &FUPT = getAnalysis<FindUnsafePointerTypes>(); + const set<PointerType*> &UnsafePTys = FUPT.getUnsafeTypes(); + // Combine the two sets, weeding out non structure types. Closures in C++ @@ -144,3 +136,14 @@ SimpleStructMutation::TransformsType return Transforms; } + +// getAnalysisUsageInfo - This function needs the results of the +// FindUsedTypes and FindUnsafePointerTypes analysis passes... +// +void SimpleStructMutation::getAnalysisUsageInfo(Pass::AnalysisSet &Required, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided){ + Required.push_back(FindUsedTypes::ID); + Required.push_back(FindUnsafePointerTypes::ID); + MutateStructTypes::getAnalysisUsageInfo(Required, Destroyed, Provided); +} diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 3c3ba78..5449f22 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -42,7 +42,7 @@ public: // doADCE() - Run the Agressive Dead Code Elimination algorithm, returning // true if the method was modified. - bool doADCE(); + bool doADCE(cfg::DominanceFrontier &CDG); //===--------------------------------------------------------------------===// // The implementation of this class @@ -76,12 +76,7 @@ private: // doADCE() - Run the Agressive Dead Code Elimination algorithm, returning // true if the method was modified. // -bool ADCE::doADCE() { - // Compute the control dependence graph... Note that this has a side effect - // on the CFG: a new return bb is added and all returns are merged here. - // - cfg::DominanceFrontier CDG(cfg::DominatorSet(M, true)); - +bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { #ifdef DEBUG_ADCE cerr << "Method: " << M; #endif @@ -296,8 +291,19 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set<BasicBlock*> &VisitedBlocks, // doADCE - Execute the Agressive Dead Code Elimination Algorithm // -bool AgressiveDCE::doADCE(Method *M) { +bool AgressiveDCE::runOnMethod(Method *M) { if (M->isExternal()) return false; ADCE DCE(M); - return DCE.doADCE(); + return DCE.doADCE( + getAnalysis<cfg::DominanceFrontier>(cfg::DominanceFrontier::PostDomID)); +} + + +// getAnalysisUsageInfo - We require post dominance frontiers (aka Control +// Dependence Graph) +// +void AgressiveDCE::getAnalysisUsageInfo(Pass::AnalysisSet &Requires, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Requires.push_back(cfg::DominanceFrontier::PostDomID); } diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 35844ca..48faffe 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -8,7 +8,6 @@ #include "llvm/Transforms/Scalar/IndVarSimplify.h" #include "llvm/Analysis/InductionVariable.h" #include "llvm/Analysis/LoopInfo.h" -#include "llvm/Analysis/Dominators.h" #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/Type.h" @@ -185,14 +184,21 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) { return Changed; } -bool InductionVariableSimplify::doit(Method *M) { +bool InductionVariableSimplify::doit(Method *M, cfg::LoopInfo &Loops) { if (M->isExternal()) return false; - // Figure out the loop structure of the method... - cfg::LoopInfo Loops(M); - // Induction Variables live in the header nodes of the loops of the method... return reduce_apply_bool(Loops.getTopLevelLoops().begin(), Loops.getTopLevelLoops().end(), std::bind1st(std::ptr_fun(TransformLoop), &Loops)); } + +bool InductionVariableSimplify::runOnMethod(Method *M) { + return doit(M, getAnalysis<cfg::LoopInfo>()); +} + +void InductionVariableSimplify::getAnalysisUsageInfo(Pass::AnalysisSet &Req, + Pass::AnalysisSet &Dest, + Pass::AnalysisSet &Prov) { + Req.push_back(cfg::LoopInfo::ID); +} diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 6d7df41..48982f4 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -25,13 +25,12 @@ #include "llvm/Assembly/Writer.h" #include "llvm/SymbolTable.h" #include "llvm/iPHINode.h" +#include "llvm/Method.h" #include "Support/STLExtras.h" #include <algorithm> #include <iostream> using std::cerr; -#include "llvm/Analysis/LoopDepth.h" - // isLoopInvariant - Return true if the specified value/basic block source is // an interval invariant computation. // @@ -371,19 +370,11 @@ static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) { // This function loops over an interval partition of a program, reducing it // until the graph is gone. // -bool InductionVariableCannonicalize::doIt(Method *M) { - // TODO: REMOVE - if (0) { // Print basic blocks with their depth - LoopDepthCalculator LDC(M); - for (Method::iterator I = M->begin(); I != M->end(); ++I) { - cerr << "Basic Block Depth: " << LDC.getLoopDepth(*I) << *I; - } - } - - - cfg::IntervalPartition *IP = new cfg::IntervalPartition(M); +bool InductionVariableCannonicalize::doIt(Method *M, + cfg::IntervalPartition &IP) { bool Changed = false; +#if 0 while (!IP->isDegeneratePartition()) { Changed |= ProcessIntervalPartition(*IP); @@ -400,5 +391,22 @@ bool InductionVariableCannonicalize::doIt(Method *M) { } delete IP; +#endif return Changed; } + + +bool InductionVariableCannonicalize::runOnMethod(Method *M) { + return doIt(M, getAnalysis<cfg::IntervalPartition>()); +} + +// getAnalysisUsageInfo - This function works on the call graph of a module. +// It is capable of updating the call graph to reflect the new state of the +// module. +// +void InductionVariableCannonicalize::getAnalysisUsageInfo( + Pass::AnalysisSet &Required, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Required.push_back(cfg::IntervalPartition::ID); +} diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 0d26e2a..ff7a367 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -9,6 +9,7 @@ #include "llvm/Transforms/ChangeAllocations.h" #include "llvm/Target/TargetData.h" +#include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" #include "llvm/iOther.h" |