Skip to content

[DNM] cross-repo testing PR #65627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,4 @@ view of the available documentation. In particular, the documents titled
[Debugging the Swift Compiler](docs/DebuggingTheCompiler.md) and
[Continuous Integration for Swift](docs/ContinuousIntegration.md) are very
helpful to understand before submitting your first PR.

9 changes: 3 additions & 6 deletions lib/SILGen/SILGenPoly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6347,13 +6347,10 @@ SILFunction *SILGenModule::getOrCreateCustomDerivativeThunk(
arguments.push_back(indErrorRes.getLValueAddress());
forwardFunctionArguments(thunkSGF, loc, fnRefType, params, arguments);

SubstitutionMap subs = thunk->getForwardingSubstitutionMap();
SILType substFnType = fnRef->getType().substGenericArgs(
M, subs, thunk->getTypeExpansionContext());

// Apply function argument.
auto apply =
thunkSGF.emitApplyWithRethrow(loc, fnRef, substFnType, subs, arguments);
auto apply = thunkSGF.emitApplyWithRethrow(
loc, fnRef, /*substFnType*/ fnRef->getType(),
thunk->getForwardingSubstitutionMap(), arguments);

// Self reordering thunk is necessary if wrt at least two parameters,
// including self.
Expand Down
29 changes: 11 additions & 18 deletions lib/SILOptimizer/Mandatory/Differentiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,15 +906,6 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
traceMessage.c_str(), witness->getOriginalFunction());

assert(witness->isDefinition());
SILFunction *orig = witness->getOriginalFunction();

// We can generate empty JVP / VJP for functions available externally. These
// functions have the same linkage as the original ones sans `external`
// flag. Important exception here hidden_external functions as they are
// serializable but corresponding hidden ones would be not and the SIL
// verifier will fail. Patch `serializeFunctions` for this case.
if (orig->getLinkage() == SILLinkage::HiddenExternal)
serializeFunctions = IsNotSerialized;

// If the JVP doesn't exist, need to synthesize it.
if (!witness->getJVP()) {
Expand All @@ -923,8 +914,9 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
// - Functions with unsupported control flow.
if (context.getASTContext()
.LangOpts.hasFeature(Feature::ForwardModeDifferentiation) &&
(diagnoseNoReturn(context, orig, invoker) ||
diagnoseUnsupportedControlFlow(context, orig, invoker)))
(diagnoseNoReturn(context, witness->getOriginalFunction(), invoker) ||
diagnoseUnsupportedControlFlow(
context, witness->getOriginalFunction(), invoker)))
return true;

// Create empty JVP.
Expand All @@ -941,10 +933,10 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
!witness->getVJP()) {
// JVP and differential generation do not currently support functions with
// multiple basic blocks.
if (orig->size() > 1) {
context.emitNondifferentiabilityError(orig->getLocation().getSourceLoc(),
invoker,
diag::autodiff_jvp_control_flow_not_supported);
if (witness->getOriginalFunction()->size() > 1) {
context.emitNondifferentiabilityError(
witness->getOriginalFunction()->getLocation().getSourceLoc(),
invoker, diag::autodiff_jvp_control_flow_not_supported);
return true;
}
// Emit JVP function.
Expand All @@ -958,7 +950,7 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
"_fatalErrorForwardModeDifferentiationDisabled");
LLVM_DEBUG(getADDebugStream()
<< "Generated empty JVP for "
<< orig->getName() << ":\n"
<< witness->getOriginalFunction()->getName() << ":\n"
<< *jvp);
}
}
Expand All @@ -968,8 +960,9 @@ bool DifferentiationTransformer::canonicalizeDifferentiabilityWitness(
// Diagnose:
// - Functions with no return.
// - Functions with unsupported control flow.
if (diagnoseNoReturn(context, orig, invoker) ||
diagnoseUnsupportedControlFlow(context, orig, invoker))
if (diagnoseNoReturn(context, witness->getOriginalFunction(), invoker) ||
diagnoseUnsupportedControlFlow(
context, witness->getOriginalFunction(), invoker))
return true;

// Create empty VJP.
Expand Down
25 changes: 0 additions & 25 deletions test/AutoDiff/SILGen/nil_coalescing.swift

This file was deleted.