@@ -906,15 +906,6 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
906
906
traceMessage.c_str (), witness->getOriginalFunction ());
907
907
908
908
assert (witness->isDefinition ());
909
- SILFunction *orig = witness->getOriginalFunction ();
910
-
911
- // We can generate empty JVP / VJP for functions available externally. These
912
- // functions have the same linkage as the original ones sans `external`
913
- // flag. Important exception here hidden_external functions as they are
914
- // serializable but corresponding hidden ones would be not and the SIL
915
- // verifier will fail. Patch `serializeFunctions` for this case.
916
- if (orig->getLinkage () == SILLinkage::HiddenExternal)
917
- serializeFunctions = IsNotSerialized;
918
909
919
910
// If the JVP doesn't exist, need to synthesize it.
920
911
if (!witness->getJVP ()) {
@@ -923,8 +914,9 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
923
914
// - Functions with unsupported control flow.
924
915
if (context.getASTContext ()
925
916
.LangOpts .hasFeature (Feature::ForwardModeDifferentiation) &&
926
- (diagnoseNoReturn (context, orig, invoker) ||
927
- diagnoseUnsupportedControlFlow (context, orig, invoker)))
917
+ (diagnoseNoReturn (context, witness->getOriginalFunction (), invoker) ||
918
+ diagnoseUnsupportedControlFlow (
919
+ context, witness->getOriginalFunction (), invoker)))
928
920
return true ;
929
921
930
922
// Create empty JVP.
@@ -941,10 +933,10 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
941
933
!witness->getVJP ()) {
942
934
// JVP and differential generation do not currently support functions with
943
935
// multiple basic blocks.
944
- if (orig ->size () > 1 ) {
945
- context.emitNondifferentiabilityError (orig-> getLocation (). getSourceLoc (),
946
- invoker ,
947
- diag::autodiff_jvp_control_flow_not_supported);
936
+ if (witness-> getOriginalFunction () ->size () > 1 ) {
937
+ context.emitNondifferentiabilityError (
938
+ witness-> getOriginalFunction ()-> getLocation (). getSourceLoc () ,
939
+ invoker, diag::autodiff_jvp_control_flow_not_supported);
948
940
return true ;
949
941
}
950
942
// Emit JVP function.
@@ -958,7 +950,7 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
958
950
" _fatalErrorForwardModeDifferentiationDisabled" );
959
951
LLVM_DEBUG (getADDebugStream ()
960
952
<< " Generated empty JVP for "
961
- << orig ->getName () << " :\n "
953
+ << witness-> getOriginalFunction () ->getName () << " :\n "
962
954
<< *jvp);
963
955
}
964
956
}
@@ -968,8 +960,9 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
968
960
// Diagnose:
969
961
// - Functions with no return.
970
962
// - Functions with unsupported control flow.
971
- if (diagnoseNoReturn (context, orig, invoker) ||
972
- diagnoseUnsupportedControlFlow (context, orig, invoker))
963
+ if (diagnoseNoReturn (context, witness->getOriginalFunction (), invoker) ||
964
+ diagnoseUnsupportedControlFlow (
965
+ context, witness->getOriginalFunction (), invoker))
973
966
return true ;
974
967
975
968
// Create empty VJP.
0 commit comments