brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · b0d5a78 Raw
77 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,NOINLINE2// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,NOINLINE3// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=CHECK,INLINE4// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=CHECK,INLINE5// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -emit-llvm -o - -O1 %s | FileCheck %s --check-prefixes=CHECK,INLINE6// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -emit-llvm -o - -O1 %s | FileCheck %s --check-prefixes=CHECK,INLINE7 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 emitted50// 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." intrinsics54// INLINE-NOT:    call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}}55// CHECK:         ret void56[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 emitted66// NOINLINE-NEXT:   call void @_GLOBAL__sub_I_inline_constructors.hlsl()67// NOINLINE-NEXT:   call void @_Z9rainyMainv()68// Verify inlining leaves only calls to "llvm." intrinsics69// INLINE-NOT:      call {{[^@]*}} @{{[^l][^l][^v][^m][^\.]}}70// CHECK:           ret void71[shader("compute")]72[numthreads(1,1,1)]73void rainyMain() {74  NionsDay(1);75}76 77