• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
2 // Check that no empty blocks are generated for nested ifs.
3 
4 extern void func();
5 
f0(int val)6 int f0(int val) {
7   if (val == 0) {
8     func();
9   } else if (val == 1) {
10     func();
11   }
12   return 0;
13 }
14 
15 // CHECK-LABEL: define {{.*}}i32 @f0
16 // CHECK: call void {{.*}} @func
17 // CHECK: call void {{.*}} @func
18 // CHECK: br label %[[RETBLOCK1:[^ ]*]]
19 // CHECK: [[RETBLOCK1]]:
20 // CHECK-NOT: br label
21 // CHECK: ret i32
22 
f1(int val,int g)23 int f1(int val, int g) {
24   if (val == 0)
25     if (g == 1) {
26       func();
27     }
28   return 0;
29 }
30 
31 // CHECK-LABEL: define {{.*}}i32 @f1
32 // CHECK: call void {{.*}} @func
33 // CHECK: br label %[[RETBLOCK2:[^ ]*]]
34 // CHECK: [[RETBLOCK2]]:
35 // CHECK-NOT: br label
36 // CHECK: ret i32
37