// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -gnone -emit-ir -I %S/Inputs | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize import Builtin sil_stage canonical enum Either { case Left(T) case Right(U) } enum EitherOr { case Left(T) case Middle case Center case Right(U) } class C {} sil_vtable C {} // CHECK: @_T026enum_dynamic_multi_payload8EitherOrOMP = {{.*}} %swift.type* (%swift.type_pattern*, i8**)* [[CREATE_GENERIC_METADATA:@[A-Za-z0-9_]+]] // -- The runtime doesn't track spare bits, so fixed instances of the dynamic // type can't use them. // CHECK-64-LABEL: define{{( protected)?}} swiftcc { i64, i8 } @fixed_instances_dont_use_spare_bits(i64, i8) // CHECK-32-LABEL: define{{( protected)?}} swiftcc { i32, i8 } @fixed_instances_dont_use_spare_bits(i32, i8) sil @fixed_instances_dont_use_spare_bits : $@convention(thin) (@owned Either) -> @owned Either { entry(%e : $Either): return %e : $Either } // -- Handle case where all of the payloads become empty. // CHECK-LABEL: define{{( protected)?}} swiftcc void @empty_instance(i8) {{.*}} { sil @empty_instance : $@convention(thin) (Either<(), ()>) -> () { // CHECK-NEXT: entry: entry(%e : $Either<(), ()>): retain_value %e : $Either<(), ()> release_value %e : $Either<(), ()> fix_lifetime %e : $Either<(), ()> // CHECK-NEXT: alloca // CHECK-NEXT: trunc i8 {{.*}} to i1 // CHECK-NEXT: bitcast // CHECK-NEXT: llvm.lifetime.start %s = alloc_stack $Either<(), ()> %l = enum $Either<(), ()>, #Either.Left!enumelt.1, undef : $() // CHECK-NEXT: bitcast {{.*}} to i1* // CHECK-NEXT: store i1 false store %l to %s : $*Either<(), ()> %r = enum $Either<(), ()>, #Either.Right!enumelt.1, undef : $() // CHECK-NEXT: bitcast {{.*}} to i1* // CHECK-NEXT: store i1 true store %r to %s : $*Either<(), ()> %a = unchecked_enum_data %l : $Either<(), ()>, #Either.Left!enumelt.1 %b = unchecked_enum_data %r : $Either<(), ()>, #Either.Right!enumelt.1 // CHECK-NEXT: br i1 {{%.*}}, label %7, label %6 // CHECK: