summaryrefslogtreecommitdiff
path: root/test/CodeGen/forwarding-blocks-if.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/forwarding-blocks-if.c')
-rw-r--r--test/CodeGen/forwarding-blocks-if.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/CodeGen/forwarding-blocks-if.c b/test/CodeGen/forwarding-blocks-if.c
new file mode 100644
index 000000000000..51711bf0ef46
--- /dev/null
+++ b/test/CodeGen/forwarding-blocks-if.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// Check that no empty blocks are generated for nested ifs.
+
+extern void func();
+
+int f0(int val) {
+ if (val == 0) {
+ func();
+ } else if (val == 1) {
+ func();
+ }
+ return 0;
+}
+
+// CHECK-LABEL: define {{.*}}i32 @f0
+// CHECK: call void {{.*}} @func
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK1:[^ ]*]]
+// CHECK: [[RETBLOCK1]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
+
+int f1(int val, int g) {
+ if (val == 0)
+ if (g == 1) {
+ func();
+ }
+ return 0;
+}
+
+// CHECK-LABEL: define {{.*}}i32 @f1
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK2:[^ ]*]]
+// CHECK: [[RETBLOCK2]]:
+// CHECK-NOT: br label
+// CHECK: ret i32