1 // RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o - -triple x86_64-linux -DCONSTEXPR= | FileCheck %s
2 // RUN: %clang_cc1 -std=c++20 %s -emit-llvm -o - -triple x86_64-linux -DCONSTEXPR=constexpr | FileCheck %s --check-prefix=CONST
4 template<typename T
> CONSTEXPR T
id(T v
) { return v
; }
5 template<auto V
> auto value
= id(V
);
7 // CHECK: call {{.*}} @_Z2idIiET_S0_(i32 noundef 1)
8 // CONST: @_Z5valueILi1EE = weak_odr {{.*}} i32 1,
11 // CHECK: call {{.*}} @_Z2idIyET_S0_(i64 noundef -1)
12 // CONST: @_Z5valueILy18446744073709551615EE = weak_odr {{.*}} i64 -1,
13 template unsigned long long value
<-1ULL>;
15 // CHECK: call {{.*}} @_Z2idIfET_S0_(float noundef 1.000000e+00)
16 // CONST: @_Z5valueILf3f800000EE = weak_odr {{.*}} float 1.000000e+00,
17 template float value
<1.0f
>;
18 // CHECK: call {{.*}} @_Z2idIdET_S0_(double noundef 1.000000e+00)
19 // CONST: @_Z5valueILd3ff0000000000000EE = weak_odr {{.*}} double 1.000000e+00,
20 template double value
<1.0>;
24 // CHECK: call {{.*}} @_Z2idI1EET_S1_(i32 noundef 1)
25 // CONST: @_Z5valueIL1E1EE = weak_odr {{.*}} i32 1,
29 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef @n)
30 // CONST: @_Z5valueIXadL_Z1nEEE = weak_odr {{.*}} ptr @n,
31 template int *value
<&n
>;
33 struct A
{ int a
[3]; } a
;
34 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef @a)
35 // CONST: @_Z5valueIXadsoiL_Z1aEEEE = weak_odr {{.*}} ptr @a,
36 template int *value
<&a
.a
[0]>;
37 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef getelementptr (i8, ptr @a, i64 4))
38 // CONST: @_Z5valueIXadsoiL_Z1aE4EEE = weak_odr {{.*}} ptr getelementptr (i8, ptr @a, i64 4),
39 template int *value
<&a
.a
[1]>;
40 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef getelementptr (i8, ptr @a, i64 8))
41 // CONST: @_Z5valueIXadsoiL_Z1aE8EEE = weak_odr {{.*}} ptr getelementptr (i8, ptr @a, i64 8),
42 template int *value
<&a
.a
[2]>;
43 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef getelementptr (i8, ptr @a, i64 12))
44 // CONST: @_Z5valueIXadsoiL_Z1aE12pEEE = weak_odr {{.*}} ptr getelementptr (i8, ptr @a, i64 12),
45 template int *value
<&a
.a
[3]>;
54 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef @u)
55 // CONST: @_Z5valueIXadsoiL_Z1uE_EEE = weak_odr {{.*}} ptr @u,
56 template int *value
<&u
.x
>;
57 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef @u)
58 // CONST: @_Z5valueIXadsoiL_Z1uE_0EEE = weak_odr {{.*}} ptr @u,
59 template int *value
<&u
.y
>;
60 // CHECK: call {{.*}} @_Z2idIPiET_S1_(ptr noundef @u)
61 // CONST: @_Z5valueIXadsoiL_Z1uE_1_0EEE = weak_odr {{.*}} ptr @u,
62 template int *value
<&u
.internal
.y
>;
64 struct B
{ int x
, y
; };
65 // CHECK: call {{.*}} @_Z2idIM1BiET_S2_(i64 0)
66 // CONST: @_Z5valueIXadL_ZN1B1xEEEE = weak_odr {{.*}} i64 0,
67 template int B::*value
<&B::x
>;
68 // CHECK: call {{.*}} @_Z2idIM1BiET_S2_(i64 4)
69 // CONST: @_Z5valueIXadL_ZN1B1yEEEE = weak_odr {{.*}} i64 4,
70 template int B::*value
<&B::y
>;
72 struct C
: A
, B
{ int z
; };
73 // CHECK: call {{.*}} @_Z2idIM1CiET_S2_(i64 12)
74 // CONST: @_Z5valueIXmcM1CiadL_ZN1B1xEE12EEE = weak_odr {{.*}} i64 12,
75 template int C::*value
<(int C::*)&B::x
>;
76 // CHECK: call {{.*}} @_Z2idIM1BiET_S2_(i64 8)
77 // CONST: @_Z5valueIXmcM1BiadL_ZN1C1zEEn12EEE = weak_odr {{.*}} i64 8,
78 template int B::*value
<(int B::*)&C::z
>;
80 // CHECK: store i32 1,
81 // CHECK: store i32 2,
83 // CHECK: call {{.*}} @_Z2idICiET_S1_(i64 noundef %
84 // CONST: @_Z5valueIXtlCiLi1ELi2EEEE = weak_odr {{.*}} { i32, i32 } { i32 1, i32 2 },
85 template _Complex
int value
<1 + 2j
>;
87 // CHECK: store float 1.000000e+00,
88 // CHECK: store float 2.000000e+00,
89 // CHECK: load <2 x float>,
90 // CHECK: call {{.*}} @_Z2idICfET_S1_(<2 x float> noundef %
91 // CONST: @_Z5valueIXtlCfLf3f800000ELf40000000EEEE = weak_odr {{.*}} { float, float } { float 1.000000e+00, float 2.000000e+00 },
92 template _Complex
float value
<1.0f
+ 2.0fj
>;
94 using V3i
__attribute__((ext_vector_type(3))) = int;
95 // CHECK: call {{.*}} @_Z2idIDv3_iET_S1_(<3 x i32> noundef <i32 1, i32 2, i32 3>)
96 // CONST: @_Z5valueIXtlDv3_iLi1ELi2ELi3EEEE = weak_odr {{.*}} <3 x i32> <i32 1, i32 2, i32 3>
97 template V3i value
<V3i
{1, 2, 3}>;
99 using V3f
[[gnu::vector_size(12)]] = float;
100 // CHECK: call {{.*}} @_Z2idIDv3_fET_S1_(<3 x float> noundef <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00>)
101 // CONST: @_Z5valueIXtlDv3_fLf3f800000ELf40000000ELf40400000EEEE = weak_odr {{.*}} <3 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00>
102 template V3f value
<V3f
{1, 2, 3}>;
110 void callSetByRefWithSubobject() {
111 // CHECK: store i32 1, ptr getelementptr (i8, ptr @a, i64 4)