1
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
2
+ // RUN: FileCheck --input-file=%t.cir --check-prefix=CIR %s
3
+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
4
+ // RUN: FileCheck --input-file=%t.ll --check-prefix=LLVM %s
3
5
4
6
int produce_int ();
5
7
void blackbox (const int &);
@@ -8,33 +10,33 @@ void local_const_int() {
8
10
const int x = produce_int ();
9
11
}
10
12
11
- // CHECK -LABEL: @_Z15local_const_intv
12
- // CHECK : %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
13
- // CHECK : }
13
+ // CIR -LABEL: @_Z15local_const_intv
14
+ // CIR : %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
15
+ // CIR : }
14
16
15
17
void param_const_int (const int x) {}
16
18
17
- // CHECK -LABEL: @_Z15param_const_inti
18
- // CHECK : %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
19
- // CHECK : }
19
+ // CIR -LABEL: @_Z15param_const_inti
20
+ // CIR : %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
21
+ // CIR : }
20
22
21
23
void local_constexpr_int () {
22
24
constexpr int x = 42 ;
23
25
blackbox (x);
24
26
}
25
27
26
- // CHECK -LABEL: @_Z19local_constexpr_intv
27
- // CHECK : %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
28
- // CHECK : }
28
+ // CIR -LABEL: @_Z19local_constexpr_intv
29
+ // CIR : %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const]
30
+ // CIR : }
29
31
30
32
void local_reference () {
31
33
int x = 0 ;
32
34
int &r = x;
33
35
}
34
36
35
- // CHECK -LABEL: @_Z15local_referencev
36
- // CHECK : %{{.+}} = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["r", init, const]
37
- // CHECK : }
37
+ // CIR -LABEL: @_Z15local_referencev
38
+ // CIR : %{{.+}} = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["r", init, const]
39
+ // CIR : }
38
40
39
41
struct Foo {
40
42
int a;
@@ -47,6 +49,22 @@ void local_const_struct() {
47
49
const Foo x = produce_foo ();
48
50
}
49
51
50
- // CHECK-LABEL: @_Z18local_const_structv
51
- // CHECK: %{{.+}} = cir.alloca !ty_Foo, !cir.ptr<!ty_Foo>, ["x", init, const]
52
- // CHECK: }
52
+ // CIR-LABEL: @_Z18local_const_structv
53
+ // CIR: %{{.+}} = cir.alloca !ty_Foo, !cir.ptr<!ty_Foo>, ["x", init, const]
54
+ // CIR: }
55
+
56
+ int local_const_load_store () {
57
+ const int x = produce_int ();
58
+ int y = x;
59
+ return y;
60
+ }
61
+
62
+ // CIR-LABEL: @_Z22local_const_load_storev
63
+ // CIR: %{{.+}} = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init, const] {alignment = 4 : i64}
64
+ // CIR: }
65
+
66
+ // LLVM-LABEL: @_Z22local_const_load_storev
67
+ // LLVM: %[[#INIT:]] = call i32 @_Z11produce_intv()
68
+ // LLVM-NEXT: store i32 %[[#INIT]], ptr %[[#SLOT:]], align 4, !dbg !{{.+}}, !invariant.group !{{.+}}
69
+ // LLVM-NEXT: %{{.+}} = load i32, ptr %[[#SLOT]], align 4, !dbg !{{.+}}, !invariant.group !{{.+}}
70
+ // LLVM: }
0 commit comments