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

SIL verification failed: Should not have an operand for the opened existential: AMI->getTypeDependentOperands().empty() #77955

Closed
hjyamauchi opened this issue Dec 4, 2024 · 8 comments
Labels
assertion failure Bug → crash: An assertion failure bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software opaque result types Feature → types → opaque types: opaque result types opaque types Feature → types: opaque types SIL verifier

Comments

@hjyamauchi
Copy link
Contributor

hjyamauchi commented Dec 4, 2024

Description

https://ci-external.swift.org/job/swift-main-windows-toolchain/867/consoleText

Reproduction

A build failure on the CI.

Also, a reduced test:

% cat crasher.swift 
struct A {}

protocol P {}
extension P {
    func foo() -> some Sequence<A> {
        EmptyCollection<A>()
    }
}

struct B {
    let p: P
    func bar() {
        for x in p.foo() {}
    }
}
% ~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/bin/swiftc -O ~/tmp/crasher.swift
error: compile command failed due to signal 6 (use -v to see invocation)
SIL verification failed: Should not have an operand for the opened existential: AMI->getTypeDependentOperands().empty()
Verifying instruction:
     %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self // users: %12, %8, %8, %7
->   %12 = witness_method $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self>, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %4 : $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %4; user: %14
     %14 = apply %12<@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
In function:
// B.bar()
// Isolation: unspecified
sil hidden @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[%0: noescape **]
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %21, %29, %28, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self // users: %12, %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // users: %18, %14, %13, %11, %10
  %10 = alloc_stack $@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self>, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %4 : $*@opened("FBD4C218-B28D-11EF-81E3-BAEE63F10E7B", any P) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %4; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  %18 = witness_method $@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self.Iterator, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %9 : $*@opened("FBD4C632-B28D-11EF-81E3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %9; user: %22
  br bb1                                          // id: %19

bb1:                                              // Preds: bb2 bb0
  %20 = alloc_stack $Optional<A>                  // users: %23, %24, %22
  %21 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("FBD4C9E8-B28D-11EF-81E3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22
  %22 = apply %18<@opened("FBD4C9E8-B28D-11EF-81E3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%20, %21) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %21
  %23 = load %20 : $*Optional<A>                  // user: %25
  dealloc_stack %20 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

bb2(%26 : $A):                                    // Preds: bb1
  br bb1                                          // id: %27

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %28
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %29
  %30 = tuple ()                                  // user: %31
  return %30 : $()                                // id: %31
} // end sil function '$s7crasher1BV3baryyF'

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/hiroshi/tmp/crasher.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -color-diagnostics -O -empty-abi-descriptor -resource-dir /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift -module-name crasher -in-process-plugin-server-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -o /var/folders/ww/kxcj3hm12kd92gcwr9t3y7k40000gq/T/TemporaryDirectory.WYwECW/crasher-1.o
1.	Apple Swift version 6.1-dev (LLVM 0f86f354a7bc883, Swift d3064c5fc64ba06)
2.	Compiling with effective version 5.10
3.	While verifying SIL function "@$s7crasher1BV3baryyF".
 for 'bar()' (at /Users/hiroshi/tmp/crasher.swift:12:5)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001063112e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010630f9cc llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106311944 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018e1f6584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018e1c5c20 pthread_kill + 288
5  libsystem_c.dylib        0x000000018e0d2a30 abort + 180
6  swift-frontend           0x000000010181d6f0 swift::SILModule::print(llvm::raw_ostream&, swift::ModuleDecl*, swift::SILOptions const&, bool) const + 0
7  swift-frontend           0x000000010183aa98 swift::SILVisitorBase<(anonymous namespace)::SILVerifier, void>::visitSILBasicBlock(swift::SILBasicBlock*) + 87712
8  swift-frontend           0x00000001018252f8 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 28
9  swift-frontend           0x0000000101823a60 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 10728
10 swift-frontend           0x000000010181d8a8 swift::SILFunction::verify(swift::CalleeCache*, bool, bool, bool) const + 224
11 swift-frontend           0x0000000101820600 swift::SILModule::verify(swift::CalleeCache*, bool, bool) const + 192
12 swift-frontend           0x00000001018204d8 swift::SILModule::verify(bool, bool) const + 140
13 swift-frontend           0x0000000100a51a04 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 580
14 swift-frontend           0x00000001007fe1d4 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*) + 820
15 swift-frontend           0x00000001007fd850 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 656
16 swift-frontend           0x0000000100809de8 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
17 swift-frontend           0x00000001007ff72c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
18 swift-frontend           0x00000001007fedf8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2328
19 swift-frontend           0x00000001005d3490 swift::mainEntry(int, char const**) + 3100
20 dyld                     0x000000018de3b154 start + 2476
hiroshi@himbp tmp % 

Expected behavior

No crash

Environment

The CI https://ci-external.swift.org/job/swift-main-windows-toolchain.

Also the swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain build from swift.org on macOS.

Additional information

No response

@hjyamauchi hjyamauchi added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Dec 4, 2024
@meg-gupta
Copy link
Contributor

@hjyamauchi Can you please add -Xllvm -sil-verify-all -Xllvm -sil-print-function=s7crasher1BV3baryyF to the command line of your reduced test ? I haven't been able to repro it on my local setup.

@hjyamauchi
Copy link
Contributor Author

@meg-gupta Here it is:

~/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/bin/swiftc -O crasher.swift -Xfrontend -sil-verify-all -Xllvm -sil-print-function=s7crasher1BV3baryyF

error: compile command failed due to signal 6 (use -v to see invocation)
  *** SIL module after #19, stage Mandatory Diagnostic Passes + Enabling Optimization Passes, pass 4: CapturePromotion (capture-promotion)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %5, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_box ${ var any IteratorProtocol<A> }, var, name "$x$generator" // users: %40, %3
  %3 = begin_borrow [lexical] [var_decl] %2 : ${ var any IteratorProtocol<A> } // users: %39, %4
  %4 = project_box %3 : ${ var any IteratorProtocol<A> }, 0 // users: %26, %17
  %5 = struct_element_addr %0 : $*B, #B.p         // user: %7
  %6 = alloc_stack $any P                         // users: %23, %22, %8, %7
  copy_addr %5 to [init] %6 : $*any P             // id: %7
  %8 = open_existential_addr immutable_access %6 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %12, %12, %11
  %9 = alloc_stack $any Sequence<A>               // users: %21, %20, %13, %11
  // function_ref P.foo()
  %10 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %12
  %11 = init_existential_addr %9 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %8; user: %12
  %12 = apply %10<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%11, %8) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %8
  %13 = open_existential_addr immutable_access %9 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %18, %17, %16, %15, %14
  %14 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %13; users: %19, %18, %15
  copy_addr %13 to [init] %14 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  %16 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %13 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %13; user: %18
  %17 = init_existential_addr %4 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %13; user: %18
  %18 = apply %16<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%17, %14) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %13
  dealloc_stack %14 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %19
  destroy_addr %9 : $*any Sequence<A>             // id: %20
  dealloc_stack %9 : $*any Sequence<A>            // id: %21
  destroy_addr %6 : $*any P                       // id: %22
  dealloc_stack %6 : $*any P                      // id: %23
  br bb1                                          // id: %24

bb1:                                              // Preds: bb2 bb0
  %25 = alloc_stack $Optional<A>                  // users: %32, %31, %29
  %26 = begin_access [modify] [unknown] %4 : $*any IteratorProtocol<A> // users: %30, %27
  %27 = open_existential_addr mutable_access %26 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %29, %29, %28
  %28 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %27 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %27; user: %29
  %29 = apply %28<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%25, %27) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %27
  end_access %26 : $*any IteratorProtocol<A>      // id: %30
  %31 = load [trivial] %25 : $*Optional<A>        // user: %33
  dealloc_stack %25 : $*Optional<A>               // id: %32
  switch_enum %31 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %33

// %34                                            // user: %35
bb2(%34 : $A):                                    // Preds: bb1
  %35 = move_value [var_decl] %34 : $A            // users: %37, %36
  debug_value %35 : $A, let, name "x"             // id: %36
  extend_lifetime %35 : $A                        // id: %37
  br bb1                                          // id: %38

bb3:                                              // Preds: bb1
  end_borrow %3 : ${ var any IteratorProtocol<A> } // id: %39
  destroy_value %2 : ${ var any IteratorProtocol<A> } // id: %40
  %41 = tuple ()                                  // user: %42
  return %41 : $()                                // id: %42
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL module after #20, stage Mandatory Diagnostic Passes + Enabling Optimization Passes, pass 5: AccessEnforcementSelection (access-enforcement-selection)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %5, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_box ${ var any IteratorProtocol<A> }, var, name "$x$generator" // users: %40, %3
  %3 = begin_borrow [lexical] [var_decl] %2 : ${ var any IteratorProtocol<A> } // users: %39, %4
  %4 = project_box %3 : ${ var any IteratorProtocol<A> }, 0 // users: %26, %17
  %5 = struct_element_addr %0 : $*B, #B.p         // user: %7
  %6 = alloc_stack $any P                         // users: %23, %22, %8, %7
  copy_addr %5 to [init] %6 : $*any P             // id: %7
  %8 = open_existential_addr immutable_access %6 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %12, %12, %11
  %9 = alloc_stack $any Sequence<A>               // users: %21, %20, %13, %11
  // function_ref P.foo()
  %10 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %12
  %11 = init_existential_addr %9 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %8; user: %12
  %12 = apply %10<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%11, %8) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %8
  %13 = open_existential_addr immutable_access %9 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %18, %17, %16, %15, %14
  %14 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %13; users: %19, %18, %15
  copy_addr %13 to [init] %14 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  %16 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %13 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %13; user: %18
  %17 = init_existential_addr %4 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %13; user: %18
  %18 = apply %16<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%17, %14) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %13
  dealloc_stack %14 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %19
  destroy_addr %9 : $*any Sequence<A>             // id: %20
  dealloc_stack %9 : $*any Sequence<A>            // id: %21
  destroy_addr %6 : $*any P                       // id: %22
  dealloc_stack %6 : $*any P                      // id: %23
  br bb1                                          // id: %24

bb1:                                              // Preds: bb2 bb0
  %25 = alloc_stack $Optional<A>                  // users: %32, %31, %29
  %26 = begin_access [modify] [static] %4 : $*any IteratorProtocol<A> // users: %30, %27
  %27 = open_existential_addr mutable_access %26 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %29, %29, %28
  %28 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %27 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %27; user: %29
  %29 = apply %28<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%25, %27) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %27
  end_access %26 : $*any IteratorProtocol<A>      // id: %30
  %31 = load [trivial] %25 : $*Optional<A>        // user: %33
  dealloc_stack %25 : $*Optional<A>               // id: %32
  switch_enum %31 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %33

// %34                                            // user: %35
bb2(%34 : $A):                                    // Preds: bb1
  %35 = move_value [var_decl] %34 : $A            // users: %37, %36
  debug_value %35 : $A, let, name "x"             // id: %36
  extend_lifetime %35 : $A                        // id: %37
  br bb1                                          // id: %38

bb3:                                              // Preds: bb1
  end_borrow %3 : ${ var any IteratorProtocol<A> } // id: %39
  destroy_value %2 : ${ var any IteratorProtocol<A> } // id: %40
  %41 = tuple ()                                  // user: %42
  return %41 : $()                                // id: %42
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #45, stage Mandatory Diagnostic Passes + Enabling Optimization Passes, pass 6: AllocBoxToStack (allocbox-to-stack)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %38, %37, %15, %24
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %5
  %4 = alloc_stack $any P                         // users: %21, %20, %6, %5
  copy_addr %3 to [init] %4 : $*any P             // id: %5
  %6 = open_existential_addr immutable_access %4 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %10, %10, %9
  %7 = alloc_stack $any Sequence<A>               // users: %19, %18, %11, %9
  // function_ref P.foo()
  %8 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %10
  %9 = init_existential_addr %7 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %6; user: %10
  %10 = apply %8<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%9, %6) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %6
  %11 = open_existential_addr immutable_access %7 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %16, %15, %14, %13, %12
  %12 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %11; users: %17, %16, %13
  copy_addr %11 to [init] %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %13
  %14 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %11 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11; user: %16
  %15 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %11; user: %16
  %16 = apply %14<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%15, %12) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11
  dealloc_stack %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %17
  destroy_addr %7 : $*any Sequence<A>             // id: %18
  dealloc_stack %7 : $*any Sequence<A>            // id: %19
  destroy_addr %4 : $*any P                       // id: %20
  dealloc_stack %4 : $*any P                      // id: %21
  br bb1                                          // id: %22

bb1:                                              // Preds: bb2 bb0
  %23 = alloc_stack $Optional<A>                  // users: %30, %29, %27
  %24 = begin_access [modify] [static] %2 : $*any IteratorProtocol<A> // users: %28, %25
  %25 = open_existential_addr mutable_access %24 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %27, %27, %26
  %26 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %25 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25; user: %27
  %27 = apply %26<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%23, %25) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25
  end_access %24 : $*any IteratorProtocol<A>      // id: %28
  %29 = load [trivial] %23 : $*Optional<A>        // user: %31
  dealloc_stack %23 : $*Optional<A>               // id: %30
  switch_enum %29 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %31

// %32                                            // user: %33
bb2(%32 : $A):                                    // Preds: bb1
  %33 = move_value [var_decl] %32 : $A            // users: %35, %34
  debug_value %33 : $A, let, name "x"             // id: %34
  extend_lifetime %33 : $A                        // id: %35
  br bb1                                          // id: %36

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %37
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %38
  %39 = tuple ()                                  // user: %40
  return %39 : $()                                // id: %40
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #120, stage Mandatory Diagnostic Passes + Enabling Optimization Passes, pass 22: ConsumeOperatorCopyableAddressesChecker (sil-consume-operator-copyable-addresses-checker)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %38, %37, %15, %24
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %5
  %4 = alloc_stack $any P                         // users: %21, %20, %6, %5
  copy_addr %3 to [init] %4 : $*any P             // id: %5
  %6 = open_existential_addr immutable_access %4 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %10, %10, %9
  %7 = alloc_stack $any Sequence<A>               // users: %19, %18, %11, %9
  // function_ref P.foo()
  %8 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %10
  %9 = init_existential_addr %7 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %6; user: %10
  %10 = apply %8<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%9, %6) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %6
  %11 = open_existential_addr immutable_access %7 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %16, %15, %14, %13, %12
  %12 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %11; users: %17, %16, %13
  copy_addr %11 to [init] %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %13
  %14 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %11 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11; user: %16
  %15 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %11; user: %16
  %16 = apply %14<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%15, %12) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11
  dealloc_stack %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %17
  destroy_addr %7 : $*any Sequence<A>             // id: %18
  dealloc_stack %7 : $*any Sequence<A>            // id: %19
  destroy_addr %4 : $*any P                       // id: %20
  dealloc_stack %4 : $*any P                      // id: %21
  br bb1                                          // id: %22

bb1:                                              // Preds: bb2 bb0
  %23 = alloc_stack $Optional<A>                  // users: %30, %29, %27
  %24 = begin_access [modify] [static] %2 : $*any IteratorProtocol<A> // users: %28, %25
  %25 = open_existential_addr mutable_access %24 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %27, %27, %26
  %26 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %25 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25; user: %27
  %27 = apply %26<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%23, %25) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25
  end_access %24 : $*any IteratorProtocol<A>      // id: %28
  %29 = load [trivial] %23 : $*Optional<A>        // user: %31
  dealloc_stack %23 : $*Optional<A>               // id: %30
  switch_enum %29 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %31

// %32                                            // user: %33
bb2(%32 : $A):                                    // Preds: bb1
  %33 = move_value [var_decl] %32 : $A            // users: %35, %34
  debug_value %33 : $A, let, name "x"             // id: %34
  extend_lifetime %33 : $A                        // id: %35
  br bb1                                          // id: %36

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %37
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %38
  %39 = tuple ()                                  // user: %40
  return %39 : $()                                // id: %40
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #123, stage Mandatory Diagnostic Passes + Enabling Optimization Passes, pass 25: MoveOnlyTypeEliminator (sil-move-only-type-eliminator)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %36, %35, %15, %24
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %5
  %4 = alloc_stack $any P                         // users: %21, %20, %6, %5
  copy_addr %3 to [init] %4 : $*any P             // id: %5
  %6 = open_existential_addr immutable_access %4 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %10, %10, %9
  %7 = alloc_stack $any Sequence<A>               // users: %19, %18, %11, %9
  // function_ref P.foo()
  %8 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %10
  %9 = init_existential_addr %7 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %6; user: %10
  %10 = apply %8<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%9, %6) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %6
  %11 = open_existential_addr immutable_access %7 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %16, %15, %14, %13, %12
  %12 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %11; users: %17, %16, %13
  copy_addr %11 to [init] %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %13
  %14 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %11 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11; user: %16
  %15 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %11; user: %16
  %16 = apply %14<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%15, %12) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11
  dealloc_stack %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %17
  destroy_addr %7 : $*any Sequence<A>             // id: %18
  dealloc_stack %7 : $*any Sequence<A>            // id: %19
  destroy_addr %4 : $*any P                       // id: %20
  dealloc_stack %4 : $*any P                      // id: %21
  br bb1                                          // id: %22

bb1:                                              // Preds: bb2 bb0
  %23 = alloc_stack $Optional<A>                  // users: %30, %29, %27
  %24 = begin_access [modify] [static] %2 : $*any IteratorProtocol<A> // users: %28, %25
  %25 = open_existential_addr mutable_access %24 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %27, %27, %26
  %26 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %25 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25; user: %27
  %27 = apply %26<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%23, %25) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25
  end_access %24 : $*any IteratorProtocol<A>      // id: %28
  %29 = load [trivial] %23 : $*Optional<A>        // user: %31
  dealloc_stack %23 : $*Optional<A>               // id: %30
  switch_enum %29 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %31

// %32                                            // user: %33
bb2(%32 : $A):                                    // Preds: bb1
  debug_value %32 : $A, let, name "x"             // id: %33
  br bb1                                          // id: %34

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %35
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %36
  %37 = tuple ()                                  // user: %38
  return %37 : $()                                // id: %38
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #183, stage Mandatory Diagnostic Passes + Enabling Optimization Passes, pass 34: DiagnoseUnreachable (diagnose-unreachable)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %36, %35, %15, %24
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %5
  %4 = alloc_stack $any P                         // users: %21, %20, %6, %5
  copy_addr %3 to [init] %4 : $*any P             // id: %5
  %6 = open_existential_addr immutable_access %4 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %10, %10, %9
  %7 = alloc_stack $any Sequence<A>               // users: %19, %18, %11, %9
  // function_ref P.foo()
  %8 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %10
  %9 = init_existential_addr %7 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %6; user: %10
  %10 = apply %8<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%9, %6) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %6
  %11 = open_existential_addr immutable_access %7 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %16, %15, %14, %13, %12
  %12 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %11; users: %17, %16, %13
  copy_addr %11 to [init] %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %13
  %14 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %11 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11; user: %16
  %15 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %11; user: %16
  %16 = apply %14<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%15, %12) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11
  dealloc_stack %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %17
  destroy_addr %7 : $*any Sequence<A>             // id: %18
  dealloc_stack %7 : $*any Sequence<A>            // id: %19
  destroy_addr %4 : $*any P                       // id: %20
  dealloc_stack %4 : $*any P                      // id: %21
  br bb1                                          // id: %22

bb1:                                              // Preds: bb2 bb0
  %23 = alloc_stack $Optional<A>                  // users: %30, %29, %27
  %24 = begin_access [modify] [static] %2 : $*any IteratorProtocol<A> // users: %28, %25
  %25 = open_existential_addr mutable_access %24 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %27, %27, %26
  %26 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %25 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25; user: %27
  %27 = apply %26<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%23, %25) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %25
  end_access %24 : $*any IteratorProtocol<A>      // id: %28
  %29 = load [trivial] %23 : $*Optional<A>        // user: %31
  dealloc_stack %23 : $*Optional<A>               // id: %30
  switch_enum %29 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %31

// %32                                            // user: %33
bb2(%32 : $A):                                    // Preds: bb1
  debug_value %32 : $A, let, name "x"             // id: %33
  br bb1                                          // id: %34

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %35
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %36
  %37 = tuple ()                                  // user: %38
  return %37 : $()                                // id: %38
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL module after #13, stage PrepareOptimizationPasses, pass 3: AccessMarkerElimination (access-marker-elim)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %24, %34, %33, %15
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %5
  %4 = alloc_stack $any P                         // users: %21, %20, %6, %5
  copy_addr %3 to [init] %4 : $*any P             // id: %5
  %6 = open_existential_addr immutable_access %4 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %10, %10, %9
  %7 = alloc_stack $any Sequence<A>               // users: %19, %18, %11, %9
  // function_ref P.foo()
  %8 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %10
  %9 = init_existential_addr %7 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %6; user: %10
  %10 = apply %8<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%9, %6) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %6
  %11 = open_existential_addr immutable_access %7 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %16, %15, %14, %13, %12
  %12 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %11; users: %17, %16, %13
  copy_addr %11 to [init] %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %13
  %14 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %11 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11; user: %16
  %15 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %11; user: %16
  %16 = apply %14<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%15, %12) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %11
  dealloc_stack %12 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %17
  destroy_addr %7 : $*any Sequence<A>             // id: %18
  dealloc_stack %7 : $*any Sequence<A>            // id: %19
  destroy_addr %4 : $*any P                       // id: %20
  dealloc_stack %4 : $*any P                      // id: %21
  br bb1                                          // id: %22

bb1:                                              // Preds: bb2 bb0
  %23 = alloc_stack $Optional<A>                  // users: %28, %27, %26
  %24 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %26, %26, %25
  %25 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %24 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %24; user: %26
  %26 = apply %25<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%23, %24) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %24
  %27 = load [trivial] %23 : $*Optional<A>        // user: %29
  dealloc_stack %23 : $*Optional<A>               // id: %28
  switch_enum %27 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %29

// %30                                            // user: %31
bb2(%30 : $A):                                    // Preds: bb1
  debug_value %30 : $A, let, name "x"             // id: %31
  br bb1                                          // id: %32

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %33
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %34
  %35 = tuple ()                                  // user: %36
  return %35 : $()                                // id: %36
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #39, stage EarlyModulePasses, pass 1: TempRValueOpt (temp-rvalue-opt)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %20, %30, %29, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %14, %13, %12, %11, %10
  %10 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %9 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  br bb1                                          // id: %18

bb1:                                              // Preds: bb2 bb0
  %19 = alloc_stack $Optional<A>                  // users: %24, %23, %22
  %20 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22, %21
  %21 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %20 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20; user: %22
  %22 = apply %21<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%19, %20) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20
  %23 = load [trivial] %19 : $*Optional<A>        // user: %25
  dealloc_stack %19 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

// %26                                            // user: %27
bb2(%26 : $A):                                    // Preds: bb1
  debug_value %26 : $A, let, name "x"             // id: %27
  br bb1                                          // id: %28

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %29
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %30
  %31 = tuple ()                                  // user: %32
  return %31 : $()                                // id: %32
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #40, stage EarlyModulePasses, pass 2: ComputeSideEffects (compute-side-effects)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %20, %30, %29, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %14, %13, %12, %11, %10
  %10 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %9 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  br bb1                                          // id: %18

bb1:                                              // Preds: bb2 bb0
  %19 = alloc_stack $Optional<A>                  // users: %24, %23, %22
  %20 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22, %21
  %21 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %20 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20; user: %22
  %22 = apply %21<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%19, %20) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20
  %23 = load [trivial] %19 : $*Optional<A>        // user: %25
  dealloc_stack %19 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

// %26                                            // user: %27
bb2(%26 : $A):                                    // Preds: bb1
  debug_value %26 : $A, let, name "x"             // id: %27
  br bb1                                          // id: %28

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %29
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %30
  %31 = tuple ()                                  // user: %32
  return %31 : $()                                // id: %32
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL module after #51, stage EarlyModulePasses, pass 7: PerformanceSILLinker (performance-linker)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %20, %30, %29, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %14, %13, %12, %11, %10
  %10 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %9 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  br bb1                                          // id: %18

bb1:                                              // Preds: bb2 bb0
  %19 = alloc_stack $Optional<A>                  // users: %24, %23, %22
  %20 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22, %21
  %21 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %20 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20; user: %22
  %22 = apply %21<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%19, %20) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20
  %23 = load [trivial] %19 : $*Optional<A>        // user: %25
  dealloc_stack %19 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

// %26                                            // user: %27
bb2(%26 : $A):                                    // Preds: bb1
  debug_value %26 : $A, let, name "x"             // id: %27
  br bb1                                          // id: %28

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %29
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %30
  %31 = tuple ()                                  // user: %32
  return %31 : $()                                // id: %32
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #454, stage HighLevel,Function+EarlyLoopOpt, pass 5: DCE (dce)
// B.bar()
// Isolation: unspecified
sil hidden [ossa] @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %20, %29, %28, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %14, %13, %12, %11, %10
  %10 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %9 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  br bb1                                          // id: %18

bb1:                                              // Preds: bb2 bb0
  %19 = alloc_stack $Optional<A>                  // users: %24, %23, %22
  %20 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22, %21
  %21 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %20 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20; user: %22
  %22 = apply %21<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%19, %20) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20
  %23 = load [trivial] %19 : $*Optional<A>        // user: %25
  dealloc_stack %19 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

bb2(%26 : $A):                                    // Preds: bb1
  br bb1                                          // id: %27

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %28
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %29
  %30 = tuple ()                                  // user: %31
  return %30 : $()                                // id: %31
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #472, stage HighLevel,Function+EarlyLoopOpt, pass 25: NonTransparentFunctionOwnershipModelEliminator (non-transparent-func-ownership-model-eliminator)
// B.bar()
// Isolation: unspecified
sil hidden @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %20, %29, %28, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %14, %13, %12, %11, %10
  %10 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %9 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  br bb1                                          // id: %18

bb1:                                              // Preds: bb2 bb0
  %19 = alloc_stack $Optional<A>                  // users: %23, %24, %22
  %20 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22, %21
  %21 = witness_method $@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %20 : $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20; user: %22
  %22 = apply %21<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%19, %20) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20
  %23 = load %19 : $*Optional<A>                  // user: %25
  dealloc_stack %19 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

bb2(%26 : $A):                                    // Preds: bb1
  br bb1                                          // id: %27

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %28
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %29
  %30 = tuple ()                                  // user: %31
  return %30 : $()                                // id: %31
} // end sil function '$s7crasher1BV3baryyF'

  *** SIL function after  #478, stage HighLevel,Function+EarlyLoopOpt, pass 31: SILCombine (sil-combine)
// B.bar()
// Isolation: unspecified
sil hidden @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %20, %29, %28, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %12, %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %21, %14, %13, %11, %10
  %10 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %4 : $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %4; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  br bb1                                          // id: %18

bb1:                                              // Preds: bb2 bb0
  %19 = alloc_stack $Optional<A>                  // users: %23, %24, %22
  %20 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22
  %21 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %9 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %9; user: %22
  %22 = apply %21<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%19, %20) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20
  %23 = load %19 : $*Optional<A>                  // user: %25
  dealloc_stack %19 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

bb2(%26 : $A):                                    // Preds: bb1
  br bb1                                          // id: %27

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %28
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %29
  %30 = tuple ()                                  // user: %31
  return %30 : $()                                // id: %31
} // end sil function '$s7crasher1BV3baryyF'

SIL verification failed: Should not have an operand for the opened existential: AMI->getTypeDependentOperands().empty()
Verifying instruction:
     %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %12, %8, %8, %7
->   %12 = witness_method $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %4 : $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %4; user: %14
     %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
In function:
// B.bar()
// Isolation: unspecified
sil hidden @$s7crasher1BV3baryyF : $@convention(method) (@in_guaranteed B) -> () {
[global: read,write,copy,destroy,allocate,deinit_barrier]
// %0 "self"                                      // users: %3, %1
bb0(%0 : $*B):
  debug_value %0 : $*B, let, name "self", argno 1, expr op_deref // id: %1
  %2 = alloc_stack [lexical] [var_decl] $any IteratorProtocol<A>, var, name "$x$generator", type $any IteratorProtocol<A> // users: %20, %29, %28, %13
  %3 = struct_element_addr %0 : $*B, #B.p         // user: %4
  %4 = open_existential_addr immutable_access %3 : $*any P to $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self // users: %12, %8, %8, %7
  %5 = alloc_stack $any Sequence<A>               // users: %17, %16, %9, %7
  // function_ref P.foo()
  %6 = function_ref @$s7crasher1PPAAE3fooQryF : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // user: %8
  %7 = init_existential_addr %5 : $*any Sequence<A>, $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self> // type-defs: %4; user: %8
  %8 = apply %6<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>(%7, %4) : $@convention(method) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @out EmptyCollection<A> // type-defs: %4
  %9 = open_existential_addr immutable_access %5 : $*any Sequence<A> to $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // users: %21, %14, %13, %11, %10
  %10 = alloc_stack $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // type-defs: %9; users: %15, %14, %11
  copy_addr %9 to [init] %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %11
  %12 = witness_method $@_opaqueReturnTypeOf("$s7crasher1PPAAE3fooQryF", 0) __<@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self>, #Sequence.makeIterator : <Self where Self : Sequence> (__owned Self) -> () -> Self.Iterator, %4 : $*@opened("C8A844B6-B290-11EF-A9D3-BAEE63F10E7B", any P) Self : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %4; user: %14
  %13 = init_existential_addr %2 : $*any IteratorProtocol<A>, $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator // type-defs: %9; user: %14
  %14 = apply %12<@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self>(%13, %10) : $@convention(witness_method: Sequence) <τ_0_0 where τ_0_0 : Sequence> (@in τ_0_0) -> @out τ_0_0.Iterator // type-defs: %9
  dealloc_stack %10 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self // id: %15
  destroy_addr %5 : $*any Sequence<A>             // id: %16
  dealloc_stack %5 : $*any Sequence<A>            // id: %17
  br bb1                                          // id: %18

bb1:                                              // Preds: bb2 bb0
  %19 = alloc_stack $Optional<A>                  // users: %23, %24, %22
  %20 = open_existential_addr mutable_access %2 : $*any IteratorProtocol<A> to $*@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self // users: %22, %22
  %21 = witness_method $@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self.Iterator, #IteratorProtocol.next : <Self where Self : IteratorProtocol> (inout Self) -> () -> Self.Element?, %9 : $*@opened("C8A84858-B290-11EF-A9D3-BAEE63F10E7B", any Sequence<A>) Self : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %9; user: %22
  %22 = apply %21<@opened("C8A84BAA-B290-11EF-A9D3-BAEE63F10E7B", any IteratorProtocol<A>) Self>(%19, %20) : $@convention(witness_method: IteratorProtocol) <τ_0_0 where τ_0_0 : IteratorProtocol> (@inout τ_0_0) -> @out Optional<τ_0_0.Element> // type-defs: %20
  %23 = load %19 : $*Optional<A>                  // user: %25
  dealloc_stack %19 : $*Optional<A>               // id: %24
  switch_enum %23 : $Optional<A>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3 // id: %25

bb2(%26 : $A):                                    // Preds: bb1
  br bb1                                          // id: %27

bb3:                                              // Preds: bb1
  destroy_addr %2 : $*any IteratorProtocol<A>     // id: %28
  dealloc_stack %2 : $*any IteratorProtocol<A>    // id: %29
  %30 = tuple ()                                  // user: %31
  return %30 : $()                                // id: %31
} // end sil function '$s7crasher1BV3baryyF'

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file crasher.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -O -sil-verify-all -empty-abi-descriptor -resource-dir /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift -Xllvm -sil-print-function=s7crasher1BV3baryyF -module-name crasher -in-process-plugin-server-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/hiroshi/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-11-20-a.xctoolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -o /var/folders/ww/kxcj3hm12kd92gcwr9t3y7k40000gq/T/TemporaryDirectory.h1O4Xk/crasher-1.o
1.	Apple Swift version 6.1-dev (LLVM 0f86f354a7bc883, Swift d3064c5fc64ba06)
2.	Compiling with effective version 5.10
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 crasher)
4.	While running pass #478 SILFunctionTransform "SILCombine" on SILFunction "@$s7crasher1BV3baryyF".
 for 'bar()' (at crasher.swift:12:5)
5.	While verifying SIL function "@$s7crasher1BV3baryyF".
 for 'bar()' (at crasher.swift:12:5)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000108c2d2e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108c2b9cc llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000108c2d944 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018e1f6584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018e1c5c20 pthread_kill + 288
5  libsystem_c.dylib        0x000000018e0d2a30 abort + 180
6  swift-frontend           0x00000001041396f0 swift::SILModule::print(llvm::raw_ostream&, swift::ModuleDecl*, swift::SILOptions const&, bool) const + 0
7  swift-frontend           0x0000000104156a98 swift::SILVisitorBase<(anonymous namespace)::SILVerifier, void>::visitSILBasicBlock(swift::SILBasicBlock*) + 87712
8  swift-frontend           0x00000001041412f8 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 28
9  swift-frontend           0x000000010413fa60 (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) + 10728
10 swift-frontend           0x00000001041398a8 swift::SILFunction::verify(swift::CalleeCache*, bool, bool, bool) const + 224
11 swift-frontend           0x0000000103b8dbe4 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 2544
12 swift-frontend           0x0000000103b8e600 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1060
13 swift-frontend           0x0000000103b8b6b8 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
14 swift-frontend           0x0000000103b8b638 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 68
15 swift-frontend           0x0000000103bdc138 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 28
16 swift-frontend           0x0000000103ba850c 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'()) + 204
17 swift-frontend           0x0000000103b8b894 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 64
18 swift-frontend           0x0000000103bbe36c swift::runSILOptimizationPasses(swift::SILModule&) + 156
19 swift-frontend           0x000000010336da3c swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 636
20 swift-frontend           0x000000010311a1d4 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*) + 820
21 swift-frontend           0x0000000103119850 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 656
22 swift-frontend           0x0000000103125de8 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
23 swift-frontend           0x000000010311b72c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
24 swift-frontend           0x000000010311adf8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2328
25 swift-frontend           0x0000000102eef490 swift::mainEntry(int, char const**) + 3100
26 dyld                     0x000000018de3b154 start + 2476

@compnerd compnerd changed the title The main Windows CI fails with "SIL verification failed: Should not have an operand for the opened existential: AMI->getTypeDependentOperands().empty()" SIL verification failed: Should not have an operand for the opened existential: AMI->getTypeDependentOperands().empty() Dec 4, 2024
@compnerd compnerd added SILGen Area → compiler: The SIL generation stage SILOptimizer Area → compiler: SIL optimization passes labels Dec 4, 2024
@hjyamauchi
Copy link
Contributor Author

This reproduces with the swift-DEVELOPMENT-SNAPSHOT-2024-04-13-a build from swift.org. So it doesn't seem like a recently-introduced compiler bug if it's a compiler bug.

@compnerd
Copy link
Member

compnerd commented Dec 4, 2024

Seeing this on Linux as well: https://ci.swift.org/job/swift-PR-Linux-smoke-test/16301/

@compnerd compnerd added Linux Platform: Linux Windows Platform: Windows labels Dec 4, 2024
@hjyamauchi hjyamauchi added the macOS Platform: macOS label Dec 5, 2024
@hjyamauchi
Copy link
Contributor Author

This also reproduces on macos. My reduced test reproduction above is on macos.

@compnerd compnerd removed the triage needed This issue needs more specific labels label Dec 5, 2024
@hjyamauchi
Copy link
Contributor Author

hjyamauchi commented Dec 5, 2024

Locally confirmed that reverting this swift-docc commit works around the build issue:

commit d82da96f1bebda563c58de90d544b60ba8d95bda
Author: David Rönnqvist <[email protected]>
Date:   Wed Dec 4 14:32:10 2024 +0100

    Deprecate `FileSystemProvider` and `RenderNodeProvider` (#1108)

@compnerd Are you going to move forward with swiftlang/swift-docc#1116 ?

@atrick
Copy link
Contributor

atrick commented Dec 5, 2024

rdar://140944064 ([Issue #77955] SIL verification failed: Should not have an operand for the opened existential: AMI->getTypeDependentOperands().empty())

@hjyamauchi
Copy link
Contributor Author

@eeckstein does it seem okay to close this with #77972 ?

@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself verifier and removed Linux Platform: Linux Windows Platform: Windows macOS Platform: macOS labels Dec 6, 2024
@AnthonyLatsis AnthonyLatsis added crash Bug: A crash, i.e., an abnormal termination of software assertion failure Bug → crash: An assertion failure opaque types Feature → types: opaque types opaque result types Feature → types → opaque types: opaque result types SIL and removed SILOptimizer Area → compiler: SIL optimization passes SILGen Area → compiler: The SIL generation stage labels Dec 6, 2024
eeckstein added a commit that referenced this issue Dec 6, 2024
Consider that the lookup-type can be an opaque return type.

Also fixing the SILPrinter.

Fixes a verifier crash
#77955
140939536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertion failure Bug → crash: An assertion failure bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software opaque result types Feature → types → opaque types: opaque result types opaque types Feature → types: opaque types SIL verifier
Projects
None yet
Development

No branches or pull requests

6 participants