summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-02-25 16:25:00 +0000
committerNico Weber <nicolasweber@gmx.de>2015-02-25 16:25:00 +0000
commite68b9f3e0a6b5efe0117f05984fb9e3a9933bac0 (patch)
tree692da69a51224a45f21684839da99a0e29078b49 /clang/lib/CodeGen/CGException.cpp
parented69e30d68c57ed7b215ac505447f80ee6982007 (diff)
downloadbcm5719-llvm-e68b9f3e0a6b5efe0117f05984fb9e3a9933bac0.tar.gz
bcm5719-llvm-e68b9f3e0a6b5efe0117f05984fb9e3a9933bac0.zip
Reland r230460 with a test fix for -Asserts builds.
Original CL description: Produce less broken basic block sequences for __finally blocks. The way cleanups (such as PerformSEHFinally) get emitted is that codegen generates some initialization code, then calls the cleanup's Emit() with the insertion point set to a good place, then the cleanup is supposed to emit its stuff, and then codegen might tack in a jump or similar to where the insertion point is after the cleanup. The PerformSEHFinally cleanup tries to just stash away the block it's supposed to codegen into, and then does codegen later, into that stashed block. However, after codegen'ing the __finally block, it used to set the insertion point to the finally's continuation block (where the __finally cleanup goes when its body is completed after regular, non-exceptional control flow). That's not correct, as that block can (and generally does) already ends in a jump. Instead, remember the insertion point that was current before the __finally got emitted, and restore that. Fixes two of the crashes in PR22553. llvm-svn: 230503
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 61f538b0eec..b7953bcedc9 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -813,8 +813,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {
bool hasFilter = false;
SmallVector<llvm::Value*, 4> filterTypes;
llvm::SmallPtrSet<llvm::Value*, 4> catchTypes;
- for (EHScopeStack::iterator I = EHStack.begin(), E = EHStack.end();
- I != E; ++I) {
+ for (EHScopeStack::iterator I = EHStack.begin(), E = EHStack.end(); I != E;
+ ++I) {
switch (I->getKind()) {
case EHScope::Cleanup:
@@ -1927,6 +1927,7 @@ void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S, SEHFinallyInfo &FI) {
assert(FI.ContBB && "did not emit normal cleanup");
// Emit the code into FinallyBB.
+ CGBuilderTy::InsertPoint SavedIP = Builder.saveIP();
Builder.SetInsertPoint(FI.FinallyBB);
EmitStmt(Finally->getBlock());
@@ -1949,7 +1950,7 @@ void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S, SEHFinallyInfo &FI) {
Builder.CreateBr(FI.ContBB);
}
- Builder.SetInsertPoint(FI.ContBB);
+ Builder.restoreIP(SavedIP);
return;
}
OpenPOWER on IntegriCloud