diff options
Diffstat (limited to 'lib/Transforms/IPO')
-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 |
5 files changed, 67 insertions, 27 deletions
diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index acb3b6b937..0951c731e1 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 c170e15164..297eaddfba 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 664381cec6..1b64a0b369 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 8beac2f2d0..77109330c4 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 7e28af3df3..8583e3e850 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); +} |