46 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=CHECK,NOINLINE2// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,INLINE3 4int i;5 6__attribute__((constructor)) void call_me_first(void) {7 i = 12;8}9 10__attribute__((constructor)) void then_call_me(void) {11 i = 13;12}13 14__attribute__((destructor)) void call_me_last(void) {15 i = 0;16}17 18[numthreads(1,1,1)]19void main(unsigned GI : SV_GroupIndex) {}20 21// Make sure global variable for ctors/dtors removed.22// CHECK-NOT:@llvm.global_ctors23// CHECK-NOT:@llvm.global_dtors24 25// CHECK: define void @main()26// CHECK-NEXT: entry:27// Verify function constructors are emitted28// NOINLINE-NEXT: call void @_Z13call_me_firstv()29// NOINLINE-NEXT: call void @_Z12then_call_mev()30// NOINLINE-NEXT: call void @_GLOBAL__sub_I_GlobalConstructorFunction.hlsl()31// NOINLINE-NEXT: %0 = call i32 @llvm.dx.flattened.thread.id.in.group()32// NOINLINE-NEXT: call void @_Z4mainj(i32 %0)33// NOINLINE-NEXT: call void @_Z12call_me_lastv(34// NOINLINE-NEXT: ret void35 36// Verify constructor calls are inlined when AlwaysInline is run37// INLINE-NEXT: alloca38// INLINE-NEXT: store i32 1239// INLINE-NEXT: store i32 1340// INLINE-NEXT: %[[HANDLE:.*]] = call target("dx.CBuffer", %"__cblayout_$Globals") @"llvm.dx.resource.handlefromimplicitbinding.tdx.CBuffer_s___cblayout_$Globalsst"(i32 0, i32 0, i32 1, i32 0, ptr @"$Globals.str")41// INLINE-NEXT: store target("dx.CBuffer", %"__cblayout_$Globals") %[[HANDLE]], ptr @"$Globals.cb", align 442// INLINE-NEXT: %0 = call i32 @llvm.dx.flattened.thread.id.in.group()43// INLINE-NEXT: store i32 %44// INLINE-NEXT: store i32 045// INLINE: ret void46