Skip to content

Commit 8263a7c

Browse files
committed
Add AlwaysInline attribute to the generated functions, update tests
1 parent cd28366 commit 8263a7c

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ static void createResourceInitFn(CodeGenModule &CGM, const VarDecl *VD,
551551
llvm::FunctionType::get(CGM.VoidTy, false),
552552
llvm::GlobalValue::InternalLinkage,
553553
("_init_resource_" + VD->getName()).str(), CGM.getModule());
554+
InitResFunc->addFnAttr(llvm::Attribute::AlwaysInline);
554555

555556
llvm::BasicBlock *EntryBB =
556557
llvm::BasicBlock::Create(Ctx, "entry", InitResFunc);

clang/test/CodeGenHLSL/builtins/RWBuffer-constructor-opt.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ void main() {
1111
// CHECK: define void @main()
1212
// CHECK-NEXT: entry:
1313

14-
// CHECK-SPIRV-NEXT: %Buf_h.i = tail call target("spirv.Image", float, 5, 2, 0, 0, 2, 0) @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, i1 false)
15-
// CHECK-SPIRV-NEXT: store target("spirv.Image", float, 5, 2, 0, 0, 2, 0) %Buf_h.i, ptr @Buf, align 8
14+
// CHECK-SPIRV-NEXT: %[[HANDLE:.*]] = tail call target("spirv.Image", float, 5, 2, 0, 0, 2, 0) @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_0t(i32 3, i32 5, i32 1, i32 0, i1 false)
15+
// CHECK-SPIRV-NEXT: store target("spirv.Image", float, 5, 2, 0, 0, 2, 0) %[[HANDLE:.*]], ptr @Buf, align 8
1616

17-
// CHECK-DXIL-NEXT: %Buf_h.i = tail call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0_0t(i32 3, i32 5, i32 1, i32 0, i1 false)
18-
// CHECK-DXIL-NEXT: store target("dx.TypedBuffer", float, 1, 0, 0) %Buf_h.i, ptr @Buf, align 4
17+
// CHECK-DXIL-NEXT: %[[HANDLE:.*]] = tail call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0_0t(i32 3, i32 5, i32 1, i32 0, i1 false)
18+
// CHECK-DXIL-NEXT: store target("dx.TypedBuffer", float, 1, 0, 0) %[[HANDLE]], ptr @Buf, align 4
1919

2020
// CHECK-NEXT: ret void
2121
}

clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RWBuffer<float> Buf : register(u5, space3);
99
// CHECK: %"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", float, 1, 0, 0) }
1010
// CHECK: @Buf = global %"class.hlsl::RWBuffer" zeroinitializer, align 4
1111

12-
// CHECK: define internal void @_init_resource_Buf() {
12+
// CHECK: define internal void @_init_resource_Buf()
1313
// CHECK-DXIL: %Buf_h = call target("dx.TypedBuffer", float, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0_0t(i32 3, i32 5, i32 1, i32 0, i1 false)
1414
// CHECK-DXIL: store target("dx.TypedBuffer", float, 1, 0, 0) %Buf_h, ptr @Buf, align 4
1515

clang/test/CodeGenHLSL/resource-bindings.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil--shadermodel6.6-compute -x hlsl -finclude-default-header -emit-llvm -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -triple dxil--shadermodel6.6-compute -x hlsl -finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
22

33
// CHECK: define internal void @_init_resource_U0S0()
44
// CHECK: %U0S0_h = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0) @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f32_1_0_0t(i32 0, i32 0, i32 1, i32 0, i1 false)

0 commit comments

Comments
 (0)