mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Type annotations for instruction operands are omitted, e.g. ``` %3 = struct $S(%1, %2) ``` Operand types are redundant anyway and were only used for sanity checking in the SIL parser. But: operand types _are_ printed if the definition of the operand value was not printed yet. This happens: * if the block with the definition appears after the block where the operand's instruction is located * if a block or instruction is printed in isolation, e.g. in a debugger The old behavior can be restored with `-Xllvm -sil-print-types`. This option is added to many existing test files which check for operand types in their check-lines.
53 lines
1.8 KiB
Swift
53 lines
1.8 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/resilient_struct.swiftmodule %S/../Inputs/resilient_struct.swift
|
|
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -I %t %s | %FileCheck %s
|
|
|
|
import resilient_struct
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @$s17switch_resilience29resilientTupleEltCaseEnumTestyyF : $@convention(thin) () -> () {
|
|
// CHECK: bb0:
|
|
// CHECK: [[STACK_SLOT:%.*]] = alloc_stack $Enum
|
|
//
|
|
// CHECK: bb1:
|
|
// CHECK: [[VALUE:%.*]] = unchecked_take_enum_data_addr [[STACK_SLOT]] : $*Enum
|
|
// CHECK: [[STACK_SLOT_COPY:%.*]] = alloc_stack [lexical] [var_decl] $(url: ResilientRef, void: ()), let, name "value"
|
|
// CHECK: copy_addr [[VALUE]] to [init] [[STACK_SLOT_COPY]]
|
|
// CHECK: cond_br {{%.*}}, bb2, bb3
|
|
//
|
|
// CHECK: bb2:
|
|
// CHECK: destroy_addr [[STACK_SLOT_COPY]]
|
|
// CHECK-NEXT: dealloc_stack [[STACK_SLOT_COPY]]
|
|
// CHECK-NEXT: destroy_addr [[VALUE]]
|
|
// CHECK-NEXT: dealloc_stack [[STACK_SLOT]]
|
|
// CHECK-NEXT: br bb4
|
|
//
|
|
// CHECK: bb3:
|
|
// CHECK-NEXT: destroy_addr [[STACK_SLOT_COPY]]
|
|
// CHECK-NEXT: dealloc_stack [[STACK_SLOT_COPY]]
|
|
// CHECK-NEXT: [[REPROJECT:%.*]] = tuple_element_addr [[VALUE]]
|
|
// CHECK: destroy_addr [[REPROJECT]]
|
|
// CHECK-NEXT: dealloc_stack [[STACK_SLOT]]
|
|
// CHECK: br bb4
|
|
//
|
|
// CHECK: } // end sil function '$s17switch_resilience29resilientTupleEltCaseEnumTestyyF'
|
|
func resilientTupleEltCaseEnumTest() {
|
|
enum Enum {
|
|
case first(url: ResilientRef, void: Void)
|
|
}
|
|
|
|
func getEnum() -> Enum {
|
|
let url = ResilientRef(r: Referent())
|
|
return .first(url: url, void: ())
|
|
}
|
|
func getBool() -> Bool { return false }
|
|
func urlUser(_ u: ResilientRef) {}
|
|
func kraken() {}
|
|
|
|
switch getEnum() {
|
|
case let .first(value) where getBool():
|
|
urlUser(value.0)
|
|
case .first:
|
|
kraken()
|
|
}
|
|
}
|