mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +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);
|
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
|
/// 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 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
|
/// 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
|
/// 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,
|
const std::vector<BasicBlock*> &code,
|
||||||
bool AggregateArgs = false);
|
bool AggregateArgs = false);
|
||||||
|
|
||||||
/// ExtractLoop - rip out a natural loop into a new function
|
/// 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);
|
bool AggregateArgs = false);
|
||||||
|
|
||||||
/// ExtractBasicBlock - rip out a basic block into a new function
|
/// ExtractBasicBlock - rip out a basic block into a new function
|
||||||
|
@ -45,7 +45,6 @@ namespace {
|
|||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.addRequiredID(BreakCriticalEdgesID);
|
AU.addRequiredID(BreakCriticalEdgesID);
|
||||||
AU.addRequiredID(LoopSimplifyID);
|
AU.addRequiredID(LoopSimplifyID);
|
||||||
AU.addRequired<ETForest>();
|
|
||||||
AU.addRequired<DominatorTree>();
|
AU.addRequired<DominatorTree>();
|
||||||
AU.addRequired<LoopInfo>();
|
AU.addRequired<LoopInfo>();
|
||||||
}
|
}
|
||||||
@ -78,7 +77,6 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
|||||||
if (LI.begin() == LI.end())
|
if (LI.begin() == LI.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ETForest &EF = getAnalysis<ETForest>();
|
|
||||||
DominatorTree &DT = getAnalysis<DominatorTree>();
|
DominatorTree &DT = getAnalysis<DominatorTree>();
|
||||||
|
|
||||||
// If there is more than one top-level loop in this function, extract all of
|
// 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) {
|
for (LoopInfo::iterator i = LI.begin(), e = LI.end(); i != e; ++i) {
|
||||||
if (NumLoops == 0) return Changed;
|
if (NumLoops == 0) return Changed;
|
||||||
--NumLoops;
|
--NumLoops;
|
||||||
Changed |= ExtractLoop(EF, DT, *i) != 0;
|
Changed |= ExtractLoop(DT, *i) != 0;
|
||||||
++NumExtracted;
|
++NumExtracted;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -118,7 +116,7 @@ bool LoopExtractor::runOnFunction(Function &F) {
|
|||||||
if (ShouldExtractLoop) {
|
if (ShouldExtractLoop) {
|
||||||
if (NumLoops == 0) return Changed;
|
if (NumLoops == 0) return Changed;
|
||||||
--NumLoops;
|
--NumLoops;
|
||||||
Changed |= ExtractLoop(EF, DT, TLL) != 0;
|
Changed |= ExtractLoop(DT, TLL) != 0;
|
||||||
++NumExtracted;
|
++NumExtracted;
|
||||||
} else {
|
} else {
|
||||||
// Okay, this function is a minimal container around the specified loop.
|
// 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) {
|
for (Loop::iterator i = TLL->begin(), e = TLL->end(); i != e; ++i) {
|
||||||
if (NumLoops == 0) return Changed;
|
if (NumLoops == 0) return Changed;
|
||||||
--NumLoops;
|
--NumLoops;
|
||||||
Changed |= ExtractLoop(EF, DT, *i) != 0;
|
Changed |= ExtractLoop(DT, *i) != 0;
|
||||||
++NumExtracted;
|
++NumExtracted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,13 @@ namespace {
|
|||||||
class VISIBILITY_HIDDEN CodeExtractor {
|
class VISIBILITY_HIDDEN CodeExtractor {
|
||||||
typedef std::vector<Value*> Values;
|
typedef std::vector<Value*> Values;
|
||||||
std::set<BasicBlock*> BlocksToExtract;
|
std::set<BasicBlock*> BlocksToExtract;
|
||||||
ETForest *EF;
|
|
||||||
DominatorTree* DT;
|
DominatorTree* DT;
|
||||||
bool AggregateArgs;
|
bool AggregateArgs;
|
||||||
unsigned NumExitBlocks;
|
unsigned NumExitBlocks;
|
||||||
const Type *RetTy;
|
const Type *RetTy;
|
||||||
public:
|
public:
|
||||||
CodeExtractor(ETForest *ef = 0, DominatorTree* dt = 0, bool AggArgs = false)
|
CodeExtractor(DominatorTree* dt = 0, bool AggArgs = false)
|
||||||
: EF(ef), DT(dt), AggregateArgs(AggArgs||AggregateArgsOpt), NumExitBlocks(~0U) {}
|
: DT(dt), AggregateArgs(AggArgs||AggregateArgsOpt), NumExitBlocks(~0U) {}
|
||||||
|
|
||||||
Function *ExtractCodeRegion(const std::vector<BasicBlock*> &code);
|
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
|
// Okay, update dominator sets. The blocks that dominate the new one are the
|
||||||
// blocks that dominate TIBB plus the new block itself.
|
// blocks that dominate TIBB plus the new block itself.
|
||||||
if (EF) {
|
if (DT) {
|
||||||
BasicBlock* idom = EF->getIDom(OldPred);
|
DomTreeNode *OPNode = DT->getNode(OldPred);
|
||||||
|
DomTreeNode *IDomNode = OPNode->getIDom();
|
||||||
|
BasicBlock* idom = IDomNode->getBlock();
|
||||||
DT->addNewBlock(NewBB, idom);
|
DT->addNewBlock(NewBB, idom);
|
||||||
EF->addNewBlock(NewBB, idom);
|
|
||||||
|
|
||||||
// Additionally, NewBB replaces OldPred as the immediate dominator of blocks
|
// Additionally, NewBB replaces OldPred as the immediate dominator of blocks
|
||||||
Function *F = Header->getParent();
|
Function *F = Header->getParent();
|
||||||
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
|
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);
|
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
|
// In the extract block case, if the block we are extracting ends
|
||||||
// with an invoke instruction, make sure that we don't emit a
|
// with an invoke instruction, make sure that we don't emit a
|
||||||
// store of the invoke value for the unwind block.
|
// store of the invoke value for the unwind block.
|
||||||
if (!EF && DefBlock != OldTarget)
|
if (!DT && DefBlock != OldTarget)
|
||||||
DominatesDef = false;
|
DominatesDef = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EF)
|
if (DT)
|
||||||
DominatesDef = EF->dominates(DefBlock, OldTarget);
|
DominatesDef = DT->dominates(DefBlock, OldTarget);
|
||||||
|
|
||||||
if (DominatesDef) {
|
if (DominatesDef) {
|
||||||
if (AggregateArgs) {
|
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
|
/// ExtractCodeRegion - slurp a sequence of basic blocks into a brand new
|
||||||
/// function
|
/// function
|
||||||
///
|
///
|
||||||
Function* llvm::ExtractCodeRegion(ETForest &EF, DominatorTree &DT,
|
Function* llvm::ExtractCodeRegion(DominatorTree &DT,
|
||||||
const std::vector<BasicBlock*> &code,
|
const std::vector<BasicBlock*> &code,
|
||||||
bool AggregateArgs) {
|
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
|
/// ExtractBasicBlock - slurp a natural loop into a brand new function
|
||||||
///
|
///
|
||||||
Function* llvm::ExtractLoop(ETForest &EF, DominatorTree &DF, Loop *L, bool AggregateArgs) {
|
Function* llvm::ExtractLoop(DominatorTree &DT, Loop *L, bool AggregateArgs) {
|
||||||
return CodeExtractor(&EF, &DF, AggregateArgs).ExtractCodeRegion(L->getBlocks());
|
return CodeExtractor(&DT, AggregateArgs).ExtractCodeRegion(L->getBlocks());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ExtractBasicBlock - slurp a basic block into a brand new function
|
/// 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) {
|
Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) {
|
||||||
std::vector<BasicBlock*> Blocks;
|
std::vector<BasicBlock*> Blocks;
|
||||||
Blocks.push_back(BB);
|
Blocks.push_back(BB);
|
||||||
return CodeExtractor(0, 0, AggregateArgs).ExtractCodeRegion(Blocks);
|
return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user