From c1f69ca1e29811919dbd2f08a6e2dd498b80aab2 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Wed, 2 Apr 2025 12:34:58 -0500 Subject: Metal remove void field (#6725) * Reapply "Eliminate empty struct on metal target (#6603)" (#6711) This reverts commit bc9dc6557fc0cc3a4c0c2ff27e636940e361cf5d. * Remove argument in make_struct call corresponding to void field This is a follow-up of #6543, where we leave the VoidType field as it in make_struct call during legalization pass. So during cleaning_void IR pass, when we remove "VoidType" from struct, we will have to also clean up the argument corresponding to the "VoidType" field. --- tests/metal/empty-struct-remove.slang | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/metal/empty-struct-remove.slang (limited to 'tests') diff --git a/tests/metal/empty-struct-remove.slang b/tests/metal/empty-struct-remove.slang new file mode 100644 index 000000000..5ac1ccb69 --- /dev/null +++ b/tests/metal/empty-struct-remove.slang @@ -0,0 +1,33 @@ + +//TEST:SIMPLE(filecheck=LIB):-target metallib -entry computeMain -stage compute +//TEST:SIMPLE(filecheck=METAL):-target metal -entry computeMain -stage compute + +// METAL-NOT: struct emptyStruct +struct emptyStruct +{ + void set(RWStructuredBuffer buffer, int value) {buffer[0] = value;} +} + + +struct MyStruct +{ + RWStructuredBuffer buffer; + int value; + void set() + { + e.set(buffer, value); + } + emptyStruct e; +} + +ParameterBlock param; + +// LIB: @computeMain +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain( + uint tid: SV_DispatchThreadID, +) +{ + param.set(); +} -- cgit v1.2.3