Skip to content
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

AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift run with sil-verify-all fails verification after SILCombine #73435

Open
nate-chandler opened this issue May 3, 2024 · 0 comments
Assignees
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SILOptimizer Area → compiler: SIL optimization passes

Comments

@nate-chandler
Copy link
Contributor

Description

A run of the test after applying the following diff

diff --git a/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift b/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift
index df0e35d0e12..f6498c0b008 100644
--- a/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift
+++ b/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -emit-sil -O -g %s | %FileCheck %s
+// RUN: %target-swift-frontend -sil-verify-all -emit-sil -O -g %s | %FileCheck %s

 // REQUIRES: swift_in_compiler

results in

SIL verification failed: Operand of release must have reference semantics: value->getType().isReferenceCounted(F.getModule()) || value->getType().isForeignReferenceType()
Verifying instruction:
   %1 = argument of bb0 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // users: %6, %10, %15, %5, %13, %14, %3
->   strong_release %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // id: %6
In function:
// specialized valueWithPullback<A>(at:of:)
sil shared @$s4main17valueWithPullback2at2ofyt0B0_y13TangentVectorQzzc8pullbacktx_yxzYjrXEt16_Differentiation14DifferentiableRzlFSd_Tg5 : $@convention(thin) (Double, @guaranteed @differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double>) -> @owned @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> {
// %0 "x"                                         // users: %8, %2
// %1 "f"                                         // users: %6, %10, %15, %5, %13, %14, %3
bb0(%0 : $Double, %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double>):
  debug_value %0 : $Double, let, name "x", argno 1 // id: %2
  debug_value %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double>, let, name "f", argno 2 // id: %3
  // function_ref specialized reverse-mode derivative of nonInoutWrappingFunction #1 <A>(_:) in valueWithPullback<A>(at:of:)
  %4 = function_ref @$s4main17valueWithPullback2at2ofyt0B0_y13TangentVectorQzzc8pullbacktx_yxzYjrXEt16_Differentiation14DifferentiableRzlF24nonInoutWrappingFunctionL_yxxAiJRzlFAiJRzlTJrSUpSrSd_TG5 : $@convention(thin) (@in_guaranteed Double, @guaranteed @differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double>) -> (@out Double, @owned @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for <Double, Double>) // user: %10
  retain_value %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // id: %5
  strong_release %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // id: %6
  %7 = alloc_stack $Double                        // users: %10, %12, %8
  store %0 to %7 : $*Double                       // id: %8
  %9 = alloc_stack $Double                        // users: %10, %11
  %10 = apply %4(%9, %7, %1) : $@convention(thin) (@in_guaranteed Double, @guaranteed @differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double>) -> (@out Double, @owned @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for <Double, Double>) // users: %16, %18
  dealloc_stack %9 : $*Double                     // id: %11
  dealloc_stack %7 : $*Double                     // id: %12
  strong_release %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // id: %13
  strong_release %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // id: %14
  strong_release %1 : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // id: %15
  debug_value %10 : $@callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for <Double, Double>, let, name "nonInoutPullback" // id: %16
  // function_ref specialized closure #1 in valueWithPullback<A>(at:of:)
  %17 = function_ref @$s4main17valueWithPullback2at2ofyt0B0_y13TangentVectorQzzc8pullbacktx_yxzYjrXEt16_Differentiation14DifferentiableRzlFyAGzcfU_Sd_Tg5 : $@convention(thin) (@inout Double, @guaranteed @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for <Double, Double>) -> () // user: %18
  %18 = partial_apply [callee_guaranteed] %17(%10) : $@convention(thin) (@inout Double, @guaranteed @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for <Double, Double>) -> () // user: %19
  %19 = convert_function %18 : $@callee_guaranteed (@inout Double) -> () to $@callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // user: %20
  return %19 : $@callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // id: %20
} // end sil function '$s4main17valueWithPullback2at2ofyt0B0_y13TangentVectorQzzc8pullbacktx_yxzYjrXEt16_Differentiation14DifferentiableRzlFSd_Tg5'

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: 
1.      Swift version 6.0-dev (LLVM 43f499658077b0d, Swift 6fdaea514fd621f)
2.      Compiling with effective version 4.1.50
3.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for main)
4.      While running pass #9595 SILFunctionTransform "SILCombine" on SILFunction "@$s4main17valueWithPullback2at2ofyt0B0_y13TangentVectorQzzc8pullbacktx_yxzYjrXEt16_Differentiation14DifferentiableRzlFSd_Tg5".
 for 'valueWithPullback(at:of:)' (at /Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/swift/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift:19:8)
5.      While verifying SIL function "@$s4main17valueWithPullback2at2ofyt0B0_y13TangentVectorQzzc8pullbacktx_yxzYjrXEt16_Differentiation14DifferentiableRzlFSd_Tg5".
 for 'valueWithPullback(at:of:)' (at /Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/swift/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift:19:8)
 #0 0x0000000106017a40 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x105a0ba40)
 #1 0x0000000106015df8 llvm::sys::RunSignalHandlers() (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x105a09df8)
 #2 0x00000001060180d4 SignalHandler(int) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x105a0c0d4)
 #3 0x0000000188f86a24 (/usr/lib/system/libsystem_platform.dylib+0x18042ea24)
 #4 0x0000000188f57c28 (/usr/lib/system/libsystem_pthread.dylib+0x1803ffc28)
 #5 0x0000000188e65ae8 (/usr/lib/system/libsystem_c.dylib+0x18030dae8)
 #6 0x0000000101718164 swift::SILModule::print(llvm::raw_ostream&, swift::ModuleDecl*, swift::SILOptions const&, bool) const (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x10110c164)
 #7 0x0000000101736c58 (anonymous namespace)::SILVerifier::requireReferenceValue(swift::SILValue, llvm::Twine const&) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x10112ac58)
 #8 0x000000010171fd88 swift::SILVisitorBase<(anonymous namespace)::SILVerifier, void>::visitSILBasicBlock(swift::SILBasicBlock*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x101113d88)
 #9 0x000000010171c200 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x101110200)
#10 0x000000010171ace0 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x10110ece0)
#11 0x00000001017146e4 swift::SILFunction::verify(swift::CalleeCache*, bool, bool, bool) const (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x1011086e4)
#12 0x00000001011c6e18 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bbae18)
#13 0x00000001011c7808 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bbb808)
#14 0x00000001011c48cc swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bb88cc)
#15 0x00000001011c4868 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bb8868)
#16 0x00000001011ff4f4 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bf34f4)
#17 0x00000001011df890 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bd3890)
#18 0x00000001011c4aa8 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bb8aa8)
#19 0x00000001011e1f44 swift::runSILOptimizationPasses(swift::SILModule&) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100bd5f44)
#20 0x0000000100a54180 swift::CompilerInstance::performSILProcessing(swift::SILModule*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100448180)
#21 0x0000000100812758 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100206758)
#22 0x00000001008120d4 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x1002060d4)
#23 0x0000000100822e08 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100216e08)
#24 0x0000000100814430 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100208430)
#25 0x0000000100813414 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x100207414)
#26 0x00000001006451e0 swift::mainEntry(int, char const**) (/Volumes/ams1_ext3/Source/Open/Apple/swift/maintain_5/build/silopt-stdlib/swift-macosx-arm64/bin/swift-frontend+0x1000391e0)
#27 0x0000000188bfff28

Reproduction

Enable sil-verify-all in the test via, for example

diff --git a/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift b/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift
index df0e35d0e12..f6498c0b008 100644
--- a/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift
+++ b/test/AutoDiff/compiler_crashers_fixed/issue-62608-conflicting-debug-info.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -emit-sil -O -g %s | %FileCheck %s
+// RUN: %target-swift-frontend -sil-verify-all -emit-sil -O -g %s | %FileCheck %s

 // REQUIRES: swift_in_compiler

Expected behavior

Valid SIL out of SILCombine

Environment

Recent main. Specifically 6fdaea514fd621f62a56afb4ff1ce39f8bf77b31.

Additional information

No response

@nate-chandler nate-chandler added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SILOptimizer Area → compiler: SIL optimization passes AutoDiff triage needed This issue needs more specific labels and removed triage needed This issue needs more specific labels labels May 3, 2024
@asl asl self-assigned this May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SILOptimizer Area → compiler: SIL optimization passes
Projects
None yet
Development

No branches or pull requests

2 participants