mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The prior emission strategy produced some scary SIL where we have a copy of uninitialized memory: ``` ignored_use %14 %16 = alloc_stack $T unreachable bb1: copy_addr [take] %16 to [init] %0 dealloc_stack %16 ``` I assume this was done to dodge the SILVerifier, which will catch a take of an uninitialized address, had the alloc_stack been in any reachable predecessor. We already have a representation for an undefined value in SIL, so I'd rather use that than try to sneak one past the verifier. This adjusted emission also is opaque values friendly, as it doesn't assume the result value is an address. resolves rdar://162239557
21 lines
981 B
Swift
21 lines
981 B
Swift
// RUN: %target-swift-emit-silgen %s -verify -sil-verify-all | %FileCheck %s --check-prefixes CHECK,REG
|
|
// RUN: %target-swift-emit-silgen %s -verify -sil-verify-all -enable-sil-opaque-values | %FileCheck %s --check-prefixes CHECK,OV
|
|
|
|
// CHECK-LABEL: sil{{.*}} [ossa] @{{.*}}uninhabited_generic{{.*}}
|
|
// CHECK: [[NEVER:%[^,]+]] = apply {{.*}} -> Never
|
|
// CHECK-NEXT: ignored_use [[NEVER]]
|
|
// CHECK-NEXT: unreachable
|
|
//
|
|
// CHECK: bb1:
|
|
// CHECK-NOT: Preds
|
|
|
|
// Without opaque values, take from an undef address,
|
|
// through a temporary alloc, to eventually the out-parameter %0
|
|
// REG-NEXT: [[BOGUS_ALLOC:%.*]] = alloc_stack $T
|
|
// REG-NEXT: copy_addr [take] undef to [init] [[BOGUS_ALLOC]]
|
|
// REG-NEXT: copy_addr [take] [[BOGUS_ALLOC]] to [init] %0
|
|
|
|
// With opaque values, simply return the undef value
|
|
// OV-NEXT: return undef : $T
|
|
func uninhabited_generic<T>() -> T { fatalError("todo") }
|