aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-02-26 22:34:33 +0000
committerNico Weber <nicolasweber@gmx.de>2015-02-26 22:34:33 +0000
commitff62a6a0b79da24fe6336fe1dfbe1bc11d0a563a (patch)
tree89207f1f0497d60acc34f2ad6825ec63583d6c54 /clang/lib/CodeGen/CGException.cpp
parent653773d0048de921fbd5cf6a4aa2767a7cd9158a (diff)
downloadllvm-ff62a6a0b79da24fe6336fe1dfbe1bc11d0a563a.zip
llvm-ff62a6a0b79da24fe6336fe1dfbe1bc11d0a563a.tar.gz
llvm-ff62a6a0b79da24fe6336fe1dfbe1bc11d0a563a.tar.bz2
Don't crash on leaving nested __finally blocks through an EH edge.
The __finally emission block tries to be clever by removing unused continuation edges if there's an unconditional jump out of the __finally block. With exception edges, the EH continuation edge isn't always unused though and we'd crash in a few places. Just don't be clever. That makes the IR for __finally blocks a bit longer in some cases (hence small and behavior-preserving changes to existing tests), but it makes no difference in general and it fixes the last crash from PR22553. http://reviews.llvm.org/D7918 llvm-svn: 230697
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index f1ffa58..4e9eb32 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1684,8 +1684,7 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool isCleanup) {
const char *RethrowName = Personality.CatchallRethrowFn;
if (RethrowName != nullptr && !isCleanup) {
EmitRuntimeCall(getCatchallRethrowFn(CGM, RethrowName),
- getExceptionFromSlot())
- ->setDoesNotReturn();
+ getExceptionFromSlot())->setDoesNotReturn();
Builder.CreateUnreachable();
Builder.restoreIP(SavedIP);
return EHResumeBlock;
@@ -1943,23 +1942,17 @@ void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S, SEHFinallyInfo &FI) {
Builder.SetInsertPoint(FI.FinallyBB);
EmitStmt(Finally->getBlock());
- // If the finally block doesn't fall through, we don't need these blocks.
- if (!HaveInsertPoint()) {
- FI.ContBB->eraseFromParent();
- if (FI.ResumeBB)
- FI.ResumeBB->eraseFromParent();
- return;
- }
-
- if (FI.ResumeBB) {
- llvm::Value *IsEH = Builder.CreateLoad(getAbnormalTerminationSlot(),
- "abnormal.termination");
- IsEH = Builder.CreateICmpEQ(IsEH, llvm::ConstantInt::get(Int8Ty, 0));
- Builder.CreateCondBr(IsEH, FI.ContBB, FI.ResumeBB);
- } else {
- // There was nothing exceptional in the try body, so we only have normal
- // control flow.
- Builder.CreateBr(FI.ContBB);
+ if (HaveInsertPoint()) {
+ if (FI.ResumeBB) {
+ llvm::Value *IsEH = Builder.CreateLoad(getAbnormalTerminationSlot(),
+ "abnormal.termination");
+ IsEH = Builder.CreateICmpEQ(IsEH, llvm::ConstantInt::get(Int8Ty, 0));
+ Builder.CreateCondBr(IsEH, FI.ContBB, FI.ResumeBB);
+ } else {
+ // There was nothing exceptional in the try body, so we only have normal
+ // control flow.
+ Builder.CreateBr(FI.ContBB);
+ }
}
Builder.restoreIP(SavedIP);