1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=CHECK,NOINLINE 2// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,INLINE 3 4// Make sure global variable for ctors exist for lib profile. 5// CHECK:@llvm.global_ctors 6 7RWBuffer<float> Buffer; 8 9[shader("compute")] 10[numthreads(1,1,1)] 11void 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 @_Z10FirstEntryv() 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)] 23void 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 @_Z11SecondEntryv() 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 constructor is alwaysinline 35// NOINLINE: ; Function Attrs: {{.*}}alwaysinline 36// NOINLINE-NEXT: define linkonce_odr void @_ZN4hlsl8RWBufferIfEC2Ev({{.*}} [[CtorAttr:\#[0-9]+]] 37 38// NOINLINE: ; Function Attrs: {{.*}}alwaysinline 39// NOINLINE-NEXT: define internal void @_GLOBAL__sub_I_GlobalConstructorLib.hlsl() [[InitAttr:\#[0-9]+]] 40 41// NOINLINE-DAG: attributes [[InitAttr]] = {{.*}} alwaysinline 42// NOINLINE-DAG: attributes [[CtorAttr]] = {{.*}} alwaysinline 43