Skip to content

Commit 6812245

Browse files
Generate IDs for every witness table (shader-slang#6129)
Co-authored-by: Yong He <yonghe@outlook.com>
1 parent b11c257 commit 6812245

File tree

1 file changed

+7
-52
lines changed

1 file changed

+7
-52
lines changed

source/slang/slang-ir-specialize-dispatch.cpp

+7-52
Original file line numberDiff line numberDiff line change
@@ -177,39 +177,6 @@ IRFunc* specializeDispatchFunction(
177177
return newDispatchFunc;
178178
}
179179

180-
// Returns true if the witness table is transitively referenced through a witness table with
181-
// linkage.
182-
bool _isWitnessTableTransitivelyVisible(IRInst* witness)
183-
{
184-
if (witness->findDecoration<IRLinkageDecoration>())
185-
return true;
186-
187-
OrderedHashSet<IRInst*> workSet;
188-
List<IRInst*> workList;
189-
workList.add(witness);
190-
for (int i = 0; i < workList.getCount(); i++)
191-
{
192-
auto item = workList[i];
193-
if (item->findDecoration<IRLinkageDecoration>())
194-
return true;
195-
for (auto use = item->firstUse; use; use = use->nextUse)
196-
{
197-
auto user = use->getUser();
198-
if (user->getOp() == kIROp_WitnessTableEntry)
199-
{
200-
if (user->getParent())
201-
{
202-
if (workSet.add(user->getParent()))
203-
{
204-
workList.add(user->getParent());
205-
}
206-
}
207-
}
208-
}
209-
}
210-
return false;
211-
}
212-
213180
// Ensures every witness table object has been assigned a sequential ID.
214181
// All witness tables will have a SequentialID decoration after this function is run.
215182
// The sequantial ID in the decoration will be the same as the one specified in the Linkage.
@@ -242,27 +209,15 @@ void ensureWitnessTableSequentialIDs(SharedGenericsLoweringContext* sharedContex
242209
continue;
243210
}
244211

245-
// If this witness table entry does not have a linkage,
246-
// we need to check if it is transitively visible via
247-
// associatedtypes from an existing witness table with linkage.
248-
// If so we still need to include this witness talbe, otherwise
249-
// don't assign sequential ID for it.
250-
if (_isWitnessTableTransitivelyVisible(inst))
212+
// generate a unique linkage for it.
213+
static int32_t uniqueId = 0;
214+
uniqueId++;
215+
if (auto nameHint = inst->findDecoration<IRNameHintDecoration>())
251216
{
252-
// generate a unique linkage for it.
253-
static int32_t uniqueId = 0;
254-
uniqueId++;
255-
if (auto nameHint = inst->findDecoration<IRNameHintDecoration>())
256-
{
257-
generatedMangledName << nameHint->getName();
258-
}
259-
generatedMangledName << "_generated_witness_uuid_" << uniqueId;
260-
witnessTableMangledName = generatedMangledName.getUnownedSlice();
261-
}
262-
else
263-
{
264-
continue;
217+
generatedMangledName << nameHint->getName();
265218
}
219+
generatedMangledName << "_generated_witness_uuid_" << uniqueId;
220+
witnessTableMangledName = generatedMangledName.getUnownedSlice();
266221
}
267222

268223
// If the inst already has a SequentialIDDecoration, stop now.

0 commit comments

Comments
 (0)