@@ -90,6 +90,8 @@ struct StructWithEnumWithIndirectCaseField {
90
90
var field : EnumWithIndirectCase
91
91
}
92
92
93
+ sil @get_fakeoptional_nativeobject : $@convention(thin) () -> @owned FakeOptional<Builtin.NativeObject>
94
+
93
95
///////////
94
96
// Tests //
95
97
///////////
@@ -1747,10 +1749,8 @@ bb1:
1747
1749
return %9999 : $()
1748
1750
}
1749
1751
1750
- // Forwarding case. We need LiveRanges for this.
1751
- //
1752
1752
// CHECK-LABEL: sil [ossa] @donot_join_simple_liveranges_in_same_block_2 : $@convention(thin) (@owned Builtin.NativeObject) -> () {
1753
- // CHECK: copy_value
1753
+ // CHECK-NOT : copy_value
1754
1754
// CHECK: } // end sil function 'donot_join_simple_liveranges_in_same_block_2'
1755
1755
sil [ossa] @donot_join_simple_liveranges_in_same_block_2 : $@convention(thin) (@owned Builtin.NativeObject) -> () {
1756
1756
bb0(%0 : @owned $Builtin.NativeObject):
@@ -2832,3 +2832,39 @@ bb1:
2832
2832
bb2:
2833
2833
unreachable
2834
2834
}
2835
+
2836
+ // Make sure we leave only one copy in bb2 and no destroys
2837
+ //
2838
+ // CHECK-LABEL: sil [ossa] @join_test_with_forwarding_inst : $@convention(thin) () -> @owned FakeOptional<Builtin.NativeObject> {
2839
+ // CHECK: bb2:
2840
+ // CHECK: copy_value
2841
+ // CHECK-NOT: destroy_value
2842
+ // CHECK-NOT: copy_value
2843
+ // CHECK: br bb3(
2844
+ // CHECK: } // end sil function 'join_test_with_forwarding_inst'
2845
+ sil [ossa] @join_test_with_forwarding_inst : $@convention(thin) () -> @owned FakeOptional<Builtin.NativeObject> {
2846
+ bb0:
2847
+ %allocStack = alloc_stack $Builtin.NativeObject
2848
+ %0 = function_ref @get_fakeoptional_nativeobject : $@convention(thin) () -> @owned FakeOptional<Builtin.NativeObject>
2849
+ %1 = apply %0() : $@convention(thin) () -> @owned FakeOptional<Builtin.NativeObject>
2850
+ cond_br undef, bb1, bb2
2851
+
2852
+ bb1:
2853
+ destroy_value %1 : $FakeOptional<Builtin.NativeObject>
2854
+ %2 = enum $FakeOptional<Builtin.NativeObject>, #FakeOptional.none!enumelt
2855
+ br bb3(%2 : $FakeOptional<Builtin.NativeObject>)
2856
+
2857
+ bb2:
2858
+ %3 = unchecked_enum_data %1 : $FakeOptional<Builtin.NativeObject>, #FakeOptional.some!enumelt
2859
+ %4 = copy_value %3 : $Builtin.NativeObject
2860
+ store %3 to [init] %allocStack : $*Builtin.NativeObject
2861
+ %4c = copy_value %4 : $Builtin.NativeObject
2862
+ destroy_value %4 : $Builtin.NativeObject
2863
+ %5 = enum $FakeOptional<Builtin.NativeObject>, #FakeOptional.some!enumelt, %4c : $Builtin.NativeObject
2864
+ destroy_addr %allocStack : $*Builtin.NativeObject
2865
+ br bb3(%5 : $FakeOptional<Builtin.NativeObject>)
2866
+
2867
+ bb3(%result : @owned $FakeOptional<Builtin.NativeObject>):
2868
+ dealloc_stack %allocStack : $*Builtin.NativeObject
2869
+ return %result : $FakeOptional<Builtin.NativeObject>
2870
+ }
0 commit comments