Hi,<br><br>A number of transforms are actually independent, so here's a partial fix. I updated the<br>dependencies in a cluster of transforms: LowerSwitch, Mem2Reg, LowerSelect, <br>LowerAllocations, UnifyFunctionExitNodes.
<br><br>The patch has been tested, but not extensively. PassManager doesn't complain, and<br>the result of a test pass that requires all these (except for LowerAllocations) together<br>works fine.<br><br>Domagoj<br><br><br>
***************************** PATCH BEGIN **********************************************<br><br>Index: ./lib/Transforms/Scalar/LowerSwitch.cpp<br>===================================================================<br>RCS file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/LowerSwitch.cpp,v
<br>retrieving revision 1.19<br>diff -u -p -r1.19 LowerSwitch.cpp<br>--- ./lib/Transforms/Scalar/LowerSwitch.cpp 2 May 2006 04:24:36 -0000 1.19<br>+++ ./lib/Transforms/Scalar/LowerSwitch.cpp 3 May 2006 18:01:53 -0000
<br>@@ -14,6 +14,7 @@<br> //===----------------------------------------------------------------------===//<br> <br> #include "llvm/Transforms/Scalar.h"<br>+#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
<br> #include "llvm/Constants.h"<br> #include "llvm/Function.h"<br> #include "llvm/Instructions.h"<br>@@ -32,7 +33,15 @@ namespace {<br> /// modifies the CFG!<br> class LowerSwitch : public FunctionPass {
<br> public:<br>- bool runOnFunction(Function &F);<br>+ virtual bool runOnFunction(Function &F);<br>+ <br>+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br>+ // This is a cluster of orthogonal Transforms
<br>+ AU.addPreserved<UnifyFunctionExitNodes>();<br>+ AU.addPreservedID(PromoteMemoryToRegisterID);<br>+ AU.addPreservedID(LowerSelectID);<br>+ }<br>+ <br> typedef std::pair<Constant*, BasicBlock*> Case;
<br> typedef std::vector<Case>::iterator CaseItr;<br> private:<br>Index: ./lib/Transforms/Scalar/Mem2Reg.cpp<br>===================================================================<br>RCS file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/Mem2Reg.cpp,v
<br>retrieving revision 1.15<br>diff -u -p -r1.15 Mem2Reg.cpp<br>--- ./lib/Transforms/Scalar/Mem2Reg.cpp 2 May 2006 04:24:36 -0000 1.15<br>+++ ./lib/Transforms/Scalar/Mem2Reg.cpp 3 May 2006 18:01:53 -0000<br>@@ -14,6 +14,7 @@
<br> <br> #include "llvm/Transforms/Scalar.h"<br> #include "llvm/Transforms/Utils/PromoteMemToReg.h"<br>+#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"<br> #include "llvm/Analysis/Dominators.h"
<br> #include "llvm/Instructions.h"<br> #include "llvm/Function.h"<br>@@ -37,6 +38,10 @@ namespace {<br> AU.addRequired<DominanceFrontier>();<br> AU.addRequired<TargetData>();<br>
AU.setPreservesCFG();<br>+ // This is a cluster of orthogonal Transforms <br>+ AU.addPreserved<UnifyFunctionExitNodes>();<br>+ AU.addPreservedID(LowerSelectID);<br>+ AU.addPreservedID(LowerSwitchID);
<br> }<br> };<br> <br>Index: ./lib/Transforms/Scalar/LowerSelect.cpp<br>===================================================================<br>RCS file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/LowerSelect.cpp,v<br>
retrieving revision 1.4<br>diff -u -p -r1.4 LowerSelect.cpp<br>--- ./lib/Transforms/Scalar/LowerSelect.cpp 2 May 2006 04:24:36 -0000 1.4<br>+++ ./lib/Transforms/Scalar/LowerSelect.cpp 3 May 2006 18:01:53 -0000
<br>@@ -19,6 +19,7 @@<br> //===----------------------------------------------------------------------===//<br> <br> #include "llvm/Transforms/Scalar.h"<br>+#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
<br> #include "llvm/Function.h"<br> #include "llvm/Instructions.h"<br> #include "llvm/Pass.h"<br>@@ -38,6 +39,12 @@ namespace {<br> <br> virtual void getAnalysisUsage(AnalysisUsage &AU) const {
<br> // Doesn't really preserve anything. It can certainly destroy the CFG.<br>+ // But it preserves some Transforms. <br>+ <br>+ // This is a cluster of orthogonal Transforms: <br>+ AU.addPreserved
<UnifyFunctionExitNodes>();<br>+ AU.addPreservedID(PromoteMemoryToRegisterID);<br>+ AU.addPreservedID(LowerSwitchID);<br> }<br> <br> bool runOnFunction(Function &F);<br>Index: ./lib/Transforms/Scalar/LowerAllocations.cpp
<br>===================================================================<br>RCS file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/LowerAllocations.cpp,v<br>retrieving revision 1.56<br>diff -u -p -r1.56 LowerAllocations.cpp<br>
--- ./lib/Transforms/Scalar/LowerAllocations.cpp 2 May 2006 04:24:36 -0000 1.56<br>+++ ./lib/Transforms/Scalar/LowerAllocations.cpp 3 May 2006 18:01:53 -0000<br>@@ -13,6 +13,7 @@<br> //===----------------------------------------------------------------------===//
<br> <br> #include "llvm/Transforms/Scalar.h"<br>+#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"<br> #include "llvm/Module.h"<br> #include "llvm/DerivedTypes.h"<br> #include "llvm/Instructions.h"
<br>@@ -39,6 +40,12 @@ namespace {<br> virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br> AU.addRequired<TargetData>();<br> AU.setPreservesCFG();<br>+<br>+ // This is a cluster of orthogonal Transforms:
<br>+ AU.addPreserved<UnifyFunctionExitNodes>();<br>+ AU.addPreservedID(PromoteMemoryToRegisterID);<br>+ AU.addPreservedID(LowerSelectID);<br>+ AU.addPreservedID(LowerSwitchID);<br> }<br> <br>
/// doPassInitialization - For the lower allocations pass, this ensures that<br>Index: ./lib/Transforms/Utils/UnifyFunctionExitNodes.cpp<br>===================================================================<br>RCS file: /var/cvs/llvm/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp,v
<br>retrieving revision 1.33<br>diff -u -p -r1.33 UnifyFunctionExitNodes.cpp<br>--- ./lib/Transforms/Utils/UnifyFunctionExitNodes.cpp 21 Apr 2005 23:45:34 -0000 1.33<br>+++ ./lib/Transforms/Utils/UnifyFunctionExitNodes.cpp 3 May 2006 18:01:53 -0000
<br>@@ -32,6 +32,10 @@ Pass *llvm::createUnifyFunctionExitNodes<br> void UnifyFunctionExitNodes::getAnalysisUsage(AnalysisUsage &AU) const{<br> // We preserve the non-critical-edgeness property<br> AU.addPreservedID
(BreakCriticalEdgesID);<br>+ // This is a cluster of orthogonal Transforms <br>+ AU.addPreservedID(PromoteMemoryToRegisterID);<br>+ AU.addPreservedID(LowerSelectID);<br>+ AU.addPreservedID(LowerSwitchID);<br> }
<br> <br> // UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new<br><br>***************************** PATCH END **********************************************<br>
<br>