Debian Codegraph @

clang/test/CodeGenHLSL/GlobalConstructorLib.hlsl

raw
1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes %s -o - | llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,NOINLINE
2 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -O0 %s -o - | llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,INLINE
3
4 // Make sure global variable for ctors exist for lib profile.
5 // CHECK:@llvm.global_ctors
6
7 RWBuffer<float> Buffer;
8
9 [shader("compute")]
10 [numthreads(1,1,1)]
11 void FirstEntry() {}
12
13 // CHECK: define void @FirstEntry()
14 // CHECK-NEXT: entry:
15 // NOINLINE-NEXT: call void @_GLOBAL__sub_I_GlobalConstructorLib.hlsl()
16 // NOINLINE-NEXT: call void @FirstEntry()
17 // Verify inlining leaves only calls to "llvm." intrinsics
18 // INLINE-NOT: call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}}
19 // CHECK: ret void
20
21 [shader("compute")]
22 [numthreads(1,1,1)]
23 void SecondEntry() {}
24
25 // CHECK: define void @SecondEntry()
26 // CHECK-NEXT: entry:
27 // NOINLINE-NEXT: call void @_GLOBAL__sub_I_GlobalConstructorLib.hlsl()
28 // NOINLINE-NEXT: call void @SecondEntry()
29 // Verify inlining leaves only calls to "llvm." intrinsics
30 // INLINE-NOT: call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}}
31 // CHECK: ret void
32
33
34 // Verify the constructors are alwaysinline
35 // NOINLINE: ; Function Attrs: {{.*}}alwaysinline
36 // NOINLINE-NEXT: define linkonce_odr hidden void @hlsl::RWBuffer<float>::RWBuffer()({{.*}}){{.*}} [[CtorAttr:\#[0-9]+]]
37
38 // NOINLINE: ; Function Attrs: {{.*}}alwaysinline
39 // NOINLINE-NEXT: define linkonce_odr hidden void @hlsl::RWBuffer<float>::RWBuffer(hlsl::RWBuffer<float> const&)({{.*}}){{.*}} [[CtorAttr]]
40
41 // NOINLINE: ; Function Attrs: {{.*}}alwaysinline
42 // NOINLINE-NEXT: define linkonce_odr hidden void @hlsl::RWBuffer<float>::RWBuffer()(ptr noundef nonnull align 4 dereferenceable(4) %this){{.*}} [[CtorAttr:\#[0-9]+]]
43
44 // NOINLINE: ; Function Attrs: {{.*}}alwaysinline
45 // NOINLINE-NEXT: define linkonce_odr hidden void @hlsl::RWBuffer<float>::RWBuffer(hlsl::RWBuffer<float> const&)({{.*}}){{.*}} [[CtorAttr]]
46
47 // NOINLINE: ; Function Attrs: {{.*}}alwaysinline
48 // NOINLINE-NEXT: define internal void @_GLOBAL__sub_I_GlobalConstructorLib.hlsl() [[InitAttr:\#[0-9]+]]
49
50 // NOINLINE-DAG: attributes [[InitAttr]] = {{.*}} alwaysinline
51 // NOINLINE-DAG: attributes [[CtorAttr]] = {{.*}} alwaysinline