|
| 1 | +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir |
| 2 | +// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR |
| 3 | +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 | +// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM |
| 5 | +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll |
| 6 | +// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 | + |
| 8 | +struct StructWithConstEval { |
| 9 | + consteval int _Complex consteval_ret_complex() { return {1, 2}; } |
| 10 | +}; |
| 11 | + |
| 12 | +void calling_consteval_methods() { |
| 13 | + StructWithConstEval a; |
| 14 | + int _Complex c = a.consteval_ret_complex(); |
| 15 | +} |
| 16 | + |
| 17 | +// CIR: %[[A_ADDR:.*]] = cir.alloca !rec_StructWithConstEval, !cir.ptr<!rec_StructWithConstEval>, ["a"] |
| 18 | +// CIR: %[[C_ADDR:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["c", init] |
| 19 | +// CIR: %[[CONST_COMPLEX:.*]] = cir.const #cir.const_complex<#cir.int<1> : !s32i, #cir.int<2> : !s32i> : !cir.complex<!s32i> |
| 20 | +// CIR: cir.store {{.*}} %[[CONST_COMPLEX]], %[[C_ADDR]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>> |
| 21 | + |
| 22 | +// LLVM: %[[A_ADDR:.*]] = alloca %struct.StructWithConstEval, i64 1, align 1 |
| 23 | +// LLVM: %[[C_ADDR:.*]] = alloca { i32, i32 }, i64 1, align 4 |
| 24 | +// LLVM: store { i32, i32 } { i32 1, i32 2 }, ptr %[[C_ADDR]], align 4 |
| 25 | + |
| 26 | +// OGCG: %[[A_ADDR:.*]] = alloca %struct.StructWithConstEval, align 1 |
| 27 | +// OGCG: %[[C_ADDR:.*]] = alloca { i32, i32 }, align 4 |
| 28 | +// OGCG: %[[C_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[C_ADDR]], i32 0, i32 0 |
| 29 | +// OGCG: %[[C_IMAG_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[C_ADDR]], i32 0, i32 1 |
| 30 | +// OGCG: store i32 1, ptr %[[C_REAL_PTR]], align 4 |
| 31 | +// OGCG: store i32 2, ptr %[[C_IMAG_PTR]], align 4 |
0 commit comments