Skip to content

Commit 4386eeb

Browse files
committed
Fix mis-named variable that was not edited appropriately after
a copy-paste. Add necessary function attributes to tests and remove unnecessary check for mumber of entries for non-library shaders in createEntryMD()
1 parent 78b39b3 commit 4386eeb

File tree

3 files changed

+29
-33
lines changed

3 files changed

+29
-33
lines changed

llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -242,26 +242,24 @@ static void createEntryMD(Module &M, const uint64_t ShaderFlags,
242242
// EntryPro.Entry is 0.
243243
ShaderEntryMDInfo SEP(EntryProp, Ctx, MDAnalysisInfo.ShaderProfile,
244244
nullptr, 0);
245-
MDTuple *EmptyMDT = SEP.getAsMetadata();
246-
EntryFnMDNodes.emplace_back(EmptyMDT);
245+
MDTuple *MDT = SEP.getAsMetadata();
246+
EntryFnMDNodes.emplace_back(MDT);
247247
}
248248
} break;
249249
case Triple::EnvironmentType::Compute: {
250250
size_t NumEntries = MDAnalysisInfo.EntryPropertyVec.size();
251-
if (NumEntries > 0) {
252-
assert(NumEntries == 1 &&
253-
"Compute shader: One and only one entry expected");
254-
EntryProperties EntryProp = MDAnalysisInfo.EntryPropertyVec[0];
255-
// ShaderFlagsAnalysis pass needs to collect and provide ShaderFlags for
256-
// each entry function. Currently, even though the ShaderFlags value
257-
// provided by ShaderFlagsAnalysis pass is created by walking all the
258-
// function instructions of the module, it is sufficient to since there is
259-
// only one entry function in the module.
260-
ShaderEntryMDInfo SEP(EntryProp, Ctx, MDAnalysisInfo.ShaderProfile,
261-
MDResources, ShaderFlags);
262-
MDTuple *EmptyMDT = SEP.getAsMetadata();
263-
EntryFnMDNodes.emplace_back(EmptyMDT);
264-
}
251+
assert(NumEntries == 1 &&
252+
"Compute shader: One and only one entry expected");
253+
EntryProperties EntryProp = MDAnalysisInfo.EntryPropertyVec[0];
254+
// ShaderFlagsAnalysis pass needs to collect and provide ShaderFlags for
255+
// each entry function. Currently, even though the ShaderFlags value
256+
// provided by ShaderFlagsAnalysis pass is created by walking all the
257+
// function instructions of the module, it is sufficient to since there is
258+
// only one entry function in the module.
259+
ShaderEntryMDInfo SEP(EntryProp, Ctx, MDAnalysisInfo.ShaderProfile,
260+
MDResources, ShaderFlags);
261+
MDTuple *MDT = SEP.getAsMetadata();
262+
EntryFnMDNodes.emplace_back(MDT);
265263
break;
266264
}
267265
case Triple::EnvironmentType::Amplification:
@@ -272,19 +270,17 @@ static void createEntryMD(Module &M, const uint64_t ShaderFlags,
272270
case Triple::EnvironmentType::Geometry:
273271
case Triple::EnvironmentType::Pixel: {
274272
size_t NumEntries = MDAnalysisInfo.EntryPropertyVec.size();
275-
if (NumEntries > 0) {
276-
assert(NumEntries == 1 && "non-lib profiles should only have one entry");
277-
EntryProperties EntryProp = MDAnalysisInfo.EntryPropertyVec[0];
278-
// ShaderFlagsAnalysis pass needs to collect and provide ShaderFlags for
279-
// each entry function. Currently, even though the ShaderFlags value
280-
// provided by ShaderFlagsAnalysis pass is created by walking all the
281-
// function instructions of the module, it is sufficient to since there is
282-
// only one entry function in the module.
283-
ShaderEntryMDInfo SEP(EntryProp, Ctx, MDAnalysisInfo.ShaderProfile,
284-
MDResources, ShaderFlags);
285-
MDTuple *EmptyMDT = SEP.getAsMetadata();
286-
EntryFnMDNodes.emplace_back(EmptyMDT);
287-
}
273+
assert(NumEntries == 1 && "non-lib profiles should only have one entry");
274+
EntryProperties EntryProp = MDAnalysisInfo.EntryPropertyVec[0];
275+
// ShaderFlagsAnalysis pass needs to collect and provide ShaderFlags for
276+
// each entry function. Currently, even though the ShaderFlags value
277+
// provided by ShaderFlagsAnalysis pass is created by walking all the
278+
// function instructions of the module, it is sufficient to since there is
279+
// only one entry function in the module.
280+
ShaderEntryMDInfo SEP(EntryProp, Ctx, MDAnalysisInfo.ShaderProfile,
281+
MDResources, ShaderFlags);
282+
MDTuple *MDT = SEP.getAsMetadata();
283+
EntryFnMDNodes.emplace_back(MDT);
288284
} break;
289285
default:
290286
assert(0 && "invalid profile");

llvm/test/CodeGen/DirectX/CreateHandle.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ target triple = "dxil-pc-shadermodel6.0-compute"
1414

1515
declare i32 @some_val();
1616

17-
define void @test_buffers() {
17+
define void @test_buffers() #0 {
1818
; RWBuffer<float4> Buf : register(u5, space3)
1919
%typed0 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
2020
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0(
@@ -68,4 +68,4 @@ define void @test_buffers() {
6868
; CHECK-DAG: [[SRVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
6969
; CHECK-DAG: [[UAVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}}
7070

71-
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
71+
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) "hlsl.numthreads"="1,2,1" "hlsl.shader"="compute"}

llvm/test/CodeGen/DirectX/CreateHandleFromBinding.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ target triple = "dxil-pc-shadermodel6.6-compute"
1414

1515
declare i32 @some_val();
1616

17-
define void @test_bindings() {
17+
define void @test_bindings() #0 {
1818
; RWBuffer<float4> Buf : register(u5, space3)
1919
%typed0 = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
2020
@llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0(
@@ -73,4 +73,4 @@ define void @test_bindings() {
7373
; CHECK-DAG: [[SRVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
7474
; CHECK-DAG: [[UAVMD]] = !{!{{[0-9]+}}, !{{[0-9]+}}}
7575

76-
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
76+
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) "hlsl.numthreads"="1,2,1" "hlsl.shader"="compute"}

0 commit comments

Comments
 (0)