mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
(containing just an uncond branch) when a shared block isn't actually shared. This is a revised version of r26676 that makes sure to emit the cleanups for a case pattern as soon as possible. Extending the lifetime of the case value across the body of the switch caused extra copies of COW types. Swift SVN r26685
30 lines
1.0 KiB
Swift
30 lines
1.0 KiB
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen %s | FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
|
|
// CHECK-LABEL: sil hidden @_TF11switch_objc13matchesEitherFT5inputCSo4Hive1aS0_1bS0__Sb :
|
|
func matchesEither(#input: Hive, #a: Hive, #b: Hive) -> Bool {
|
|
switch input {
|
|
// CHECK: function_ref @_TZF10ObjectiveCoi2teFTCSo8NSObjectS0__Sb
|
|
// CHECK: cond_br {{%.*}}, [[YES_CASE1:bb[0-9]+]], [[NOT_CASE1:bb[0-9]+]]
|
|
// CHECK: [[YES_CASE1]]:
|
|
// CHECK: br [[RET_TRUE:bb[0-9]+]]
|
|
// CHECK: [[NOT_CASE1]]:
|
|
// CHECK: function_ref @_TZF10ObjectiveCoi2teFTCSo8NSObjectS0__Sb
|
|
// CHECK: cond_br {{%.*}}, [[YES_CASE2:bb[0-9]+]], [[NOT_CASE2:bb[0-9]+]]
|
|
// CHECK: [[YES_CASE2]]:
|
|
case a, b:
|
|
// CHECK: function_ref @_TFSbCfMSbFT22_builtinBooleanLiteralBi1__Sb
|
|
return true
|
|
|
|
// CHECK: [[NOT_CASE2]]:
|
|
// CHECK: br [[RET_FALSE:bb[0-9]+]]
|
|
default:
|
|
// CHECK: [[RET_FALSE]]:
|
|
// CHECK: function_ref @_TFSbCfMSbFT22_builtinBooleanLiteralBi1__Sb
|
|
return false
|
|
}
|
|
}
|