diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-26 00:17:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-26 00:17:21 +0000 |
commit | 3a15d707340eef80e01651a4529965ca1a3f3b2f (patch) | |
tree | 3d3945f3f94c93a33ee567da99eeb661b433334d /lib/Transforms/IPO/SimpleStructMutation.cpp | |
parent | 7afd98d144342de13df1ec5ffc0efc1cf40e2815 (diff) |
Converted SimpleStructMutation to take TargetData as a required pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3932 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/SimpleStructMutation.cpp')
-rw-r--r-- | lib/Transforms/IPO/SimpleStructMutation.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index 022d6d822c..4e21dd69a0 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -12,7 +12,6 @@ #include "llvm/Target/TargetData.h" #include "llvm/DerivedTypes.h" #include <algorithm> -#include <iostream> using std::vector; using std::set; using std::pair; @@ -20,8 +19,6 @@ using std::pair; namespace { struct SimpleStructMutation : public MutateStructTypes { enum Transform { SwapElements, SortElements }; - const TargetData &TD; - SimpleStructMutation(const TargetData &td) : TD(td) {} virtual bool run(Module &M) = 0; @@ -29,6 +26,7 @@ namespace { // FindUsedTypes and FindUnsafePointerTypes analysis passes... // virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired<TargetData>(); AU.addRequired<FindUsedTypes>(); AU.addRequired<FindUnsafePointerTypes>(); MutateStructTypes::getAnalysisUsage(AU); @@ -39,8 +37,6 @@ namespace { }; struct SwapStructElements : public SimpleStructMutation { - SwapStructElements(const TargetData &TD) : SimpleStructMutation(TD) {} - virtual bool run(Module &M) { setTransforms(getTransforms(M, SwapElements)); bool Changed = MutateStructTypes::run(M); @@ -50,8 +46,6 @@ namespace { }; struct SortStructElements : public SimpleStructMutation { - SortStructElements(const TargetData &TD) : SimpleStructMutation(TD) {} - virtual bool run(Module &M) { setTransforms(getTransforms(M, SortElements)); bool Changed = MutateStructTypes::run(M); @@ -59,8 +53,15 @@ namespace { return Changed; } }; + + RegisterOpt<SwapStructElements> X("swapstructs", + "Swap structure types around"); + RegisterOpt<SortStructElements> Y("sortstructs", + "Sort structure elements by size"); } // end anonymous namespace +Pass *createSwapElementsPass() { return new SwapStructElements(); } +Pass *createSortElementsPass() { return new SortStructElements(); } // PruneTypes - Given a type Ty, make sure that neither it, or one of its @@ -168,6 +169,7 @@ SimpleStructMutation::TransformsType // Build up a set of structure types that we are going to modify, and // information describing how to modify them. std::map<const StructType*, vector<int> > Transforms; + TargetData &TD = getAnalysis<TargetData>(); for (set<const StructType*>::iterator I = TypesToModify.begin(), E = TypesToModify.end(); I != E; ++I) { @@ -179,20 +181,3 @@ SimpleStructMutation::TransformsType return Transforms; } - - -Pass *createSwapElementsPass(const TargetData &TD) { - return new SwapStructElements(TD); -} -Pass *createSortElementsPass(const TargetData &TD) { - return new SortStructElements(TD); -} - -namespace { - RegisterOpt<SwapStructElements> X("swapstructs", - "Swap structure types around", - createSwapElementsPass); - RegisterOpt<SortStructElements> Y("sortstructs", - "Sort structure elements by size", - createSortElementsPass); -} |