forked from OSchip/llvm-project
Switch some std::sets to SmallPtrSet. This speeds up
domtree by 10% and postdomtree by 17% llvm-svn: 40829
This commit is contained in:
parent
5f5585c432
commit
0e8f85f87e
|
@ -29,7 +29,7 @@ F("postdomtree", "Post-Dominator Tree Construction", true);
|
||||||
|
|
||||||
unsigned PostDominatorTree::DFSPass(BasicBlock *V, unsigned N) {
|
unsigned PostDominatorTree::DFSPass(BasicBlock *V, unsigned N) {
|
||||||
std::vector<BasicBlock *> workStack;
|
std::vector<BasicBlock *> workStack;
|
||||||
std::set<BasicBlock *> visited;
|
SmallPtrSet<BasicBlock *, 32> Visited;
|
||||||
workStack.push_back(V);
|
workStack.push_back(V);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -37,7 +37,7 @@ unsigned PostDominatorTree::DFSPass(BasicBlock *V, unsigned N) {
|
||||||
InfoRec &CurVInfo = Info[currentBB];
|
InfoRec &CurVInfo = Info[currentBB];
|
||||||
|
|
||||||
// Visit each block only once.
|
// Visit each block only once.
|
||||||
if (visited.insert(currentBB).second) {
|
if (Visited.insert(currentBB)) {
|
||||||
CurVInfo.Semi = ++N;
|
CurVInfo.Semi = ++N;
|
||||||
CurVInfo.Label = currentBB;
|
CurVInfo.Label = currentBB;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ unsigned PostDominatorTree::DFSPass(BasicBlock *V, unsigned N) {
|
||||||
InfoRec &SuccVInfo = Info[*PI];
|
InfoRec &SuccVInfo = Info[*PI];
|
||||||
if (SuccVInfo.Semi == 0) {
|
if (SuccVInfo.Semi == 0) {
|
||||||
SuccVInfo.Parent = currentBB;
|
SuccVInfo.Parent = currentBB;
|
||||||
if (!visited.count(*PI)) {
|
if (!Visited.count(*PI)) {
|
||||||
workStack.push_back(*PI);
|
workStack.push_back(*PI);
|
||||||
visitChild = true;
|
visitChild = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ unsigned DominatorTree::DFSPass(BasicBlock *V, unsigned N) {
|
||||||
void DominatorTree::Compress(BasicBlock *VIn) {
|
void DominatorTree::Compress(BasicBlock *VIn) {
|
||||||
|
|
||||||
std::vector<BasicBlock *> Work;
|
std::vector<BasicBlock *> Work;
|
||||||
std::set<BasicBlock *> Visited;
|
SmallPtrSet<BasicBlock *, 32> Visited;
|
||||||
BasicBlock *VInAncestor = Info[VIn].Ancestor;
|
BasicBlock *VInAncestor = Info[VIn].Ancestor;
|
||||||
InfoRec &VInVAInfo = Info[VInAncestor];
|
InfoRec &VInVAInfo = Info[VInAncestor];
|
||||||
|
|
||||||
|
@ -225,9 +225,9 @@ void DominatorTree::Compress(BasicBlock *VIn) {
|
||||||
InfoRec &VAInfo = Info[VAncestor];
|
InfoRec &VAInfo = Info[VAncestor];
|
||||||
|
|
||||||
// Process Ancestor first
|
// Process Ancestor first
|
||||||
if (Visited.count(VAncestor) == 0 && VAInfo.Ancestor != 0) {
|
if (Visited.insert(VAncestor) &&
|
||||||
|
VAInfo.Ancestor != 0) {
|
||||||
Work.push_back(VAncestor);
|
Work.push_back(VAncestor);
|
||||||
Visited.insert(VAncestor);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Work.pop_back();
|
Work.pop_back();
|
||||||
|
|
Loading…
Reference in New Issue