Skip to content

Commit 9c76a29

Browse files
authored
[AutoDiff] Add @differentiable attribute SILGen assertion. (#27650)
Previously, `@differentiable` attribute SILGen lowering was skipped if the attribute did not have resolved parameter indices. This led to unexpected and difficult-to-debug bugs like TF-888. Re-add the assertion for robustness. This is possible after #27613, which fixed the underlying issue with parameter indices resolution.
1 parent 65ebee0 commit 9c76a29

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/SIL/SILFunctionBuilder.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ void SILFunctionBuilder::addFunctionAttributes(SILFunction *F,
8686
for (auto *A : Attrs.getAttributes<DifferentiableAttr>()) {
8787
// Get lowered argument indices.
8888
auto *paramIndices = A->getParameterIndices();
89-
// NOTE: If `A->getParameterIndices()` is `nullptr`, continue. This is a
90-
// necessary hack regarding deserialization.
91-
if (!paramIndices)
92-
continue;
89+
assert(paramIndices && "Parameter indices should have been resolved");
9390
auto *loweredParamIndices = autodiff::getLoweredParameterIndices(
9491
paramIndices, decl->getInterfaceType()->castTo<AnyFunctionType>());
9592
SILAutoDiffIndices indices(/*source*/ 0, loweredParamIndices);

0 commit comments

Comments
 (0)