1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,NOINLINE 2// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,NOINLINE 3// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=CHECK,INLINE 4// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=CHECK,INLINE 5// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -O1 %s | FileCheck %s --check-prefixes=CHECK,INLINE 6// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -O1 %s | FileCheck %s --check-prefixes=CHECK,INLINE 7 8// Tests that implicit constructor calls for user classes will always be inlined. 9 10struct Weed { 11 Weed() {Count += 1;} 12 [[maybe_unused]] void pull() {Count--;} 13 static int weedCount() { return Count; } 14private: 15 static int Count; 16 17} YardWeeds; 18 19int Weed::Count = 1; // It begins. . . 20 21struct Kitty { 22 unsigned burrsInFur; 23 24 Kitty() { 25 burrsInFur = 0; 26 } 27 28 void wanderInYard(int hours) { 29 burrsInFur = hours*Weed::weedCount()/8; 30 } 31 32 void lick() { 33 if(burrsInFur) { 34 burrsInFur--; 35 Weed w; 36 } 37 } 38 39} Nion; 40 41void NionsDay(int hours) { 42 static Kitty Nion; 43 Nion.wanderInYard(hours); 44 while(Nion.burrsInFur) Nion.lick(); 45} 46 47// CHECK: define void @main() 48// CHECK-NEXT: entry: 49// Verify constructor is emitted 50// NOINLINE-NEXT: call void @_GLOBAL__sub_I_inline_constructors.hlsl() 51// NOINLINE-NEXT: %0 = call i32 @llvm.dx.flattened.thread.id.in.group() 52// NOINLINE-NEXT: call void @_Z4mainj(i32 %0) 53// Verify inlining leaves only calls to "llvm." intrinsics 54// INLINE-NOT: call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}} 55// CHECK: ret void 56[shader("compute")] 57[numthreads(1,1,1)] 58void main(unsigned GI : SV_GroupIndex) { 59 NionsDay(10); 60} 61 62 63// CHECK: define void @rainyMain() 64// CHECK-NEXT: entry: 65// Verify constructor is emitted 66// NOINLINE-NEXT: call void @_GLOBAL__sub_I_inline_constructors.hlsl() 67// NOINLINE-NEXT: call void @_Z9rainyMainv() 68// Verify inlining leaves only calls to "llvm." intrinsics 69// INLINE-NOT: call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}} 70// CHECK: ret void 71[shader("compute")] 72[numthreads(1,1,1)] 73void rainyMain() { 74 NionsDay(1); 75} 76 77