Skip to content

Commit 73304dc

Browse files
committed
Update the comments
1 parent df29854 commit 73304dc

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

source/slang/slang-ir-specialize.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -3123,13 +3123,18 @@ IRInst* specializeGenericImpl(
31233123
//
31243124
IRInstList<IRInst> ordinaryInsts = bb->getOrdinaryInsts();
31253125

3126-
// After IRWitnessTable became Hoistable, they are removed and insered back by
3126+
// After IRWitnessTable became Hoistable, they are removed and inserted back by
31273127
// `addHoistableInst()`. But when they are re-inserted, the order it appears in the block is
3128-
// changed. When IRWitnessTable refers to IRSpecialize, as an example, IRSpecialize must be
3128+
// changed. We need to change the order in a way that the dependancy is resolved.
3129+
//
3130+
// The dependency cannot be resolve in `addHoistableInst()`, because IRWitnessTable doesn't
3131+
// have IRWitnessTableEntry yet while in the function.
3132+
//
3133+
// When IRWitnessTable refers to IRSpecialize, as an example, IRSpecialize must be
31293134
// cloned before the cloning of IRWitnessTable. It is because the operands are assumed to be
31303135
// cloned before the cloning of IRInst.
31313136
//
3132-
// We need to resolve the dependency problem by changing the order of them.
3137+
// Similarly, there can be dependencies between an IRWitnessTable and another IRWitnessTable.
31333138
//
31343139
List<IRInst*> insts;
31353140
int instCount = 0;

source/slang/slang-lower-to-ir.cpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -8016,12 +8016,9 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
80168016
irWitnessTableBaseType,
80178017
irWitnessTable->getConcreteType());
80188018

8019-
// TODO: When WitnessTable became HOISTABLE, we needed a way to avoid
8020-
// adding the same decorations and childrens redundantly.
8021-
// There isn't an easy way to tell if the returned WitnessTable is a
8022-
// brand new or a found one from the existing pool.
8023-
// The code below assumes that when there are any decoration or child,
8024-
// it is a pre-existed one.
8019+
// Since IRWitnessTable is Hoistable, `createWitnessTable()` may return a
8020+
// pre-existing one. We need to avoid adding the same decorations/children
8021+
// when the IRWitnessTable already has them.
80258022
//
80268023
if (irSatisfyingWitnessTable->getFirstDecorationOrChild() == nullptr)
80278024
{
@@ -8167,12 +8164,9 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
81678164
// Create the IR-level witness table
81688165
auto irWitnessTable = subBuilder->createWitnessTable(irWitnessTableBaseType, irSubType);
81698166

8170-
// TODO: When WitnessTable became HOISTABLE, we needed a way to avoid
8171-
// adding the same decorations and childrens redundantly.
8172-
// There isn't an easy way to tell if the returned WitnessTable is a
8173-
// brand new or a found one from the existing pool.
8174-
// The code below assumes that when there are any decoration or child,
8175-
// it is a pre-existed one.
8167+
// Since IRWitnessTable is Hoistable, `createWitnessTable()` may return a
8168+
// pre-existing one. We need to avoid adding the same decorations/children
8169+
// when the IRWitnessTable already has them.
81768170
//
81778171
if (irWitnessTable->getFirstDecorationOrChild() == nullptr)
81788172
{

0 commit comments

Comments
 (0)