mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-05 02:07:16 +00:00
Do not use ETForest as well as DomiantorTree. DominatorTree is sufficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37501 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
326821ef12
commit
4b90e3a276
@ -142,6 +142,16 @@ protected:
|
||||
return getNode(BB);
|
||||
}
|
||||
|
||||
/// getIDomBlock - return basic block BB's immediate domiantor basic block.
|
||||
///
|
||||
BasicBlock *getIDomBlock(BasicBlock *BB) {
|
||||
DomTreeNode *N = getNode(BB);
|
||||
assert (N && "Missing dominator tree node");
|
||||
DomTreeNode *I = N->getIDom();
|
||||
assert (N && "Missing immediate dominator");
|
||||
return I->getBlock();
|
||||
}
|
||||
|
||||
/// getRootNode - This returns the entry node for the CFG of the function. If
|
||||
/// this tree represents the post-dominance relations for a function, however,
|
||||
/// this root may be a node with the block == NULL. This is the case when
|
||||
|
@ -24,13 +24,13 @@ namespace llvm {
|
||||
|
||||
/// ExtractCodeRegion - rip out a sequence of basic blocks into a new function
|
||||
///
|
||||
Function* ExtractCodeRegion(ETForest &DS, DominatorTree& DT,
|
||||
Function* ExtractCodeRegion(DominatorTree& DT,
|
||||
const std::vector<BasicBlock*> &code,
|
||||
bool AggregateArgs = false);
|
||||
|
||||
/// ExtractLoop - rip out a natural loop into a new function
|
||||
///
|
||||
Function* ExtractLoop(ETForest &DS, DominatorTree& DT, Loop *L,
|
||||
Function* ExtractLoop(DominatorTree& DT, Loop *L,
|
||||
bool AggregateArgs = false);
|
||||
|
||||
/// ExtractBasicBlock - rip out a basic block into a new function
|
||||
|
@ -45,7 +45,6 @@ namespace {
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequiredID(BreakCriticalEdgesID);
|
||||
AU.addRequiredID(LoopSimplifyID);
|
||||
AU.addRequired<ETForest>();
|
||||
AU.addRequired<DominatorTree>();
|
||||
AU.addRequired<LoopInfo>();
|
||||
}
|
||||
@ -78,7 +77,6 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
||||
if (LI.begin() == LI.end())
|
||||
return false;
|
||||
|
||||
ETForest &EF = getAnalysis<ETForest>();
|
||||
DominatorTree &DT = getAnalysis<DominatorTree>();
|
||||
|
||||
// If there is more than one top-level loop in this function, extract all of
|
||||
@ -88,7 +86,7 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
||||
for (LoopInfo::iterator i = LI.begin(), e = LI.end(); i != e; ++i) {
|
||||
if (NumLoops == 0) return Changed;
|
||||
--NumLoops;
|
||||
Changed |= ExtractLoop(EF, DT, *i) != 0;
|
||||
Changed |= ExtractLoop(DT, *i) != 0;
|
||||
++NumExtracted;
|
||||
}
|
||||
} else {
|
||||
@ -118,7 +116,7 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
||||
if (ShouldExtractLoop) {
|
||||
if (NumLoops == 0) return Changed;
|
||||
--NumLoops;
|
||||
Changed |= ExtractLoop(EF, DT, TLL) != 0;
|
||||
Changed |= ExtractLoop(DT, TLL) != 0;
|
||||
++NumExtracted;
|
||||
} else {
|
||||
// Okay, this function is a minimal container around the specified loop.
|
||||
@ -128,7 +126,7 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
||||
for (Loop::iterator i = TLL->begin(), e = TLL->end(); i != e; ++i) {
|
||||
if (NumLoops == 0) return Changed;
|
||||
--NumLoops;
|
||||
Changed |= ExtractLoop(EF, DT, *i) != 0;
|
||||
Changed |= ExtractLoop(DT, *i) != 0;
|
||||
++NumExtracted;
|
||||
}
|
||||
}
|
||||
|
@ -44,14 +44,13 @@ namespace {
|
||||
class VISIBILITY_HIDDEN CodeExtractor {
|
||||
typedef std::vector<Value*> Values;
|
||||
std::set<BasicBlock*> BlocksToExtract;
|
||||
ETForest *EF;
|
||||
DominatorTree* DT;
|
||||
bool AggregateArgs;
|
||||
unsigned NumExitBlocks;
|
||||
const Type *RetTy;
|
||||
public:
|
||||
CodeExtractor(ETForest *ef = 0, DominatorTree* dt = 0, bool AggArgs = false)
|
||||
: EF(ef), DT(dt), AggregateArgs(AggArgs||AggregateArgsOpt), NumExitBlocks(~0U) {}
|
||||
CodeExtractor(DominatorTree* dt = 0, bool AggArgs = false)
|
||||
: DT(dt), AggregateArgs(AggArgs||AggregateArgsOpt), NumExitBlocks(~0U) {}
|
||||
|
||||
Function *ExtractCodeRegion(const std::vector<BasicBlock*> &code);
|
||||
|
||||
@ -141,17 +140,17 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) {
|
||||
|
||||
// Okay, update dominator sets. The blocks that dominate the new one are the
|
||||
// blocks that dominate TIBB plus the new block itself.
|
||||
if (EF) {
|
||||
BasicBlock* idom = EF->getIDom(OldPred);
|
||||
if (DT) {
|
||||
DomTreeNode *OPNode = DT->getNode(OldPred);
|
||||
DomTreeNode *IDomNode = OPNode->getIDom();
|
||||
BasicBlock* idom = IDomNode->getBlock();
|
||||
DT->addNewBlock(NewBB, idom);
|
||||
EF->addNewBlock(NewBB, idom);
|
||||
|
||||
// Additionally, NewBB replaces OldPred as the immediate dominator of blocks
|
||||
Function *F = Header->getParent();
|
||||
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
|
||||
if (EF->getIDom(I) == OldPred) {
|
||||
if (DT->getIDomBlock(I) == OldPred) {
|
||||
DT->changeImmediateDominator(I, NewBB);
|
||||
EF->setImmediateDominator(I, NewBB);
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,12 +508,12 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
|
||||
// In the extract block case, if the block we are extracting ends
|
||||
// with an invoke instruction, make sure that we don't emit a
|
||||
// store of the invoke value for the unwind block.
|
||||
if (!EF && DefBlock != OldTarget)
|
||||
if (!DT && DefBlock != OldTarget)
|
||||
DominatesDef = false;
|
||||
}
|
||||
|
||||
if (EF)
|
||||
DominatesDef = EF->dominates(DefBlock, OldTarget);
|
||||
if (DT)
|
||||
DominatesDef = DT->dominates(DefBlock, OldTarget);
|
||||
|
||||
if (DominatesDef) {
|
||||
if (AggregateArgs) {
|
||||
@ -728,16 +727,16 @@ bool CodeExtractor::isEligible(const std::vector<BasicBlock*> &code) {
|
||||
/// ExtractCodeRegion - slurp a sequence of basic blocks into a brand new
|
||||
/// function
|
||||
///
|
||||
Function* llvm::ExtractCodeRegion(ETForest &EF, DominatorTree &DT,
|
||||
Function* llvm::ExtractCodeRegion(DominatorTree &DT,
|
||||
const std::vector<BasicBlock*> &code,
|
||||
bool AggregateArgs) {
|
||||
return CodeExtractor(&EF, &DT, AggregateArgs).ExtractCodeRegion(code);
|
||||
return CodeExtractor(&DT, AggregateArgs).ExtractCodeRegion(code);
|
||||
}
|
||||
|
||||
/// ExtractBasicBlock - slurp a natural loop into a brand new function
|
||||
///
|
||||
Function* llvm::ExtractLoop(ETForest &EF, DominatorTree &DF, Loop *L, bool AggregateArgs) {
|
||||
return CodeExtractor(&EF, &DF, AggregateArgs).ExtractCodeRegion(L->getBlocks());
|
||||
Function* llvm::ExtractLoop(DominatorTree &DT, Loop *L, bool AggregateArgs) {
|
||||
return CodeExtractor(&DT, AggregateArgs).ExtractCodeRegion(L->getBlocks());
|
||||
}
|
||||
|
||||
/// ExtractBasicBlock - slurp a basic block into a brand new function
|
||||
@ -745,5 +744,5 @@ Function* llvm::ExtractLoop(ETForest &EF, DominatorTree &DF, Loop *L, bool Aggre
|
||||
Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) {
|
||||
std::vector<BasicBlock*> Blocks;
|
||||
Blocks.push_back(BB);
|
||||
return CodeExtractor(0, 0, AggregateArgs).ExtractCodeRegion(Blocks);
|
||||
return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user