mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 04:06:44 +00:00
Remove unreachable basic blocks before "linking"
This commit is contained in:
parent
8ba533fd32
commit
a4416e563d
1 changed files with 20 additions and 1 deletions
|
|
@ -911,7 +911,26 @@ void Compiler::linkBasicBlocks()
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
// Remove dead basic blocks
|
||||
auto sthErased = false;
|
||||
do
|
||||
{
|
||||
sthErased = false;
|
||||
for (auto it = basicBlocks.begin(); it != basicBlocks.end();)
|
||||
{
|
||||
auto llvmBB = it->second.llvm();
|
||||
if (llvm::pred_begin(llvmBB) == llvm::pred_end(llvmBB))
|
||||
{
|
||||
llvmBB->eraseFromParent();
|
||||
basicBlocks.erase(it++);
|
||||
sthErased = true;
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
while (sthErased);
|
||||
|
||||
// TODO: It is crappy visiting of basic blocks.
|
||||
llvm::SmallPtrSet<llvm::BasicBlock*, 32> visitSet;
|
||||
for (auto&& bb : basicBlocks) // TODO: External loop is to visit unreable blocks that can also have phi nodes
|
||||
|
|
|
|||
Loading…
Reference in a new issue