mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* re-implement the SILCombine peephole as a Swift instruction simplification * run this simplification also in the OnoneSimplification pass
125 lines
4.1 KiB
Plaintext
125 lines
4.1 KiB
Plaintext
// RUN: %target-sil-opt %s -onone-simplification -simplify-instruction=mark_dependence_addr -enable-experimental-feature LifetimeDependence | %FileCheck %s
|
|
|
|
// REQUIRES: swift_feature_LifetimeDependence
|
|
|
|
import Swift
|
|
import Builtin
|
|
|
|
class B {}
|
|
|
|
struct S {
|
|
var a: B
|
|
var b: B
|
|
}
|
|
|
|
struct NE: ~Escapable {}
|
|
|
|
struct S2: ~Escapable {
|
|
var a: NE
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @mark_dependence_trivial_base :
|
|
// CHECK-NOT: mark_dependence_addr
|
|
// CHECK: } // end sil function 'mark_dependence_trivial_base'
|
|
sil [ossa] @mark_dependence_trivial_base : $@convention(thin) (@in_guaranteed B, Int) -> () {
|
|
bb0(%0 : $*B, %1 : $Int):
|
|
mark_dependence_addr %0 on %1
|
|
%3 = tuple ()
|
|
return %3
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @mark_dependence_trivial_base_addr :
|
|
// CHECK: mark_dependence_addr %0 on %1
|
|
// CHECK: } // end sil function 'mark_dependence_trivial_base_addr'
|
|
sil [ossa] @mark_dependence_trivial_base_addr : $@convention(thin) (@in_guaranteed B, @in_guaranteed Int) -> () {
|
|
bb0(%0 : $*B, %1 : $*Int):
|
|
mark_dependence_addr %0 on %1
|
|
%3 = tuple ()
|
|
return %3
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @mark_dependence_non_trivial_base :
|
|
// CHECK: mark_dependence_addr %0 on %1
|
|
// CHECK: } // end sil function 'mark_dependence_non_trivial_base'
|
|
sil [ossa] @mark_dependence_non_trivial_base : $@convention(thin) (@in_guaranteed B, @guaranteed B) -> () {
|
|
bb0(%0 : $*B, %1 : @guaranteed $B):
|
|
mark_dependence_addr %0 on %1
|
|
%3 = tuple ()
|
|
return %3
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @mark_dependence_projection :
|
|
// CHECK-NOT: mark_dependence_addr
|
|
// CHECK: } // end sil function 'mark_dependence_projection'
|
|
sil [ossa] @mark_dependence_projection : $@convention(thin) (@in_guaranteed S) -> () {
|
|
bb0(%0 : $*S):
|
|
%1 = struct_element_addr %0, #S.a
|
|
mark_dependence_addr %1 on %0
|
|
%3 = tuple ()
|
|
return %3
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @mark_dependence_wrong_projection :
|
|
// CHECK: mark_dependence_addr %0 on %1
|
|
// CHECK: } // end sil function 'mark_dependence_wrong_projection'
|
|
sil [ossa] @mark_dependence_wrong_projection : $@convention(thin) (@in_guaranteed S) -> () {
|
|
bb0(%0 : $*S):
|
|
%1 = struct_element_addr %0, #S.a
|
|
mark_dependence_addr %0 on %1
|
|
%3 = tuple ()
|
|
return %3
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @mark_dependence_wrong_projection2 :
|
|
// CHECK: mark_dependence_addr %1 on %2
|
|
// CHECK: } // end sil function 'mark_dependence_wrong_projection2'
|
|
sil [ossa] @mark_dependence_wrong_projection2 : $@convention(thin) (@in_guaranteed S) -> () {
|
|
bb0(%0 : $*S):
|
|
%1 = struct_element_addr %0, #S.a
|
|
%2 = struct_element_addr %0, #S.b
|
|
mark_dependence_addr %1 on %2
|
|
%4 = tuple ()
|
|
return %4
|
|
}
|
|
|
|
// CHECK-LABEL: sil [ossa] @mark_dependence_non_escapable_projection :
|
|
// CHECK: mark_dependence_addr %1 on %0
|
|
// CHECK: } // end sil function 'mark_dependence_non_escapable_projection'
|
|
sil [ossa] @mark_dependence_non_escapable_projection : $@convention(thin) (@in_guaranteed S2) -> () {
|
|
bb0(%0 : $*S2):
|
|
%1 = struct_element_addr %0, #S2.a
|
|
mark_dependence_addr %1 on %0
|
|
%4 = tuple ()
|
|
return %4
|
|
}
|
|
|
|
// CHECK-LABEL: sil @mark_dependence_base :
|
|
// CHECK-NOT: init_existential_ref
|
|
// CHECK-NOT: enum
|
|
// CHECK: mark_dependence_addr %0 on %1
|
|
// CHECK: } // end sil function 'mark_dependence_base'
|
|
sil @mark_dependence_base : $@convention(thin) (@inout Builtin.Int64, @owned B) -> () {
|
|
bb0(%0 : $*Builtin.Int64, %1 : $B):
|
|
%2 = init_existential_ref %1 : $B : $B, $AnyObject
|
|
%3 = enum $Optional<AnyObject>, #Optional.some!enumelt, %2
|
|
mark_dependence_addr %0 on %3
|
|
%5 = tuple ()
|
|
return %5
|
|
}
|
|
|
|
// CHECK-LABEL: sil @mark_dependence_base2 :
|
|
// CHECK-NOT: init_existential_ref
|
|
// CHECK-NOT: open_existential_ref
|
|
// CHECK: mark_dependence_addr %0 on %1
|
|
// CHECK: } // end sil function 'mark_dependence_base2'
|
|
sil @mark_dependence_base2 : $@convention(thin) (@inout Builtin.Int64, @owned B) -> () {
|
|
bb0(%0 : $*Builtin.Int64, %1 : $B):
|
|
%2 = init_existential_ref %1 : $B : $B, $AnyObject
|
|
%3 = open_existential_ref %2 to $@opened("B674783A-EF08-11E7-97D6-8C85900CB088", AnyObject) Self
|
|
mark_dependence_addr %0 on %3
|
|
%5 = tuple ()
|
|
return %5
|
|
}
|
|
|
|
|