forked from OSchip/llvm-project
NFC: Refactor GVNHoist class so not everything is public
llvm-svn: 276657
This commit is contained in:
parent
b89eb65b0e
commit
65af45de03
|
@ -187,6 +187,42 @@ static void combineKnownMetadata(Instruction *ReplInst, Instruction *I) {
|
|||
// cases reduce critical path (by exposing more ILP).
|
||||
class GVNHoist {
|
||||
public:
|
||||
GVNHoist(DominatorTree *Dt, AliasAnalysis *Aa, MemoryDependenceResults *Md,
|
||||
bool OptForMinSize)
|
||||
: DT(Dt), AA(Aa), MD(Md), OptForMinSize(OptForMinSize), HoistedCtr(0) {}
|
||||
bool run(Function &F) {
|
||||
VN.setDomTree(DT);
|
||||
VN.setAliasAnalysis(AA);
|
||||
VN.setMemDep(MD);
|
||||
bool Res = false;
|
||||
|
||||
unsigned I = 0;
|
||||
for (const BasicBlock *BB : depth_first(&F.getEntryBlock()))
|
||||
DFSNumber.insert({BB, ++I});
|
||||
|
||||
// FIXME: use lazy evaluation of VN to avoid the fix-point computation.
|
||||
while (1) {
|
||||
// FIXME: only compute MemorySSA once. We need to update the analysis in
|
||||
// the same time as transforming the code.
|
||||
MemorySSA M(F, AA, DT);
|
||||
MSSA = &M;
|
||||
|
||||
auto HoistStat = hoistExpressions(F);
|
||||
if (HoistStat.first + HoistStat.second == 0) {
|
||||
return Res;
|
||||
}
|
||||
if (HoistStat.second > 0) {
|
||||
// To address a limitation of the current GVN, we need to rerun the
|
||||
// hoisting after we hoisted loads in order to be able to hoist all
|
||||
// scalars dependent on the hoisted loads. Same for stores.
|
||||
VN.clear();
|
||||
}
|
||||
Res = true;
|
||||
}
|
||||
|
||||
return Res;
|
||||
}
|
||||
private:
|
||||
GVN::ValueTable VN;
|
||||
DominatorTree *DT;
|
||||
AliasAnalysis *AA;
|
||||
|
@ -199,10 +235,6 @@ public:
|
|||
|
||||
enum InsKind { Unknown, Scalar, Load, Store };
|
||||
|
||||
GVNHoist(DominatorTree *Dt, AliasAnalysis *Aa, MemoryDependenceResults *Md,
|
||||
bool OptForMinSize)
|
||||
: DT(Dt), AA(Aa), MD(Md), OptForMinSize(OptForMinSize), HoistedCtr(0) {}
|
||||
|
||||
// Return true when there are exception handling in BB.
|
||||
bool hasEH(const BasicBlock *BB) {
|
||||
auto It = BBSideEffects.find(BB);
|
||||
|
@ -770,39 +802,6 @@ public:
|
|||
computeInsertionPoints(CI.getStoreVNTable(), HPL, InsKind::Store);
|
||||
return hoist(HPL);
|
||||
}
|
||||
|
||||
bool run(Function &F) {
|
||||
VN.setDomTree(DT);
|
||||
VN.setAliasAnalysis(AA);
|
||||
VN.setMemDep(MD);
|
||||
bool Res = false;
|
||||
|
||||
unsigned I = 0;
|
||||
for (const BasicBlock *BB : depth_first(&F.getEntryBlock()))
|
||||
DFSNumber.insert({BB, ++I});
|
||||
|
||||
// FIXME: use lazy evaluation of VN to avoid the fix-point computation.
|
||||
while (1) {
|
||||
// FIXME: only compute MemorySSA once. We need to update the analysis in
|
||||
// the same time as transforming the code.
|
||||
MemorySSA M(F, AA, DT);
|
||||
MSSA = &M;
|
||||
|
||||
auto HoistStat = hoistExpressions(F);
|
||||
if (HoistStat.first + HoistStat.second == 0) {
|
||||
return Res;
|
||||
}
|
||||
if (HoistStat.second > 0) {
|
||||
// To address a limitation of the current GVN, we need to rerun the
|
||||
// hoisting after we hoisted loads in order to be able to hoist all
|
||||
// scalars dependent on the hoisted loads. Same for stores.
|
||||
VN.clear();
|
||||
}
|
||||
Res = true;
|
||||
}
|
||||
|
||||
return Res;
|
||||
}
|
||||
};
|
||||
|
||||
class GVNHoistLegacyPass : public FunctionPass {
|
||||
|
|
Loading…
Reference in New Issue