|
| 1 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir |
| 2 | +// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR |
| 3 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 | +// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM |
| 5 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll |
| 6 | +// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG |
| 7 | + |
| 8 | +int f19(void) { |
| 9 | + return ({ 3;;4;; }); |
| 10 | +} |
| 11 | + |
| 12 | +// CIR: cir.func dso_local @f19() -> !s32i |
| 13 | +// CIR: %[[RETVAL:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] |
| 14 | +// CIR: %[[TMP:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["tmp"] |
| 15 | +// CIR: cir.scope { |
| 16 | +// CIR: %[[C3:.+]] = cir.const #cir.int<3> : !s32i |
| 17 | +// CIR: %[[C4:.+]] = cir.const #cir.int<4> : !s32i |
| 18 | +// CIR: cir.store {{.*}} %[[C4]], %[[TMP]] : !s32i, !cir.ptr<!s32i> |
| 19 | +// CIR: } |
| 20 | +// CIR: %[[TMP_VAL:.+]] = cir.load {{.*}} %[[TMP]] : !cir.ptr<!s32i>, !s32i |
| 21 | +// CIR: cir.store %[[TMP_VAL]], %[[RETVAL]] : !s32i, !cir.ptr<!s32i> |
| 22 | +// CIR: %[[RES:.+]] = cir.load %[[RETVAL]] : !cir.ptr<!s32i>, !s32i |
| 23 | +// CIR: cir.return %[[RES]] : !s32i |
| 24 | + |
| 25 | +// LLVM: define dso_local i32 @f19() |
| 26 | +// LLVM: %[[VAR1:.+]] = alloca i32, i64 1 |
| 27 | +// LLVM: %[[VAR2:.+]] = alloca i32, i64 1 |
| 28 | +// LLVM: br label %[[LBL3:.+]] |
| 29 | +// LLVM: [[LBL3]]: |
| 30 | +// LLVM: store i32 4, ptr %[[VAR2]] |
| 31 | +// LLVM: br label %[[LBL4:.+]] |
| 32 | +// LLVM: [[LBL4]]: |
| 33 | +// LLVM: %[[V1:.+]] = load i32, ptr %[[VAR2]] |
| 34 | +// LLVM: store i32 %[[V1]], ptr %[[VAR1]] |
| 35 | +// LLVM: %[[RES:.+]] = load i32, ptr %[[VAR1]] |
| 36 | +// LLVM: ret i32 %[[RES]] |
| 37 | + |
| 38 | +// OGCG: define dso_local i32 @f19() |
| 39 | +// OGCG: entry: |
| 40 | +// OGCG: %[[TMP:.+]] = alloca i32 |
| 41 | +// OGCG: store i32 4, ptr %[[TMP]] |
| 42 | +// OGCG: %[[TMP_VAL:.+]] = load i32, ptr %[[TMP]] |
| 43 | +// OGCG: ret i32 %[[TMP_VAL]] |
| 44 | + |
| 45 | + |
| 46 | +int nested(void) { |
| 47 | + ({123;}); |
| 48 | + { |
| 49 | + int bar = 987; |
| 50 | + return ({ ({ int asdf = 123; asdf; }); ({9999;}); }); |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +// CIR: cir.func dso_local @nested() -> !s32i |
| 55 | +// CIR: %[[RETVAL:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] |
| 56 | +// CIR: %[[TMP_OUTER:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["tmp"] |
| 57 | +// CIR: cir.scope { |
| 58 | +// CIR: %[[C123_OUTER:.+]] = cir.const #cir.int<123> : !s32i |
| 59 | +// CIR: cir.store {{.*}} %[[C123_OUTER]], %[[TMP_OUTER]] : !s32i, !cir.ptr<!s32i> |
| 60 | +// CIR: } |
| 61 | +// CIR: %[[LOAD_TMP_OUTER:.+]] = cir.load {{.*}} %[[TMP_OUTER]] : !cir.ptr<!s32i>, !s32i |
| 62 | +// CIR: cir.scope { |
| 63 | +// CIR: %[[BAR:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["bar", init] |
| 64 | +// CIR: %[[TMP_BARRET:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["tmp"] |
| 65 | +// CIR: %[[C987:.+]] = cir.const #cir.int<987> : !s32i |
| 66 | +// CIR: cir.store {{.*}} %[[C987]], %[[BAR]] : !s32i, !cir.ptr<!s32i> |
| 67 | +// CIR: cir.scope { |
| 68 | +// CIR: %[[TMP1:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["tmp"] |
| 69 | +// CIR: %[[TMP2:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["tmp"] |
| 70 | +// CIR: cir.scope { |
| 71 | +// CIR: %[[ASDF:.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["asdf", init] |
| 72 | +// CIR: %[[C123_INNER:.+]] = cir.const #cir.int<123> : !s32i |
| 73 | +// CIR: cir.store {{.*}} %[[C123_INNER]], %[[ASDF]] : !s32i, !cir.ptr<!s32i> |
| 74 | +// CIR: %[[LOAD_ASDF:.+]] = cir.load {{.*}} %[[ASDF]] : !cir.ptr<!s32i>, !s32i |
| 75 | +// CIR: cir.store {{.*}} %[[LOAD_ASDF]], %[[TMP1]] : !s32i, !cir.ptr<!s32i> |
| 76 | +// CIR: } |
| 77 | +// CIR: %[[V1:.+]] = cir.load {{.*}} %[[TMP1]] : !cir.ptr<!s32i>, !s32i |
| 78 | +// CIR: cir.scope { |
| 79 | +// CIR: %[[C9999:.+]] = cir.const #cir.int<9999> : !s32i |
| 80 | +// CIR: cir.store {{.*}} %[[C9999]], %[[TMP2]] : !s32i, !cir.ptr<!s32i> |
| 81 | +// CIR: } |
| 82 | +// CIR: %[[V2:.+]] = cir.load {{.*}} %[[TMP2]] : !cir.ptr<!s32i>, !s32i |
| 83 | +// CIR: cir.store {{.*}} %[[V2]], %[[TMP_BARRET]] : !s32i, !cir.ptr<!s32i> |
| 84 | +// CIR: } |
| 85 | +// CIR: %[[BARRET_VAL:.+]] = cir.load {{.*}} %[[TMP_BARRET]] : !cir.ptr<!s32i>, !s32i |
| 86 | +// CIR: cir.store %[[BARRET_VAL]], %[[RETVAL]] : !s32i, !cir.ptr<!s32i> |
| 87 | +// CIR: %[[RES:.+]] = cir.load %[[RETVAL]] : !cir.ptr<!s32i>, !s32i |
| 88 | +// CIR: cir.return %[[RES]] : !s32i |
| 89 | +// CIR: } |
| 90 | +// CIR: %[[FINAL_RES:.+]] = cir.load %[[RETVAL]] : !cir.ptr<!s32i>, !s32i |
| 91 | +// CIR: cir.return %[[FINAL_RES]] : !s32i |
| 92 | + |
| 93 | +// LLVM: define dso_local i32 @nested() |
| 94 | +// LLVM: %[[VAR1:.+]] = alloca i32, i64 1 |
| 95 | +// LLVM: %[[VAR2:.+]] = alloca i32, i64 1 |
| 96 | +// LLVM: %[[VAR3:.+]] = alloca i32, i64 1 |
| 97 | +// LLVM: %[[VAR4:.+]] = alloca i32, i64 1 |
| 98 | +// LLVM: %[[VAR5:.+]] = alloca i32, i64 1 |
| 99 | +// LLVM: %[[VAR6:.+]] = alloca i32, i64 1 |
| 100 | +// LLVM: %[[VAR7:.+]] = alloca i32, i64 1 |
| 101 | +// LLVM: br label %[[LBL8:.+]] |
| 102 | +// LLVM: [[LBL8]]: |
| 103 | +// LLVM: store i32 123, ptr %[[VAR7]] |
| 104 | +// LLVM: br label %[[LBL9:.+]] |
| 105 | +// LLVM: [[LBL9]]: |
| 106 | +// LLVM: br label %[[LBL10:.+]] |
| 107 | +// LLVM: [[LBL10]]: |
| 108 | +// LLVM: store i32 987, ptr %[[VAR1]] |
| 109 | +// LLVM: br label %[[LBL11:.+]] |
| 110 | +// LLVM: [[LBL11]]: |
| 111 | +// LLVM: br label %[[LBL12:.+]] |
| 112 | +// LLVM: [[LBL12]]: |
| 113 | +// LLVM: store i32 123, ptr %[[VAR5]] |
| 114 | +// LLVM: %[[V1:.+]] = load i32, ptr %[[VAR5]] |
| 115 | +// LLVM: store i32 %[[V1]], ptr %[[VAR3]] |
| 116 | +// LLVM: br label %[[LBL14:.+]] |
| 117 | +// LLVM: [[LBL14]]: |
| 118 | +// LLVM: br label %[[LBL15:.+]] |
| 119 | +// LLVM: [[LBL15]]: |
| 120 | +// LLVM: store i32 9999, ptr %[[VAR4]] |
| 121 | +// LLVM: br label %[[LBL16:.+]] |
| 122 | +// LLVM: [[LBL16]]: |
| 123 | +// LLVM: %[[V2:.+]] = load i32, ptr %[[VAR4]] |
| 124 | +// LLVM: store i32 %[[V2]], ptr %[[VAR2]] |
| 125 | +// LLVM: br label %[[LBL18:.+]] |
| 126 | +// LLVM: [[LBL18]]: |
| 127 | +// LLVM: %[[V3:.+]] = load i32, ptr %[[VAR2]] |
| 128 | +// LLVM: store i32 %[[V3]], ptr %[[VAR6]] |
| 129 | +// LLVM: %[[RES:.+]] = load i32, ptr %[[VAR6]] |
| 130 | +// LLVM: ret i32 %[[RES]] |
| 131 | + |
| 132 | +// OGCG: define dso_local i32 @nested() |
| 133 | +// OGCG: entry: |
| 134 | +// OGCG: %[[TMP_OUTER:.+]] = alloca i32 |
| 135 | +// OGCG: %[[BAR:.+]] = alloca i32 |
| 136 | +// OGCG: %[[ASDF:.+]] = alloca i32 |
| 137 | +// OGCG: %[[TMP1:.+]] = alloca i32 |
| 138 | +// OGCG: %[[TMP2:.+]] = alloca i32 |
| 139 | +// OGCG: %[[TMP3:.+]] = alloca i32 |
| 140 | +// OGCG: store i32 123, ptr %[[TMP_OUTER]] |
| 141 | +// OGCG: %[[OUTER_VAL:.+]] = load i32, ptr %[[TMP_OUTER]] |
| 142 | +// OGCG: store i32 987, ptr %[[BAR]] |
| 143 | +// OGCG: store i32 123, ptr %[[ASDF]] |
| 144 | +// OGCG: %[[ASDF_VAL:.+]] = load i32, ptr %[[ASDF]] |
| 145 | +// OGCG: store i32 %[[ASDF_VAL]], ptr %[[TMP1]] |
| 146 | +// OGCG: %[[TMP1_VAL:.+]] = load i32, ptr %[[TMP1]] |
| 147 | +// OGCG: store i32 9999, ptr %[[TMP3]] |
| 148 | +// OGCG: %[[TMP3_VAL:.+]] = load i32, ptr %[[TMP3]] |
| 149 | +// OGCG: store i32 %[[TMP3_VAL]], ptr %[[TMP2]] |
| 150 | +// OGCG: %[[RES:.+]] = load i32, ptr %[[TMP2]] |
| 151 | +// OGCG: ret i32 %[[RES]] |
| 152 | + |
| 153 | +void empty() { |
| 154 | + return ({;;;;}); |
| 155 | +} |
| 156 | + |
| 157 | +// CIR: cir.func no_proto dso_local @empty() |
| 158 | +// CIR-NEXT: cir.return |
| 159 | + |
| 160 | +// LLVM: define dso_local void @empty() |
| 161 | +// LLVM: ret void |
| 162 | +// LLVM: } |
| 163 | + |
| 164 | +// OGCG: define dso_local void @empty() |
| 165 | +// OGCG: ret void |
| 166 | +// OGCG: } |
0 commit comments