inside a cleanup block, convert "unreachable" to a branch to "cleanupret"

This commit is contained in:
Rainer Schuetze 2015-12-30 14:33:40 +01:00 committed by Martin
parent 5dabf78c7b
commit 73ab5f4fee
2 changed files with 11 additions and 18 deletions

View file

@ -251,6 +251,7 @@ void ScopeStack::runCleanupCopies(CleanupCursor sourceScope,
llvm::BasicBlock *ScopeStack::runCleanupPad(CleanupCursor scope,
llvm::BasicBlock *unwindTo) {
// a catch switch never needs to be cloned and is an unwind target itself
if (isCatchSwitchBlock(cleanupScopes[scope].beginBlock))
return cleanupScopes[scope].beginBlock;
@ -287,10 +288,10 @@ llvm::BasicBlock *ScopeStack::runCleanupPad(CleanupCursor scope,
llvm::BasicBlock *cleanupret =
llvm::BasicBlock::Create(irs->context(), "cleanupret", irs->topfunc());
llvm::CleanupReturnInst::Create(cleanuppad, unwindTo, cleanupret);
auto copybb = executeCleanupCopying(irs, cleanupScopes[scope], cleanupbb,
cleanupret, unwindTo, cleanuppad);
cleanupret, unwindTo, cleanuppad);
llvm::BranchInst::Create(copybb, cleanupbb);
return cleanupbb;
}