summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-19 08:23:12 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-19 08:23:12 +0000
commitc3ab4c6c987a6351c2130b09190b19f836fd2a54 (patch)
tree76d678b7083e51fe59753ebe82f58244e72b5b4c /clang/lib/CodeGen/CGStmt.cpp
parent68602758e4c22e0289b3cd90cf4c445694d11330 (diff)
downloadbcm5719-llvm-c3ab4c6c987a6351c2130b09190b19f836fd2a54.tar.gz
bcm5719-llvm-c3ab4c6c987a6351c2130b09190b19f836fd2a54.zip
Detect when the current generation point is unreachable after emitting
expressions. - This generally catches the important case of noreturn functions. - With the last two changes, we are down to 152 unreachable blocks emitted on 403.gcc, vs the 1805 we started with. llvm-svn: 76364
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 4e6ec82eb52..04b26ea80ae 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -68,10 +68,19 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
default:
// Must be an expression in a stmt context. Emit the value (to get
// side-effects) and ignore the result.
- if (const Expr *E = dyn_cast<Expr>(S)) {
- EmitAnyExpr(E, 0, false, true);
- } else {
+ if (!isa<Expr>(S))
ErrorUnsupported(S, "statement");
+
+ EmitAnyExpr(cast<Expr>(S), 0, false, true);
+
+ // Expression emitters don't handle unreachable blocks yet, so look for one
+ // 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()) {
+ CurBB->eraseFromParent();
+ Builder.ClearInsertionPoint();
+ }
}
break;
case Stmt::IndirectGotoStmtClass:
OpenPOWER on IntegriCloud