Skip to content

Commit

Permalink
Fix resource specialization issue where store insts from inlined call…
Browse files Browse the repository at this point in the history
…s are not considered properly. (#6099)

* Fix resource specialization issue where stores from inlined calls are not considered.

* Format
  • Loading branch information
saipraveenb25 authored Jan 17, 2025
1 parent d3ad6bb commit 1b7c242
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions source/slang/slang-ir-specialize-resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,21 +910,17 @@ struct ResourceOutputSpecializationPass
//
SpecializeFuncResult recursiveSpecializationResult = SpecializeFuncResult::Ok;
List<IRStore*> stores;

// We'll first specialize any relevant calls that may affect the value stored into the
// param. This may create more stores into the param.
//
traverseUses(
param,
[&](IRUse* use)
{
auto user = use->getUser();
switch (user->getOp())
{
case kIROp_Store:
{
auto store = as<IRStore>(user);
if (store->ptr.get() != param)
return;
stores.add(store);
return;
}
case kIROp_Call:
{
// This call may require an inline if it fails to specialize
Expand All @@ -942,9 +938,33 @@ struct ResourceOutputSpecializationPass
return;
};
});

// If any call specialization fails, we may need to revisit this function at a later
// iteration.
if (failedResult(recursiveSpecializationResult))
return recursiveSpecializationResult;

// Then, traverse all stores into this param.
traverseUses(
param,
[&](IRUse* use)
{
auto user = use->getUser();
switch (user->getOp())
{
case kIROp_Store:
{
auto store = as<IRStore>(user);
if (store->ptr.get() != param)
return;
stores.add(store);
return;
}
default:
return;
};
});

// Having identified the places where a value is stored to
// the output parameter, we iterate over those values to
// ensure that they are all specializable and consistent
Expand Down

0 comments on commit 1b7c242

Please sign in to comment.