10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
//
13
- // Devirtualized differentiability witnesses whose bodies are availabe, by
14
- // turning "differentiability_witness_function" instructions into "function_ref"
15
- // instructions referencing the appropriate function.
13
+ // Devirtualizes `differentiability_witness_function` instructions into
14
+ // `function_ref` instructions for differentiability witness definitions.
16
15
//
17
16
// ===----------------------------------------------------------------------===//
18
17
@@ -26,7 +25,7 @@ using namespace swift;
26
25
namespace {
27
26
class DifferentiabilityWitnessDevirtualizer : public SILFunctionTransform {
28
27
29
- // / Returns true if and changes were made.
28
+ // / Returns true if any changes were made.
30
29
bool devirtualizeDifferentiabilityWitnessesInFunction (SILFunction &f);
31
30
32
31
// / The entry point to the transformation.
@@ -50,17 +49,17 @@ bool DifferentiabilityWitnessDevirtualizer::
50
49
}
51
50
}
52
51
for (auto *inst : insts) {
53
- auto *wit = inst->getWitness ();
54
- if (wit ->isDeclaration ())
55
- f.getModule ().loadDifferentiabilityWitness (wit );
56
- if (wit ->isDeclaration ())
52
+ auto *witness = inst->getWitness ();
53
+ if (witness ->isDeclaration ())
54
+ f.getModule ().loadDifferentiabilityWitness (witness );
55
+ if (witness ->isDeclaration ())
57
56
continue ;
58
57
changed = true ;
59
58
SILBuilderWithScope builder (inst);
60
59
auto kind = inst->getWitnessKind ().getAsDerivativeFunctionKind ();
61
60
assert (kind.hasValue ());
62
61
auto *newInst = builder.createFunctionRefFor (inst->getLoc (),
63
- wit ->getDerivative (*kind));
62
+ witness ->getDerivative (*kind));
64
63
inst->replaceAllUsesWith (newInst);
65
64
inst->getParent ()->erase (inst);
66
65
}
0 commit comments