1 // RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=X86,CXX11X86
2 // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=X86,CXX17X86
3 // RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple amdgcn-amd-amdhsa | FileCheck %s --check-prefixes=AMD,CXX11AMD
4 // RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple amdgcn-amd-amdhsa | FileCheck %s --check-prefixes=AMD,CXX17AMD
7 static const int Foo
= 123;
9 // X86: @_ZN1A3FooE ={{.*}} constant i32 123, align 4
10 // AMD: @_ZN1A3FooE ={{.*}} addrspace(1) constant i32 123, align 4
11 const int *p
= &A::Foo
; // emit available_externally
12 const int A::Foo
; // convert to full definition
19 // Deferred initialization of the structure here requires changing
20 // the type of the global variable: the initializer list does not include
22 // CXX11X86: @_ZN9CreatePOD3podE = available_externally constant { i32, i8 } { i32 42, i8 43 },
23 // CXX11AMD: @_ZN9CreatePOD3podE = available_externally addrspace(1) constant { i32, i8 } { i32 42, i8 43 },
24 static constexpr PODWithInit pod
{};
26 const int *p_pod
= &CreatePOD::pod
.g
;
37 // CXX11X86: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant i32 42,
38 // CXX17X86: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42,
39 // CXX11AMD: @_ZN3Foo21ConstexprStaticMemberE = available_externally addrspace(4) constant i32 42,
40 // CXX17AMD: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr addrspace(4) constant i32 42, comdat, align 4
41 static constexpr int ConstexprStaticMember
= 42;
42 // X86: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 43,
43 // AMD: @_ZN3Foo17ConstStaticMemberE = available_externally addrspace(4) constant i32 43,
44 static const int ConstStaticMember
= 43;
46 // CXX11X86: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant %struct.Bar { i32 44 },
47 // CXX17X86: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant %struct.Bar { i32 44 },
48 // CXX11AMD: @_ZN3Foo23ConstStaticStructMemberE = available_externally addrspace(1) constant %struct.Bar { i32 44 },
49 // CXX17AMD: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr addrspace(1) constant %struct.Bar { i32 44 },
50 static constexpr Bar ConstStaticStructMember
= {44};
52 // CXX11X86: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global %struct.MutableBar,
53 // CXX17X86: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr global %struct.MutableBar { i32 45 },
54 // CXX11AMD: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external addrspace(1) global %struct.MutableBar,
55 // CXX17AMD: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr addrspace(1) global %struct.MutableBar { i32 45 },
56 static constexpr MutableBar ConstexprStaticMutableStructMember
= {45};
58 // X86: @_ZL15ConstStaticexpr = internal constant i32 46,
59 // AMD: @_ZL15ConstStaticexpr = internal addrspace(4) constant i32 46,
60 static constexpr int ConstStaticexpr
= 46;
61 // X86: @_ZL9ConstExpr = internal constant i32 46, align 4
62 // AMD: @_ZL9ConstExpr = internal addrspace(4) constant i32 46, align 4
63 static const int ConstExpr
= 46;
65 // X86: @_ZL21ConstexprStaticStruct = internal constant %struct.Bar { i32 47 },
66 // AMD: @_ZL21ConstexprStaticStruct = internal addrspace(1) constant %struct.Bar { i32 47 },
67 static constexpr Bar ConstexprStaticStruct
= {47};
69 // X86: @_ZL28ConstexprStaticMutableStruct = internal global %struct.MutableBar { i32 48 },
70 // AMD: @_ZL28ConstexprStaticMutableStruct = internal addrspace(1) global %struct.MutableBar { i32 48 },
71 static constexpr MutableBar ConstexprStaticMutableStruct
= {48};
73 void use(const int &);
75 use(Foo::ConstexprStaticMember
);
76 use(Foo::ConstStaticMember
);
77 use(Foo::ConstStaticStructMember
.b
);
78 use(Foo::ConstexprStaticMutableStructMember
.b
);
81 use(ConstexprStaticStruct
.b
);
82 use(ConstexprStaticMutableStruct
.b
);