<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/bugs/gh-7905.slang, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-09-23T16:39:39+00:00</updated>
<entry>
<title>Legalize type as well in legalizeOperand (#8483)</title>
<updated>2025-09-23T16:39:39+00:00</updated>
<author>
<name>Gangzheng Tong</name>
<email>tonggangzheng@gmail.com</email>
</author>
<published>2025-09-23T16:39:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d61d6b57dfb0788ebf3449bfde6db288fe4e44a8'/>
<id>urn:sha1:d61d6b57dfb0788ebf3449bfde6db288fe4e44a8</id>
<content type='text'>
This fixes a type mismatch issue. See the generated cuda code

```cuda
struct Query_0
{
    EmptyExample_0 query_0;
    uint hasNonEmptyAbsorbingBoundary_0;
};

struct Query_1
{
    uint hasNonEmptyAbsorbingBoundary_0;
};

struct GlobalParams_0
{
    Query_0* gQuery_0;
    RWStructuredBuffer&lt;float3 &gt; gInput_0;
    RWStructuredBuffer&lt;float&gt; gOutput_0;
};

...
Query_1 _S4 = *globalParams_0-&gt;gQuery_0;      // ==&gt; type mismatch at call site!

```

**Root Cause:** During the empty type legalization pass in Slang's IR
processing, struct types were being optimized. e.g., `Query_0` →
`Query_1` with empty type removed), but this created an inconsistency:

**Function parameters were updated:** When Query_compute_0 function was
legalized, its parameter type was correctly updated from `Query_0` to
the optimized `Query_1`

**Global parameter types were NOT updated:** The
`ParameterBlock&lt;Struct&gt;` type in globalParams still referenced the old
`Query_0` type

The PR adds special handling for type operands in the `legalizeInst`
function. This triggers the legalization of the `StructType` from the
original `legalizeOperand` call site. The leaglized result will be saved
in the type-to-legal-type map and be re-used when the same type requires
legalization again (e.g. in the `IRFunc` as parameter)

Fixes: https://github.com/shader-slang/slang/issues/7905</content>
</entry>
</feed>
