diff options
| author | Owen Anderson <resistor@mac.com> | 2010-10-19 17:21:58 +0000 | 
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2010-10-19 17:21:58 +0000 | 
| commit | 6c18d1aac08df0143d9a9810261421faeac81d4a (patch) | |
| tree | 030940dde09fdf79abd0fc960e253b2c553c042c /llvm/lib/Transforms/Utils | |
| parent | 50c925fe967754666400ccfec251ebd2b7cc62b0 (diff) | |
| download | bcm5719-llvm-6c18d1aac08df0143d9a9810261421faeac81d4a.tar.gz bcm5719-llvm-6c18d1aac08df0143d9a9810261421faeac81d4a.zip  | |
Get rid of static constructors for pass registration.  Instead, every pass exposes an initializeMyPassFunction(), which
must be called in the pass's constructor.  This function uses static dependency declarations to recursively initialize
the pass's dependencies.
Clients that only create passes through the createFooPass() APIs will require no changes.  Clients that want to use the
CommandLine options for passes will need to manually call the appropriate initialization functions in PassInitialization.h
before parsing commandline arguments.
I have tested this with all standard configurations of clang and llvm-gcc on Darwin.  It is possible that there are problems
with the static dependencies that will only be visible with non-standard options.  If you encounter any crash in pass
registration/creation, please send the testcase to me directly.
llvm-svn: 116820
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/InstructionNamer.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/LCSSA.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/LowerInvoke.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/LowerSwitch.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/Mem2Reg.cpp | 4 | 
7 files changed, 21 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp index e4f6631b31f..67c04944c07 100644 --- a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -36,7 +36,9 @@ STATISTIC(NumBroken, "Number of blocks inserted");  namespace {    struct BreakCriticalEdges : public FunctionPass {      static char ID; // Pass identification, replacement for typeid -    BreakCriticalEdges() : FunctionPass(ID) {} +    BreakCriticalEdges() : FunctionPass(ID) { +      initializeBreakCriticalEdgesPass(*PassRegistry::getPassRegistry()); +    }      virtual bool runOnFunction(Function &F); diff --git a/llvm/lib/Transforms/Utils/InstructionNamer.cpp b/llvm/lib/Transforms/Utils/InstructionNamer.cpp index d8d01c9a4ba..45c15de9437 100644 --- a/llvm/lib/Transforms/Utils/InstructionNamer.cpp +++ b/llvm/lib/Transforms/Utils/InstructionNamer.cpp @@ -23,7 +23,9 @@ using namespace llvm;  namespace {    struct InstNamer : public FunctionPass {      static char ID; // Pass identification, replacement for typeid -    InstNamer() : FunctionPass(ID) {} +    InstNamer() : FunctionPass(ID) { +      initializeInstNamerPass(*PassRegistry::getPassRegistry()); +    }      void getAnalysisUsage(AnalysisUsage &Info) const {        Info.setPreservesAll(); diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp index 193dd3895da..77aca02a517 100644 --- a/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -47,7 +47,9 @@ STATISTIC(NumLCSSA, "Number of live out of a loop variables");  namespace {    struct LCSSA : public LoopPass {      static char ID; // Pass identification, replacement for typeid -    LCSSA() : LoopPass(ID) {} +    LCSSA() : LoopPass(ID) { +      initializeLCSSAPass(*PassRegistry::getPassRegistry()); +    }      // Cached analysis information for the current function.      DominatorTree *DT; diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 8b47899d233..6ab6c243c41 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -65,7 +65,9 @@ STATISTIC(NumNested  , "Number of nested loops split out");  namespace {    struct LoopSimplify : public LoopPass {      static char ID; // Pass identification, replacement for typeid -    LoopSimplify() : LoopPass(ID) {} +    LoopSimplify() : LoopPass(ID) { +      initializeLoopSimplifyPass(*PassRegistry::getPassRegistry()); +    }      // AA - If we have an alias analysis object to update, this is it, otherwise      // this is null. @@ -111,11 +113,6 @@ INITIALIZE_PASS_BEGIN(LoopSimplify, "loopsimplify",                  "Canonicalize natural loops", true, false)  INITIALIZE_PASS_DEPENDENCY(DominatorTree)  INITIALIZE_PASS_DEPENDENCY(LoopInfo) -INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) -INITIALIZE_PASS_DEPENDENCY(BreakCriticalEdges) -INITIALIZE_PASS_DEPENDENCY(DominanceFrontier) -INITIALIZE_PASS_DEPENDENCY(LCSSA) -INITIALIZE_AG_DEPENDENCY(AliasAnalysis)  INITIALIZE_PASS_END(LoopSimplify, "loopsimplify",                  "Canonicalize natural loops", true, false) diff --git a/llvm/lib/Transforms/Utils/LowerInvoke.cpp b/llvm/lib/Transforms/Utils/LowerInvoke.cpp index 77d7f153d7e..025ae0d6169 100644 --- a/llvm/lib/Transforms/Utils/LowerInvoke.cpp +++ b/llvm/lib/Transforms/Utils/LowerInvoke.cpp @@ -79,7 +79,9 @@ namespace {      explicit LowerInvoke(const TargetLowering *tli = NULL,                           bool useExpensiveEHSupport = ExpensiveEHSupport)        : FunctionPass(ID), useExpensiveEHSupport(useExpensiveEHSupport), -        TLI(tli) { } +        TLI(tli) { +      initializeLowerInvokePass(*PassRegistry::getPassRegistry()); +    }      bool doInitialization(Module &M);      bool runOnFunction(Function &F); diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp index dce57f517bc..6db53f44d25 100644 --- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp +++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp @@ -33,7 +33,9 @@ namespace {    class LowerSwitch : public FunctionPass {    public:      static char ID; // Pass identification, replacement for typeid -    LowerSwitch() : FunctionPass(ID) {}  +    LowerSwitch() : FunctionPass(ID) { +      initializeLowerSwitchPass(*PassRegistry::getPassRegistry()); +    }       virtual bool runOnFunction(Function &F); diff --git a/llvm/lib/Transforms/Utils/Mem2Reg.cpp b/llvm/lib/Transforms/Utils/Mem2Reg.cpp index 588a1654f90..f3450b92d47 100644 --- a/llvm/lib/Transforms/Utils/Mem2Reg.cpp +++ b/llvm/lib/Transforms/Utils/Mem2Reg.cpp @@ -27,7 +27,9 @@ STATISTIC(NumPromoted, "Number of alloca's promoted");  namespace {    struct PromotePass : public FunctionPass {      static char ID; // Pass identification, replacement for typeid -    PromotePass() : FunctionPass(ID) {} +    PromotePass() : FunctionPass(ID) { +      initializePromotePassPass(*PassRegistry::getPassRegistry()); +    }      // runOnFunction - To run this pass, first we calculate the alloca      // instructions that are safe for promotion, then we promote each one.  | 

