summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-05-23 20:00:44 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-05-23 20:00:44 +0000
commit11d4d9ec4e5567a6808e46ae87cb80e6250967ff (patch)
tree5a1f86b759962cdd4e9331843abf0bd0b654fca4
parenta09387df9ffbe0849288b6ba5ce9a31c0829eed5 (diff)
downloadbcm5719-llvm-11d4d9ec4e5567a6808e46ae87cb80e6250967ff.tar.gz
bcm5719-llvm-11d4d9ec4e5567a6808e46ae87cb80e6250967ff.zip
PR5863: Don't erase unreachable BBs which have an associated cleanup size.
This works around a crash where malloc reused the memory of an erased BB for a new BB leaving old cleanup information pointing at the new block. llvm-svn: 104472
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp2
-rw-r--r--clang/test/CodeGenCXX/PR5863-unreachable-block.cpp13
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 589273da439..3e807bdbc76 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -80,7 +80,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
// explicitly here. This handles the common case of a call to a noreturn
// function.
if (llvm::BasicBlock *CurBB = Builder.GetInsertBlock()) {
- if (CurBB->empty() && CurBB->use_empty()) {
+ if (CurBB->empty() && CurBB->use_empty() && !BlockScopes.count(CurBB)) {
CurBB->eraseFromParent();
Builder.ClearInsertionPoint();
}
diff --git a/clang/test/CodeGenCXX/PR5863-unreachable-block.cpp b/clang/test/CodeGenCXX/PR5863-unreachable-block.cpp
new file mode 100644
index 00000000000..91221c9a7a6
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR5863-unreachable-block.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+// PR5836
+class E { };
+
+void P1() {
+ try {
+ int a=0, b=0;
+ if (a > b) // simply filling in 0 or 1 doesn't trigger the assertion
+ throw E(); // commenting out 'if' or 'throw' 'fixes' the assertion failure
+ try { } catch (...) { } // empty try/catch block needed for failure
+ } catch (...) { } // this try/catch block needed for failure
+}
OpenPOWER on IntegriCloud