|
| 1 | +// RUN: %target-sil-opt %s -dead-store-elimination -I %S/Inputs/include | %FileCheck %s |
| 2 | + |
| 3 | +sil_stage canonical |
| 4 | + |
| 5 | +import Builtin |
| 6 | +import Swift |
| 7 | +import SwiftShims |
| 8 | +import CUnion |
| 9 | + |
| 10 | + |
| 11 | +sil [noinline] @modify_U : $@convention(thin) (@inout U) -> () { |
| 12 | +[%0: read v**] |
| 13 | +[global: read,write,copy,destroy,allocate,deinit_barrier] |
| 14 | +} |
| 15 | + |
| 16 | +// CHECK-LABEL: sil @pointer_escape_via_c_union : |
| 17 | +// CHECK: store %0 to %1 |
| 18 | +// CHECK: } // end sil function 'pointer_escape_via_c_union' |
| 19 | +sil @pointer_escape_via_c_union : $@convention(thin) (S) -> () { |
| 20 | +[global: read,write,copy,destroy,allocate,deinit_barrier] |
| 21 | +bb0(%0 : $S): |
| 22 | + %1 = alloc_stack [var_decl] $S, var, name "vs" |
| 23 | + store %0 to %1 : $*S |
| 24 | + %3 = address_to_pointer [stack_protection] %1 : $*S to $Builtin.RawPointer |
| 25 | + %4 = struct $UnsafeMutablePointer<S> (%3 : $Builtin.RawPointer) |
| 26 | + %5 = alloc_stack [var_decl] $U, var, name "u" |
| 27 | + %6 = enum $Optional<UnsafeMutablePointer<S>>, #Optional.some!enumelt, %4 : $UnsafeMutablePointer<S> |
| 28 | + %7 = alloc_stack [var_decl] $U |
| 29 | + %8 = address_to_pointer %7 : $*U to $Builtin.RawPointer |
| 30 | + %9 = pointer_to_address %8 : $Builtin.RawPointer to [strict] $*Optional<UnsafeMutablePointer<S>> |
| 31 | + store %6 to %9 : $*Optional<UnsafeMutablePointer<S>> |
| 32 | + %11 = load %7 : $*U |
| 33 | + dealloc_stack %7 : $*U |
| 34 | + store %11 to %5 : $*U |
| 35 | + %14 = function_ref @modify_U : $@convention(thin) (@inout U) -> () |
| 36 | + %15 = apply %14(%5) : $@convention(thin) (@inout U) -> () |
| 37 | + dealloc_stack %5 : $*U |
| 38 | + dealloc_stack %1 : $*S |
| 39 | + %18 = tuple () |
| 40 | + return %18 : $() |
| 41 | +} |
| 42 | + |
0 commit comments