Debian Codegraph @

clang/test/CIR/CodeGen/stmt-expr.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -mconstructor-aliases -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 -mconstructor-aliases -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 -mconstructor-aliases -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG
7
8 class A {
9 public:
10 A(): x(0) {}
11 A(A &a) : x(a.x) {}
12 int x;
13 void Foo() {}
14 };
15
16 void test1() {
17 ({
18 A a;
19 a;
20 }).Foo();
21 }
22
23 // CIR: cir.func {{.*}} @_Z5test1v()
24 // CIR: cir.scope {
25 // CIR: %[[REF_TMP0:.+]] = cir.alloca !rec_A, !cir.ptr<!rec_A>, ["ref.tmp0"]
26 // CIR: %[[TMP:.+]] = cir.alloca !rec_A, !cir.ptr<!rec_A>, ["tmp"]
27 // CIR: cir.scope {
28 // CIR: %[[A:.+]] = cir.alloca !rec_A, !cir.ptr<!rec_A>, ["a", init]
29 // CIR: cir.call @_ZN1AC2Ev(%[[A]]) : (!cir.ptr<!rec_A>) -> ()
30 // CIR: cir.call @_ZN1AC2ERS_(%[[REF_TMP0]], %[[A]]) : (!cir.ptr<!rec_A>, !cir.ptr<!rec_A>) -> ()
31 // CIR: }
32 // CIR: cir.call @_ZN1A3FooEv(%[[REF_TMP0]]) : (!cir.ptr<!rec_A>) -> ()
33 // CIR: }
34 // CIR: cir.return
35
36 // LLVM: define dso_local void @_Z5test1v()
37 // LLVM: %[[VAR1:.+]] = alloca %class.A, i64 1
38 // LLVM: %[[VAR2:.+]] = alloca %class.A, i64 1
39 // LLVM: %[[VAR3:.+]] = alloca %class.A, i64 1
40 // LLVM: br label %[[LBL4:.+]]
41 // LLVM: [[LBL4]]:
42 // LLVM: br label %[[LBL5:.+]]
43 // LLVM: [[LBL5]]:
44 // LLVM: call void @_ZN1AC2Ev(ptr %[[VAR3]])
45 // LLVM: call void @_ZN1AC2ERS_(ptr %[[VAR1]], ptr %[[VAR3]])
46 // LLVM: br label %[[LBL6:.+]]
47 // LLVM: [[LBL6]]:
48 // LLVM: call void @_ZN1A3FooEv(ptr %[[VAR1]])
49 // LLVM: br label %[[LBL7:.+]]
50 // LLVM: [[LBL7]]:
51 // LLVM: ret void
52
53 // OGCG: define dso_local void @_Z5test1v()
54 // OGCG: entry:
55 // OGCG: %[[REF_TMP:.+]] = alloca %class.A
56 // OGCG: %[[A:.+]] = alloca %class.A
57 // OGCG: call void @_ZN1AC2Ev(ptr {{.*}} %[[A]])
58 // OGCG: call void @_ZN1AC2ERS_(ptr {{.*}} %[[REF_TMP]], ptr {{.*}} %[[A]])
59 // OGCG: call void @_ZN1A3FooEv(ptr {{.*}} %[[REF_TMP]])
60 // OGCG: ret void
61
62 struct with_dtor {
63 ~with_dtor();
64 };
65
66 void cleanup() {
67 ({ with_dtor wd; });
68 }
69
70 // CIR: cir.func {{.*}} @_Z7cleanupv()
71 // CIR: cir.scope {
72 // CIR: %[[WD:.+]] = cir.alloca !rec_with_dtor, !cir.ptr<!rec_with_dtor>, ["wd"]
73 // CIR: cir.call @_ZN9with_dtorD1Ev(%[[WD]]) nothrow : (!cir.ptr<!rec_with_dtor>) -> ()
74 // CIR: }
75 // CIR: cir.return
76
77 // LLVM: define dso_local void @_Z7cleanupv()
78 // LLVM: %[[WD:.+]] = alloca %struct.with_dtor, i64 1
79 // LLVM: br label %[[LBL2:.+]]
80 // LLVM: [[LBL2]]:
81 // LLVM: call void @_ZN9with_dtorD1Ev(ptr %[[WD]])
82 // LLVM: br label %[[LBL3:.+]]
83 // LLVM: [[LBL3]]:
84 // LLVM: ret void
85
86 // OGCG: define dso_local void @_Z7cleanupv()
87 // OGCG: entry:
88 // OGCG: %[[WD:.+]] = alloca %struct.with_dtor
89 // OGCG: call void @_ZN9with_dtorD1Ev(ptr {{.*}} %[[WD]])
90 // OGCG: ret void
91
92 void gnu_statement_extension() {
93 float b = __real__ ({float _Complex a; a;});
94 }
95
96 // CIR: %[[B_ADDR:.*]] = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["b", init]
97 // CIR: %[[TMP_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["tmp"]
98 // CIR: cir.scope {
99 // CIR: %[[A_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["a"]
100 // CIR: %[[TMP_A:.*]] = cir.load {{.*}} %[[A_ADDR]] : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>
101 // CIR: cir.store {{.*}} %[[TMP_A]], %[[TMP_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>
102 // CIR: }
103 // CIR: %[[TMP:.*]] = cir.load {{.*}} %[[TMP_ADDR]] : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>
104 // CIR: %[[REAL:.*]] = cir.complex.real %[[TMP]] : !cir.complex<!cir.float> -> !cir.float
105 // CIR: cir.store {{.*}} %[[REAL]], %[[B_ADDR]] : !cir.float, !cir.ptr<!cir.float>
106
107 // LLVM: %[[A_ADDR:.*]] = alloca { float, float }, i64 1, align 4
108 // LLVM: %[[B_ADDR:.*]] = alloca float, i64 1, align 4
109 // LLVM: %[[TMP_ADDR:.*]] = alloca { float, float }, i64 1, align 4
110 // LLVM: br label %[[LABEL_1:.*]]
111 // LLVM: [[LABEL_1]]:
112 // LLVM: %[[TMP_A:.*]] = load { float, float }, ptr %[[A_ADDR]], align 4
113 // LLVM: store { float, float } %[[TMP_A]], ptr %[[TMP_ADDR]], align 4
114 // LLVM: br label %[[LABEL_2:.*]]
115 // LLVM: [[LABEL_2]]:
116 // LLVM: %[[TMP:.*]] = load { float, float }, ptr %[[TMP_ADDR]], align 4
117 // LLVM: %[[REAL:.*]] = extractvalue { float, float } %[[TMP]], 0
118 // LLVM: store float %[[REAL]], ptr %[[B_ADDR]], align 4
119
120 // OGCG: %[[B_ADDR:.*]] = alloca float, align 4
121 // OGCG: %[[A_ADDR:.*]] = alloca { float, float }, align 4
122 // OGCG: %[[TMP_ADDR:.*]] = alloca { float, float }, align 4
123 // OGCG: %[[A_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 0
124 // OGCG: %[[A_REAL:.*]] = load float, ptr %[[A_REAL_PTR]], align 4
125 // OGCG: %[[A_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[A_ADDR]], i32 0, i32 1
126 // OGCG: %[[A_IMAG:.*]] = load float, ptr %[[A_IMAG_PTR]], align 4
127 // OGCG: %[[TMP_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[TMP_ADDR]], i32 0, i32 0
128 // OGCG: %[[TMP_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[TMP_ADDR]], i32 0, i32 1
129 // OGCG: store float %[[A_REAL]], ptr %[[TMP_REAL_PTR]], align 4
130 // OGCG: store float %[[A_IMAG]], ptr %[[TMP_IMAG_PTR]], align 4
131 // OGCG: %[[TMP_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[TMP_ADDR]], i32 0, i32 0
132 // OGCG: %[[TMP_REAL:.*]] = load float, ptr %[[TMP_REAL_PTR]], align 4
133 // OGCG: store float %[[TMP_REAL]], ptr %[[B_ADDR]], align 4