#define TRANSFORMS_UTILS_PROMOTEMEMTOREG_H
class AllocaInst;
+class DominatorTree;
class DominanceFrontier;
class TargetData;
#include <vector>
/// of the function at all. All allocas must be from the same function.
///
void PromoteMemToReg(const std::vector<AllocaInst*> &Allocas,
- DominanceFrontier &DF, const TargetData &TD);
+ DominatorTree &DT, DominanceFrontier &DF,
+ const TargetData &TD);
#endif
private:
LoopInfo *LI; // Current LoopInfo
AliasAnalysis *AA; // Current AliasAnalysis information
+ DominanceFrontier *DF; // Current Dominance Frontier
bool Changed; // Set to true when we change anything.
BasicBlock *Preheader; // The preheader block of the current loop...
Loop *CurLoop; // The current loop we are working on...
// Get our Loop and Alias Analysis information...
LI = &getAnalysis<LoopInfo>();
AA = &getAnalysis<AliasAnalysis>();
+ DF = &getAnalysis<DominanceFrontier>();
DT = &getAnalysis<DominatorTree>();
// Hoist expressions out of all of the top-level loops.
PromotedAllocas.reserve(PromotedValues.size());
for (unsigned i = 0, e = PromotedValues.size(); i != e; ++i)
PromotedAllocas.push_back(PromotedValues[i].first);
- PromoteMemToReg(PromotedAllocas, getAnalysis<DominanceFrontier>(),
- AA->getTargetData());
+ PromoteMemToReg(PromotedAllocas, *DT, *DF, AA->getTargetData());
}
/// findPromotableValuesInLoop - Check the current loop for stores to definite
// 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.addRequired<TargetData>();
AU.setPreservesCFG();
bool SROA::performPromotion(Function &F) {
std::vector<AllocaInst*> Allocas;
const TargetData &TD = getAnalysis<TargetData>();
+ DominatorTree &DT = getAnalysis<DominatorTree>();
+ DominanceFrontier &DF = getAnalysis<DominanceFrontier>();
BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
if (Allocas.empty()) break;
- PromoteMemToReg(Allocas, getAnalysis<DominanceFrontier>(), TD);
+ PromoteMemToReg(Allocas, DT, DF, TD);
NumPromoted += Allocas.size();
Changed = true;
}
// getAnalysisUsage - We need dominance frontiers
//
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired<DominatorTree>();
AU.addRequired<DominanceFrontier>();
AU.addRequired<TargetData>();
AU.setPreservesCFG();
BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
bool Changed = false;
+
+ DominatorTree &DT = getAnalysis<DominatorTree>();
+ DominanceFrontier &DF = getAnalysis<DominanceFrontier>();
while (1) {
Allocas.clear();
if (Allocas.empty()) break;
- PromoteMemToReg(Allocas, getAnalysis<DominanceFrontier>(), TD);
+ PromoteMemToReg(Allocas, DT, DF, TD);
NumPromoted += Allocas.size();
Changed = true;
}
/// of the function at all. All allocas must be from the same function.
///
void PromoteMemToReg(const std::vector<AllocaInst*> &Allocas,
- DominanceFrontier &DF, const TargetData &TD) {
+ DominatorTree &DT, DominanceFrontier &DF,
+ const TargetData &TD) {
// If there is nothing to do, bail out...
if (Allocas.empty()) return;
PromoteMem2Reg(Allocas, DF, TD).run();