[llvm-commits] [llvm] r123436 - in /llvm/trunk: include/llvm/InitializePasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/Scalar.cpp lib/Transforms/Scalar/ScalarReplAggregates.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 14 00:13:00 PST 2011
Author: lattner
Date: Fri Jan 14 02:13:00 2011
New Revision: 123436
URL: http://llvm.org/viewvc/llvm-project?rev=123436&view=rev
Log:
split SROA into two passes: one that uses DomFrontiers (-scalarrepl)
and one that uses SSAUpdater (-scalarrepl-ssa)
Modified:
llvm/trunk/include/llvm/InitializePasses.h
llvm/trunk/include/llvm/Transforms/Scalar.h
llvm/trunk/lib/Transforms/Scalar/Scalar.cpp
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Modified: llvm/trunk/include/llvm/InitializePasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=123436&r1=123435&r2=123436&view=diff
==============================================================================
--- llvm/trunk/include/llvm/InitializePasses.h (original)
+++ llvm/trunk/include/llvm/InitializePasses.h Fri Jan 14 02:13:00 2011
@@ -193,7 +193,8 @@
void initializeRenderMachineFunctionPass(PassRegistry&);
void initializeSCCPPass(PassRegistry&);
void initializeSRETPromotionPass(PassRegistry&);
-void initializeSROAPass(PassRegistry&);
+void initializeSROA_DFPass(PassRegistry&);
+void initializeSROA_SSAUpPass(PassRegistry&);
void initializeScalarEvolutionAliasAnalysisPass(PassRegistry&);
void initializeScalarEvolutionPass(PassRegistry&);
void initializeSimpleInlinerPass(PassRegistry&);
Modified: llvm/trunk/include/llvm/Transforms/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=123436&r1=123435&r2=123436&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar.h Fri Jan 14 02:13:00 2011
@@ -73,7 +73,8 @@
// ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
// if possible.
//
-FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
+FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
+ bool UseDomFrontier = true);
//===----------------------------------------------------------------------===//
//
Modified: llvm/trunk/lib/Transforms/Scalar/Scalar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Scalar.cpp?rev=123436&r1=123435&r2=123436&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Scalar.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Scalar.cpp Fri Jan 14 02:13:00 2011
@@ -53,7 +53,8 @@
initializeRegToMemPass(Registry);
initializeSCCPPass(Registry);
initializeIPSCCPPass(Registry);
- initializeSROAPass(Registry);
+ initializeSROA_DFPass(Registry);
+ initializeSROA_SSAUpPass(Registry);
initializeCFGSimplifyPassPass(Registry);
initializeSimplifyHalfPowrLibCallsPass(Registry);
initializeSimplifyLibCallsPass(Registry);
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=123436&r1=123435&r2=123436&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Jan 14 02:13:00 2011
@@ -52,15 +52,10 @@
STATISTIC(NumConverted, "Number of aggregates converted to scalar");
STATISTIC(NumGlobals, "Number of allocas copied from constant global");
-enum {
- UsePromoteMemToReg = 1
-};
-
namespace {
struct SROA : public FunctionPass {
- static char ID; // Pass identification, replacement for typeid
- explicit SROA(signed T = -1) : FunctionPass(ID) {
- initializeSROAPass(*PassRegistry::getPassRegistry());
+ SROA(int T, bool hasDF, char &ID)
+ : FunctionPass(ID), HasDomFrontiers(hasDF) {
if (T == -1)
SRThreshold = 128;
else
@@ -72,17 +67,8 @@
bool performScalarRepl(Function &F);
bool performPromotion(Function &F);
- // getAnalysisUsage - This pass does not require any passes, but we know it
- // will not alter the CFG, so say so.
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- if (UsePromoteMemToReg) {
- AU.addRequired<DominatorTree>();
- AU.addRequired<DominanceFrontier>();
- }
- AU.setPreservesCFG();
- }
-
private:
+ bool HasDomFrontiers;
TargetData *TD;
/// DeadInsts - Keep track of instructions we have made dead, so that
@@ -142,19 +128,62 @@
static MemTransferInst *isOnlyCopiedFromConstantGlobal(AllocaInst *AI);
};
+
+ // SROA_DF - SROA that uses DominanceFrontier.
+ struct SROA_DF : public SROA {
+ static char ID;
+ public:
+ SROA_DF(int T = -1) : SROA(T, true, ID) {
+ initializeSROA_DFPass(*PassRegistry::getPassRegistry());
+ }
+
+ // getAnalysisUsage - This pass does not require any passes, but we know it
+ // will not alter the CFG, so say so.
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired<DominatorTree>();
+ AU.addRequired<DominanceFrontier>();
+ AU.setPreservesCFG();
+ }
+ };
+
+ // SROA_SSAUp - SROA that uses SSAUpdater.
+ struct SROA_SSAUp : public SROA {
+ static char ID;
+ public:
+ SROA_SSAUp(int T = -1) : SROA(T, false, ID) {
+ initializeSROA_SSAUpPass(*PassRegistry::getPassRegistry());
+ }
+
+ // getAnalysisUsage - This pass does not require any passes, but we know it
+ // will not alter the CFG, so say so.
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesCFG();
+ }
+ };
+
}
-char SROA::ID = 0;
-INITIALIZE_PASS_BEGIN(SROA, "scalarrepl",
- "Scalar Replacement of Aggregates", false, false)
+char SROA_DF::ID = 0;
+char SROA_SSAUp::ID = 0;
+
+INITIALIZE_PASS_BEGIN(SROA_DF, "scalarrepl",
+ "Scalar Replacement of Aggregates (DF)", false, false)
INITIALIZE_PASS_DEPENDENCY(DominatorTree)
INITIALIZE_PASS_DEPENDENCY(DominanceFrontier)
-INITIALIZE_PASS_END(SROA, "scalarrepl",
- "Scalar Replacement of Aggregates", false, false)
+INITIALIZE_PASS_END(SROA_DF, "scalarrepl",
+ "Scalar Replacement of Aggregates (DF)", false, false)
+
+INITIALIZE_PASS_BEGIN(SROA_SSAUp, "scalarrepl-ssa",
+ "Scalar Replacement of Aggregates (SSAUp)", false, false)
+INITIALIZE_PASS_END(SROA_SSAUp, "scalarrepl-ssa",
+ "Scalar Replacement of Aggregates (SSAUp)", false, false)
// Public interface to the ScalarReplAggregates pass
-FunctionPass *llvm::createScalarReplAggregatesPass(signed int Threshold) {
- return new SROA(Threshold);
+FunctionPass *llvm::createScalarReplAggregatesPass(int Threshold,
+ bool UseDomFrontier) {
+ if (UseDomFrontier)
+ return new SROA_DF(Threshold);
+ return new SROA_SSAUp(Threshold);
}
@@ -954,7 +983,7 @@
std::vector<AllocaInst*> Allocas;
DominatorTree *DT = 0;
DominanceFrontier *DF = 0;
- if (UsePromoteMemToReg) {
+ if (HasDomFrontiers) {
DT = &getAnalysis<DominatorTree>();
DF = &getAnalysis<DominanceFrontier>();
}
@@ -975,7 +1004,7 @@
if (Allocas.empty()) break;
- if (UsePromoteMemToReg)
+ if (HasDomFrontiers)
PromoteMemToReg(Allocas, *DT, *DF);
else {
SSAUpdater SSA;
More information about the llvm-commits
mailing list