Skip to content

SILCombine for differential_function creates SIL with invalid ownership when enabling OSSA modules #78848

@eeckstein

Description

@eeckstein

Description

When running the test AutoDiff/validation-test/reabstraction.swift in optimize mode and with sil-verify-all, the compiler crashes with

Begin Error in Function: '$s4mainyycfU7_'
Found over consume?!
Value:   %9 = partial_apply [callee_guaranteed] %8(%3) : $@convention(thin) (@in_guaranteed Float, @guaranteed @callee_guaranteed (Float) -> (Float, @owned @callee_guaranteed (Float) -> Float)) -> (Float, @owned @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed τ_0_0) -> Float for <Float>) // users: %20, %14
User:   %14 = convert_function %9 : $@callee_guaranteed (@in_guaranteed Float) -> (Float, @owned @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed τ_0_0) -> Float for <Float>) to $@callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> (Float, @owned @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed τ_0_0) -> Float for <τ_0_1>) for <Float, Float> // user: %16
Block: bb0
Consuming Users:
  %20 = convert_function %9 : $@callee_guaranteed (@in_guaranteed Float) -> (Float, @owned @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed τ_0_0) -> Float for <Float>) to $@callee_guaranteed (@in_guaranteed Float) -> (Float, @owned @callee_guaranteed (@in_guaranteed Float) -> Float) // user: %22
  %14 = convert_function %9 : $@callee_guaranteed (@in_guaranteed Float) -> (Float, @owned @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed τ_0_0) -> Float for <Float>) to $@callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> (Float, @owned @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed τ_0_0) -> Float for <τ_0_1>) for <Float, Float> // user: %16

Reproduction

  • Enable OSSA modules, e.g. by cherry-picking cb4db5a
  • Enable sil-verify-all, e.g. by
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 2a5a5c7d09e..7e1541556c9 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -2881,7 +2881,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
                    OPT_disable_lifetime_dependence_diagnostics,
                    Opts.EnableLifetimeDependenceDiagnostics);
 
-  Opts.VerifyAll |= Args.hasArg(OPT_sil_verify_all);
+  Opts.VerifyAll = true; // |= Args.hasArg(OPT_sil_verify_all);
   Opts.VerifyNone |= Args.hasArg(OPT_sil_verify_none);
   Opts.VerifyOwnershipAll |= Args.hasArg(OPT_sil_ownership_verify_all);
   Opts.DebugSerialization |= Args.hasArg(OPT_sil_debug_serialization);
  • Run the test AutoDiff/validation-test/reabstraction.swift in optimized mode, e.g. with ninja check-swift-optimize

Expected behavior

no crash

Environment

Additional information

No response

Metadata

Metadata

Assignees

Labels

AutoDiffSIL ownershipArea → compiler → SIL: SIL ownershipSILOptimizerArea → compiler: SIL optimization passesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareswift 6.2

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions