mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Optimize tree walking in markAliveBlocks.
Check whether a BB is known as reachable before adding it to the worklist. This way BB's with multiple predecessors are added to the list no more than once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170335 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a839ffc323
commit
1794814198
@ -111,13 +111,11 @@ static bool markAliveBlocks(BasicBlock *BB,
|
||||
|
||||
SmallVector<BasicBlock*, 128> Worklist;
|
||||
Worklist.push_back(BB);
|
||||
Reachable.insert(BB);
|
||||
bool Changed = false;
|
||||
do {
|
||||
BB = Worklist.pop_back_val();
|
||||
|
||||
if (!Reachable.insert(BB))
|
||||
continue;
|
||||
|
||||
// Do a quick scan of the basic block, turning any obviously unreachable
|
||||
// instructions into LLVM unreachable insts. The instruction combining pass
|
||||
// canonicalizes unreachable insts into stores to null or undef.
|
||||
@ -176,7 +174,8 @@ static bool markAliveBlocks(BasicBlock *BB,
|
||||
|
||||
Changed |= ConstantFoldTerminator(BB, true);
|
||||
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI)
|
||||
Worklist.push_back(*SI);
|
||||
if (Reachable.insert(*SI))
|
||||
Worklist.push_back(*SI);
|
||||
} while (!Worklist.empty());
|
||||
return Changed;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user