1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=CS,CHECK
2 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=LIB,CHECK
4 // Make sure global variable for dtors exist for lib profile.
5 // LIB:@llvm.global_dtors
6 // Make sure global variable for dtors removed for compute profile.
7 // CS-NOT:llvm.global_dtors
41 int Pupper::Count = 0;
45 void main(unsigned GI : SV_GroupIndex) {
49 // Make sure global variable for ctors/dtors removed.
50 // CHECK-NOT:@llvm.global_ctors
51 // CHECK-NOT:@llvm.global_dtors
52 //CHECK: define void @main()
54 //CHECK-NEXT: call void @_GLOBAL__sub_I_GlobalDestructors.hlsl()
55 //CHECK-NEXT: %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
56 //CHECK-NEXT: call void @"?main@@YAXI@Z"(i32 %0)
57 //CHECK-NEXT: call void @_GLOBAL__D_a()
58 //CHECK-NEXT: ret void
60 // This is really just a sanity check I needed for myself to verify that
61 // function scope static variables also get destroyed properly.
63 //CHECK: define internal void @_GLOBAL__D_a()
65 //CHECK-NEXT: call void @"??1Tail@@QAA@XZ"(ptr @"?T@?1??Wag@@YAXXZ@4UTail@@A")
66 //CHECK-NEXT: call void @"??1Pupper@@QAA@XZ"(ptr @"?GlobalPup@@3UPupper@@A")
67 //CHECK-NEXT: ret void