aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGStmt.cpp4
-rw-r--r--test/CodeGen/dostmt.c10
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 7c65b3c437..5c1fea4472 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -237,6 +237,10 @@ void CodeGenFunction::SimplifyForwardingBlocks(llvm::BasicBlock *BB) {
if (!BI || !BI->isUnconditional())
return;
+ // Can only simplify empty blocks.
+ if (BI != BB->begin())
+ return;
+
BB->replaceAllUsesWith(BI->getSuccessor(0));
BI->eraseFromParent();
BB->eraseFromParent();
diff --git a/test/CodeGen/dostmt.c b/test/CodeGen/dostmt.c
index 1a2e02a78e..32e5f94034 100644
--- a/test/CodeGen/dostmt.c
+++ b/test/CodeGen/dostmt.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o -
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
int bar();
int test0() {
@@ -66,5 +66,11 @@ void test5() {
do { break; } while(0);
}
-
+// PR14191
+void test6f(void);
+void test6() {
+ do {
+ } while (test6f(), 0);
+ // CHECK call void @test6f()
+}