@@ -1861,6 +1861,7 @@ IRInst* DifferentiableTypeConformanceContext::buildDifferentiablePairWitness(
1861
1861
sharedContext->differentiableInterfaceType ,
1862
1862
(IRType*)pairType);
1863
1863
1864
+ // Add WitnessTableEntry only once
1864
1865
if (table->getFirstDecorationOrChild () == nullptr )
1865
1866
{
1866
1867
// And place it in the synthesized witness table.
@@ -1946,6 +1947,7 @@ IRInst* DifferentiableTypeConformanceContext::buildDifferentiablePairWitness(
1946
1947
sharedContext->differentiablePtrInterfaceType ,
1947
1948
(IRType*)pairType);
1948
1949
1950
+ // Add WitnessTableEntry only once
1949
1951
if (table->getFirstDecorationOrChild () == nullptr )
1950
1952
{
1951
1953
// And place it in the synthesized witness table.
@@ -1992,6 +1994,7 @@ IRInst* DifferentiableTypeConformanceContext::buildArrayWitness(
1992
1994
sharedContext->differentiableInterfaceType ,
1993
1995
(IRType*)arrayType);
1994
1996
1997
+ // Add WitnessTableEntry only once
1995
1998
if (table->getFirstDecorationOrChild () == nullptr )
1996
1999
{
1997
2000
// And place it in the synthesized witness table.
@@ -2074,6 +2077,7 @@ IRInst* DifferentiableTypeConformanceContext::buildArrayWitness(
2074
2077
sharedContext->differentiablePtrInterfaceType ,
2075
2078
(IRType*)arrayType);
2076
2079
2080
+ // Add WitnessTableEntry only once
2077
2081
if (table->getFirstDecorationOrChild () == nullptr )
2078
2082
{
2079
2083
// And place it in the synthesized witness table.
@@ -2118,6 +2122,7 @@ IRInst* DifferentiableTypeConformanceContext::buildTupleWitness(
2118
2122
sharedContext->differentiableInterfaceType ,
2119
2123
(IRType*)inTupleType);
2120
2124
2125
+ // Add WitnessTableEntry only once
2121
2126
if (table->getFirstDecorationOrChild () == nullptr )
2122
2127
{
2123
2128
// And place it in the synthesized witness table.
@@ -2234,6 +2239,7 @@ IRInst* DifferentiableTypeConformanceContext::buildTupleWitness(
2234
2239
sharedContext->differentiablePtrInterfaceType ,
2235
2240
(IRType*)inTupleType);
2236
2241
2242
+ // Add WitnessTableEntry only once
2237
2243
if (table->getFirstDecorationOrChild () == nullptr )
2238
2244
{
2239
2245
// And place it in the synthesized witness table.
@@ -3096,6 +3102,7 @@ struct AutoDiffPass : public InstPassBase
3096
3102
builder.createWitnessTable (autodiffContext->differentiableInterfaceType , originalType);
3097
3103
result.diffWitness = origTypeIsDiffWitness;
3098
3104
3105
+ // Add WitnessTableEntry only once
3099
3106
if (origTypeIsDiffWitness->getFirstDecorationOrChild () == nullptr )
3100
3107
{
3101
3108
builder.createWitnessTableEntry (
@@ -3116,6 +3123,7 @@ struct AutoDiffPass : public InstPassBase
3116
3123
addMethod);
3117
3124
}
3118
3125
3126
+ // Add WitnessTableEntry only once
3119
3127
if (diffTypeIsDiffWitness->getFirstDecorationOrChild () == nullptr )
3120
3128
{
3121
3129
builder.createWitnessTableEntry (
@@ -3212,6 +3220,7 @@ struct AutoDiffPass : public InstPassBase
3212
3220
auto witnessTableType = innerResult.diffWitness ->getFullType ();
3213
3221
auto newWitnessTable = builder.createWitnessTable (witnessTableType, concreteType);
3214
3222
3223
+ // Add WitnessTableEntry only once
3215
3224
if (newWitnessTable->getFirstDecorationOrChild () == nullptr )
3216
3225
{
3217
3226
builder.setInsertInto (newWitnessTable);
0 commit comments