mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 03:46:02 +03:00
Coalesce last catch mismatch block with unwind resume block if possible
Makes IR a bit more compact.
This commit is contained in:
parent
4bcae9731a
commit
db8f0fd8e2
1 changed files with 6 additions and 1 deletions
|
@ -341,7 +341,7 @@ llvm::BasicBlock* ScopeStack::emitLandingPad() {
|
|||
}
|
||||
irs->ir->CreateStore(ehSelector, irs->func()->ehSelectorSlot);
|
||||
|
||||
// Add landingpad clauses, emit finallys and 'if' chain to catch the exception,
|
||||
// Add landingpad clauses, emit finallys and 'if' chain to catch the exception.
|
||||
CleanupCursor lastCleanup = currentCleanupScope();
|
||||
for (std::vector<CatchScope>::reverse_iterator it = catchScopes.rbegin(),
|
||||
end = catchScopes.rend();
|
||||
|
@ -389,6 +389,11 @@ llvm::BasicBlock* ScopeStack::emitLandingPad() {
|
|||
if (lastCleanup > 0) {
|
||||
landingPad->setCleanup(true);
|
||||
runCleanups(lastCleanup, 0, irs->func()->resumeUnwindBlock);
|
||||
} else if (!catchScopes.empty()) {
|
||||
// Directly convert the last mismatch branch into a branch to the
|
||||
// unwind resume block.
|
||||
irs->scopebb()->replaceAllUsesWith(irs->func()->resumeUnwindBlock);
|
||||
irs->scopebb()->eraseFromParent();
|
||||
} else {
|
||||
irs->ir->CreateBr(irs->func()->resumeUnwindBlock);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue