From 8d89e7bdbcea38fe2ab3c85d91359712cd45714b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 9 May 2006 04:13:41 +0000 Subject: [PATCH] Patch to make some xforms preserve each other. Patch contributed by Domagoj Babic! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28181 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/LowerAllocations.cpp | 7 +++++++ lib/Transforms/Utils/LowerSelect.cpp | 7 ++++++- lib/Transforms/Utils/LowerSwitch.cpp | 11 ++++++++++- lib/Transforms/Utils/Mem2Reg.cpp | 5 +++++ lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 4 ++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 0a6dc09147e..f6e70e11f5f 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" @@ -39,6 +40,12 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.setPreservesCFG(); + + // This is a cluster of orthogonal Transforms: + AU.addPreserved(); + AU.addPreservedID(PromoteMemoryToRegisterID); + AU.addPreservedID(LowerSelectID); + AU.addPreservedID(LowerSwitchID); } /// doPassInitialization - For the lower allocations pass, this ensures that diff --git a/lib/Transforms/Utils/LowerSelect.cpp b/lib/Transforms/Utils/LowerSelect.cpp index 6a24c294cfd..27dd4307285 100644 --- a/lib/Transforms/Utils/LowerSelect.cpp +++ b/lib/Transforms/Utils/LowerSelect.cpp @@ -19,6 +19,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Pass.h" @@ -37,7 +38,11 @@ namespace { LowerSelect(bool onlyfp = false) : OnlyFP(onlyfp) {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { - // Doesn't really preserve anything. It can certainly destroy the CFG. + // This certainly destroys the CFG. + // This is a cluster of orthogonal Transforms: + AU.addPreserved(); + AU.addPreservedID(PromoteMemoryToRegisterID); + AU.addPreservedID(LowerSwitchID); } bool runOnFunction(Function &F); diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index ebad6c36dbc..14d3027b918 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Instructions.h" @@ -32,7 +33,15 @@ namespace { /// modifies the CFG! class LowerSwitch : public FunctionPass { public: - bool runOnFunction(Function &F); + virtual bool runOnFunction(Function &F); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + // This is a cluster of orthogonal Transforms + AU.addPreserved(); + AU.addPreservedID(PromoteMemoryToRegisterID); + AU.addPreservedID(LowerSelectID); + } + typedef std::pair Case; typedef std::vector::iterator CaseItr; private: diff --git a/lib/Transforms/Utils/Mem2Reg.cpp b/lib/Transforms/Utils/Mem2Reg.cpp index c15d10c824e..9ca2c8300da 100644 --- a/lib/Transforms/Utils/Mem2Reg.cpp +++ b/lib/Transforms/Utils/Mem2Reg.cpp @@ -14,6 +14,7 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/PromoteMemToReg.h" +#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Instructions.h" #include "llvm/Function.h" @@ -37,6 +38,10 @@ namespace { AU.addRequired(); AU.addRequired(); AU.setPreservesCFG(); + // This is a cluster of orthogonal Transforms + AU.addPreserved(); + AU.addPreservedID(LowerSelectID); + AU.addPreservedID(LowerSwitchID); } }; diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index 0c1eda7c0cc..d3c7b328958 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -32,6 +32,10 @@ Pass *llvm::createUnifyFunctionExitNodesPass() { void UnifyFunctionExitNodes::getAnalysisUsage(AnalysisUsage &AU) const{ // We preserve the non-critical-edgeness property AU.addPreservedID(BreakCriticalEdgesID); + // This is a cluster of orthogonal Transforms + AU.addPreservedID(PromoteMemoryToRegisterID); + AU.addPreservedID(LowerSelectID); + AU.addPreservedID(LowerSwitchID); } // UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new