mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-07 14:33:15 +00:00
Cleanup some from my DomSet-removal changes. Add a new
isReachableFromEntry test to ETForest to factor a common test out of code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d2eae62e93
commit
558fc740da
@ -27,6 +27,7 @@
|
|||||||
#define LLVM_ANALYSIS_DOMINATORS_H
|
#define LLVM_ANALYSIS_DOMINATORS_H
|
||||||
|
|
||||||
#include "llvm/Analysis/ET-Forest.h"
|
#include "llvm/Analysis/ET-Forest.h"
|
||||||
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@ -395,7 +396,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dominates - Return true if A dominates B. THis performs the
|
// dominates - Return true if A dominates B. This performs the
|
||||||
// special checks necessary if A and B are in the same basic block.
|
// special checks necessary if A and B are in the same basic block.
|
||||||
bool dominates(Instruction *A, Instruction *B);
|
bool dominates(Instruction *A, Instruction *B);
|
||||||
|
|
||||||
@ -405,6 +406,12 @@ public:
|
|||||||
return dominates(A, B) && A != B;
|
return dominates(A, B) && A != B;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// isReachableFromEntry - Return true if A is dominated by the entry
|
||||||
|
/// block of the function containing it.
|
||||||
|
bool isReachableFromEntry(BasicBlock* A) {
|
||||||
|
return dominates(&A->getParent()->getEntryBlock(), A);
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the nearest common dominator of A and B.
|
/// Return the nearest common dominator of A and B.
|
||||||
BasicBlock *nearestCommonDominator(BasicBlock *A, BasicBlock *B) const {
|
BasicBlock *nearestCommonDominator(BasicBlock *A, BasicBlock *B) const {
|
||||||
ETNode *NodeA = getNode(A);
|
ETNode *NodeA = getNode(A);
|
||||||
|
@ -312,6 +312,8 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
|
|||||||
// Can we eliminate this phi node now?
|
// Can we eliminate this phi node now?
|
||||||
if (Value *V = PN->hasConstantValue(true)) {
|
if (Value *V = PN->hasConstantValue(true)) {
|
||||||
Instruction *I = dyn_cast<Instruction>(V);
|
Instruction *I = dyn_cast<Instruction>(V);
|
||||||
|
// If I is in NewBB, the ETForest call will fail, because NewBB isn't
|
||||||
|
// registered in ETForest yet. Handle this case explicitly.
|
||||||
if (!I || (I->getParent() != NewBB &&
|
if (!I || (I->getParent() != NewBB &&
|
||||||
getAnalysis<ETForest>().dominates(I, PN))) {
|
getAnalysis<ETForest>().dominates(I, PN))) {
|
||||||
PN->replaceAllUsesWith(V);
|
PN->replaceAllUsesWith(V);
|
||||||
@ -701,15 +703,13 @@ void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB,
|
|||||||
{
|
{
|
||||||
BasicBlock *OnePred = PredBlocks[0];
|
BasicBlock *OnePred = PredBlocks[0];
|
||||||
unsigned i = 1, e = PredBlocks.size();
|
unsigned i = 1, e = PredBlocks.size();
|
||||||
for (i = 1; !ETF.dominates(&OnePred->getParent()->getEntryBlock(), OnePred);
|
for (i = 1; !ETF.isReachableFromEntry(OnePred); ++i) {
|
||||||
++i) {
|
|
||||||
assert(i != e && "Didn't find reachable pred?");
|
assert(i != e && "Didn't find reachable pred?");
|
||||||
OnePred = PredBlocks[i];
|
OnePred = PredBlocks[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i != e; ++i)
|
for (; i != e; ++i)
|
||||||
if (PredBlocks[i] != OnePred &&
|
if (PredBlocks[i] != OnePred && ETF.isReachableFromEntry(OnePred)){
|
||||||
ETF.dominates(&PredBlocks[i]->getParent()->getEntryBlock(), OnePred)){
|
|
||||||
NewBBDominatesNewBBSucc = false;
|
NewBBDominatesNewBBSucc = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user