Skip to content

Commit f64718d

Browse files
authored
[ParseSIL] Fix [differentiable] attribute where clause parsing. (#24792)
Follow-up to #24762. Fix `test/AutoDiff/differentiable_sil_attr.sil` to actually test where clause parsing. Fix SIL requirement parsing. Friend PR to master: #24790
1 parent e941adc commit f64718d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/ParseSIL/ParseSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,8 @@ void SILParser::convertRequirements(SILFunction *F,
953953
}
954954

955955
if (Req.getKind() == RequirementReprKind::TypeConstraint) {
956-
auto FirstType = ResolveToInterfaceType(Req.getFirstTypeLoc());
957-
auto SecondType = ResolveToInterfaceType(Req.getSecondTypeLoc());
956+
auto FirstType = ResolveToInterfaceType(Req.getSubjectLoc());
957+
auto SecondType = ResolveToInterfaceType(Req.getConstraintLoc());
958958
Requirement ConvertedRequirement(RequirementKind::Conformance, FirstType,
959959
SecondType);
960960
To.push_back(ConvertedRequirement);

test/AutoDiff/differentiable_sil_attr.sil

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ entry(%0: $Float, %1: $Float):
1616
return undef: $(Float, (Float) -> (Float, Float))
1717
}
1818

19-
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 vjp @foo_vjp] @foo
20-
sil [differentiable source 0 wrt 0, 1 vjp @foo_vjp] @foo : $@convention(thin) <T, U, V> (@in_guaranteed T, @in_guaranteed U, @in_guaranteed V) -> @out V {
19+
// CHECK-LABEL: sil [differentiable source 0 wrt 0, 1 vjp @foo_vjp where T : Differentiable, U : Differentiable, V : Differentiable] @foo
20+
sil [differentiable source 0 wrt 0, 1 vjp @foo_vjp where T : Differentiable, U : Differentiable, V : Differentiable] @foo : $@convention(thin) <T, U, V> (@in_guaranteed T, @in_guaranteed U, @in_guaranteed V) -> @out V {
2121
entry(%0 : $*V, %1 : $*T, %2 : $*U, %3 : $*V):
2222
return undef: $()
2323
}
2424

25-
sil @$foo_vjp : $@convention(thin) <T, U, V> (@in_guaranteed T, @in_guaranteed U, @in_guaranteed V) -> (@out V, @owned @callee_guaranteed (@in_guaranteed V) -> (@out T, @out U)) {
26-
// %1 // user: %4
27-
// %2 // user: %5
28-
// %3 // user: %6
25+
sil @foo_vjp : $@convention(thin) <T, U, V where T : Differentiable, U : Differentiable, V : Differentiable> (@in_guaranteed T, @in_guaranteed U, @in_guaranteed V) -> (@out V, @owned @callee_guaranteed (@in_guaranteed V) -> (@out T, @out U)) {
2926
bb0(%0 : $*V, %1 : $*T, %2 : $*U, %3 : $*V):
3027
return undef: $@callee_guaranteed (@in_guaranteed V) -> (@out T, @out U)
3128
}

0 commit comments

Comments
 (0)