Skip to content

Commit 5a63808

Browse files
author
Gabor Horvath
committed
Change the convention for reabstractions as well.
Remove SIL tests that are testing result conventions that are never emitted by the compiler.
1 parent 8c197eb commit 5a63808

File tree

9 files changed

+1
-196
lines changed

9 files changed

+1
-196
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5290,6 +5290,7 @@ void ResultPlanner::execute(SmallVectorImpl<SILValue> &innerDirectResultStack,
52905290
LLVM_FALLTHROUGH;
52915291
case ResultConvention::Owned:
52925292
case ResultConvention::Autoreleased:
5293+
case ResultConvention::Unowned: // Handled in OwnershipModelEliminator.
52935294
return SGF.emitManagedRValueWithCleanup(resultValue, resultTL);
52945295
case ResultConvention::Pack:
52955296
llvm_unreachable("shouldn't have direct result with pack results");
@@ -5299,8 +5300,6 @@ void ResultPlanner::execute(SmallVectorImpl<SILValue> &innerDirectResultStack,
52995300
// originally 'self'.
53005301
SGF.SGM.diagnose(Loc.getSourceLoc(), diag::not_implemented,
53015302
"reabstraction of returns_inner_pointer function");
5302-
LLVM_FALLTHROUGH;
5303-
case ResultConvention::Unowned:
53045303
return SGF.emitManagedCopy(Loc, resultValue, resultTL);
53055304
case ResultConvention::GuaranteedAddress:
53065305
case ResultConvention::Guaranteed:

test/SIL/OwnershipVerifier/use_verifier.sil

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -828,30 +828,6 @@ bb5(%5 : @owned $ThreeDifferingPayloadEnum):
828828
return %5 : $ThreeDifferingPayloadEnum
829829
}
830830

831-
sil [ossa] @enum_cases_with_trivial_unowned_cases_arg_into_phi : $@convention(thin) (Builtin.NativeObject) -> ThreeDifferingPayloadEnum {
832-
bb0(%0 : @unowned $Builtin.NativeObject):
833-
cond_br undef, bb1, bb2
834-
835-
bb1:
836-
cond_br undef, bb3, bb4
837-
838-
bb2:
839-
%1 = enum $ThreeDifferingPayloadEnum, #ThreeDifferingPayloadEnum.nopayload!enumelt
840-
br bb5(%1 : $ThreeDifferingPayloadEnum)
841-
842-
bb3:
843-
%2 = enum $ThreeDifferingPayloadEnum, #ThreeDifferingPayloadEnum.nontrivial_payload!enumelt, %0 : $Builtin.NativeObject
844-
br bb5(%2 : $ThreeDifferingPayloadEnum)
845-
846-
bb4:
847-
%3 = integer_literal $Builtin.Int32, 0
848-
%4 = enum $ThreeDifferingPayloadEnum, #ThreeDifferingPayloadEnum.trivial_payload!enumelt, %3 : $Builtin.Int32
849-
br bb5(%4 : $ThreeDifferingPayloadEnum)
850-
851-
bb5(%5 : @unowned $ThreeDifferingPayloadEnum):
852-
return %5 : $ThreeDifferingPayloadEnum
853-
}
854-
855831
sil [ossa] @enum_cases_with_trivial_guaranteed_cases_arg_into_phi : $@convention(thin) (@guaranteed Builtin.NativeObject) -> @owned ThreeDifferingPayloadEnum {
856832
bb0(%0 : @guaranteed $Builtin.NativeObject):
857833
cond_br undef, bb1, bb2
@@ -1383,20 +1359,6 @@ bb3(%fUnknown : @owned $@callee_owned () -> ()):
13831359
return %9999 : $()
13841360
}
13851361

1386-
sil [ossa] @unowned_to_ref_is_unowned_instant_use : $@convention(thin) (@guaranteed Builtin.NativeObject) -> Builtin.NativeObject {
1387-
bb0(%0 : @guaranteed $Builtin.NativeObject):
1388-
%1 = ref_to_unowned %0 : $Builtin.NativeObject to $@sil_unowned Builtin.NativeObject
1389-
%2 = unowned_to_ref %1 : $@sil_unowned Builtin.NativeObject to $Builtin.NativeObject
1390-
return %2 : $Builtin.NativeObject
1391-
}
1392-
1393-
sil [ossa] @unmanaged_to_ref_is_unowned_instant_use : $@convention(thin) (@guaranteed Builtin.NativeObject) -> Builtin.NativeObject {
1394-
bb0(%0 : @guaranteed $Builtin.NativeObject):
1395-
%1 = ref_to_unmanaged %0 : $Builtin.NativeObject to $@sil_unmanaged Builtin.NativeObject
1396-
%2 = unmanaged_to_ref %1 : $@sil_unmanaged Builtin.NativeObject to $Builtin.NativeObject
1397-
return %2 : $Builtin.NativeObject
1398-
}
1399-
14001362
sil [ossa] @nontrivial_enum_unchecked_enum_data_trivial_payload_owned : $@convention(thin) (@owned ThreeDifferingPayloadEnum) -> Builtin.Int32 {
14011363
bb0(%0 : @owned $ThreeDifferingPayloadEnum):
14021364
// NOTE: It may be surprising that %0 is consumed by this unchecked_enum_data

test/SILOptimizer/cse_objc_ossa.sil

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@ import Foundation
99
@objc(XX) protocol XX {
1010
}
1111

12-
// CHECK-LABEL: sil [ossa] @cse_objc_protocol :
13-
// CHECK: objc_protocol #XX : $Protocol
14-
// CHECK-NOT: objc_protocol
15-
// CHECK: tuple (%0 : $Protocol, %0 : $Protocol)
16-
// CHECK-LABEL: } // end sil function 'cse_objc_protocol'
17-
sil [ossa] @cse_objc_protocol : $@convention(thin) () -> (Protocol, Protocol) {
18-
bb0:
19-
%0 = objc_protocol #XX : $Protocol
20-
%1 = objc_protocol #XX : $Protocol
21-
%2 = tuple (%0: $Protocol, %1: $Protocol)
22-
return %2 : $(Protocol, Protocol)
23-
}
24-
2512
@objc protocol Walkable {
2613
func walk()
2714
}

test/SILOptimizer/cse_ossa.sil

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -695,19 +695,6 @@ bb0(%0 : $*Builtin.Int8):
695695
return %4 : $Builtin.Int64
696696
}
697697

698-
// CHECK-LABEL: sil [ossa] @cse_raw_pointer_to_ref :
699-
// CHECK: raw_pointer_to_ref
700-
// CHECK-NOT: raw_pointer_to_ref
701-
// CHECK: tuple
702-
// CHECK-LABEL: } // end sil function 'cse_raw_pointer_to_ref'
703-
sil [ossa] @cse_raw_pointer_to_ref : $@convention(thin) (Builtin.RawPointer) -> (C, C) {
704-
bb0(%0 : $Builtin.RawPointer):
705-
%1 = raw_pointer_to_ref %0 : $Builtin.RawPointer to $C
706-
%2 = raw_pointer_to_ref %0 : $Builtin.RawPointer to $C
707-
%6 = tuple(%1: $C, %2: $C)
708-
return %6 : $(C, C)
709-
}
710-
711698
// CHECK-LABEL: sil [ossa] @cse_unchecked_addr_cast :
712699
// CHECK: unchecked_addr_cast
713700
// CHECK-NOT: unchecked_addr_cast

test/SILOptimizer/cse_ossa_nontrivial.sil

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,6 @@ bb0(%0 : @owned $Klass):
255255
return %6 : $()
256256
}
257257

258-
// CHECK-LABEL: sil [ossa] @cse_raw_pointer_to_ref :
259-
// CHECK: raw_pointer_to_ref
260-
// CHECK-NOT: raw_pointer_to_ref
261-
// CHECK: tuple
262-
// CHECK-LABEL: } // end sil function 'cse_raw_pointer_to_ref'
263-
sil [ossa] @cse_raw_pointer_to_ref : $@convention(thin) (Builtin.RawPointer) -> (Klass, Klass) {
264-
bb0(%0 : $Builtin.RawPointer):
265-
%1 = raw_pointer_to_ref %0 : $Builtin.RawPointer to $Klass
266-
%2 = raw_pointer_to_ref %0 : $Builtin.RawPointer to $Klass
267-
%6 = tuple(%1: $Klass, %2: $Klass)
268-
return %6 : $(Klass, Klass)
269-
}
270-
271258
enum Enum1 {
272259
case Case1
273260
case Case2

test/SILOptimizer/ossa_rauw_tests.sil

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -302,52 +302,6 @@ bbExitBlock(%result : @owned $FakeOptional<Klass>):
302302
return %result : $FakeOptional<Klass>
303303
}
304304

305-
// CHECK-LABEL: sil [ossa] @unowned_to_guaranteed_rauw_2 : $@convention(thin) (@guaranteed Klass) -> (Klass, Klass) {
306-
// CHECK: bb0(
307-
// CHECK-NEXT: tuple
308-
// CHECK-NEXT: return
309-
// CHECK: } // end sil function 'unowned_to_guaranteed_rauw_2'
310-
sil [ossa] @unowned_to_guaranteed_rauw_2 : $@convention(thin) (@guaranteed Klass) -> (Klass, Klass) {
311-
bb0(%0 : @guaranteed $Klass):
312-
%1 = unchecked_bitwise_cast %0 : $Klass to $SubKlass
313-
%2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
314-
%3 = tuple(%2 : $Klass, %2 : $Klass)
315-
return %3 : $(Klass, Klass)
316-
}
317-
318-
// CHECK-LABEL: sil [ossa] @unowned_to_guaranteed_rauw_2a : $@convention(thin) (@guaranteed Builtin.NativeObject) -> (Klass, Klass) {
319-
// CHECK: bb0(
320-
// CHECK-NEXT: unchecked_ref_cast
321-
// CHECK-NEXT: tuple
322-
// CHECK-NEXT: return
323-
// CHECK: } // end sil function 'unowned_to_guaranteed_rauw_2a'
324-
sil [ossa] @unowned_to_guaranteed_rauw_2a : $@convention(thin) (@guaranteed Builtin.NativeObject) -> (Klass, Klass) {
325-
bb0(%0 : @guaranteed $Builtin.NativeObject):
326-
%0a = unchecked_ref_cast %0 : $Builtin.NativeObject to $Klass
327-
%1 = unchecked_bitwise_cast %0a : $Klass to $SubKlass
328-
%2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
329-
%3 = tuple(%2 : $Klass, %2 : $Klass)
330-
return %3 : $(Klass, Klass)
331-
}
332-
333-
// We need the unchecked_ownership_conversion since our base value is
334-
// guaranteed, not a function argument, and our user is a function exiting
335-
// terminator.
336-
//
337-
// CHECK-LABEL: sil [ossa] @unowned_to_guaranteed_rauw_2b : $@convention(thin) (@guaranteed Builtin.NativeObject) -> Klass {
338-
// CHECK: bb0(
339-
// CHECK-NEXT: unchecked_ref_cast
340-
// CHECK-NEXT: return
341-
// CHECK: } // end sil function 'unowned_to_guaranteed_rauw_2b'
342-
sil [ossa] @unowned_to_guaranteed_rauw_2b : $@convention(thin) (@guaranteed Builtin.NativeObject) -> Klass {
343-
bb0(%0 : @guaranteed $Builtin.NativeObject):
344-
%0a = unchecked_ref_cast %0 : $Builtin.NativeObject to $Klass
345-
%1 = unchecked_bitwise_cast %0a : $Klass to $SubKlass
346-
%2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
347-
return %2 : $Klass
348-
}
349-
350-
351305
// CHECK-LABEL: sil [ossa] @unowned_to_guaranteed_rauw_2_loop : $@convention(thin) (@guaranteed Klass) -> @owned FakeOptional<(Klass, Klass)> {
352306
// CHECK: bb0([[ARG:%.*]] : @guaranteed $Klass):
353307
// CHECK-NOT: unchecked_bitwise_cast
@@ -404,17 +358,6 @@ bbExitBlock(%result : @owned $FakeOptional<(Klass, Klass)>):
404358
return %result : $FakeOptional<(Klass, Klass)>
405359
}
406360

407-
// CHECK-LABEL: sil [ossa] @unowned_to_guaranteed_rauw_3 : $@convention(thin) (@guaranteed Klass) -> Klass {
408-
// CHECK: bb0(
409-
// CHECK-NEXT: return
410-
// CHECK: } // end sil function 'unowned_to_guaranteed_rauw_3'
411-
sil [ossa] @unowned_to_guaranteed_rauw_3 : $@convention(thin) (@guaranteed Klass) -> Klass {
412-
bb0(%0 : @guaranteed $Klass):
413-
%1 = unchecked_bitwise_cast %0 : $Klass to $SubKlass
414-
%2 = unchecked_bitwise_cast %1 : $SubKlass to $Klass
415-
return %2 : $Klass
416-
}
417-
418361
//===---
419362
// Guaranteed Tests
420363
//

test/SILOptimizer/sil_combine_ossa.sil

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,18 +1604,6 @@ bb0(%0 : @guaranteed $B):
16041604
return %3 : $F
16051605
}
16061606

1607-
// CHECK-LABEL: sil [ossa] @unchecked_ref_cast_formation_unowned : $@convention(thin) (B) -> F {
1608-
// CHECK: bb0([[INPUT_REF:%[0-9]+]] :
1609-
// CHECK: ref_to_raw_pointer
1610-
// CHECK: raw_pointer_to_ref
1611-
// CHECK: } // end sil function 'unchecked_ref_cast_formation_unowned'
1612-
sil [ossa] @unchecked_ref_cast_formation_unowned : $@convention(thin) (B) -> F {
1613-
bb0(%0 : @unowned $B):
1614-
%1 = ref_to_raw_pointer %0 : $B to $Builtin.RawPointer
1615-
%2 = raw_pointer_to_ref %1 : $Builtin.RawPointer to $F
1616-
return %2 : $F
1617-
}
1618-
16191607
// CHECK-LABEL: sil [ossa] @upcast_unchecked_ref_cast_roundtrip : $@convention(thin) (@owned B) -> @owned B {
16201608
// CHECK-NOT: unchecked_ref_cast
16211609
// CHECK-NOT: upcast
@@ -2745,27 +2733,6 @@ class XXImpl : XX {
27452733
init()
27462734
}
27472735

2748-
// CHECK-LABEL: sil [ossa] @unowned_round_trips : $@convention(thin) (@guaranteed B, @guaranteed @sil_unowned B, @guaranteed AnyObject, @sil_unmanaged AnyObject) -> (B, @sil_unowned B, AnyObject, @sil_unmanaged AnyObject) {
2749-
// CHECK: bb0(
2750-
// CHECK-NEXT: tuple
2751-
// CHECK-NEXT: return
2752-
// CHECK: } // end sil function 'unowned_round_trips'
2753-
sil [ossa] @unowned_round_trips : $@convention(thin) (@guaranteed B, @guaranteed @sil_unowned B, @guaranteed AnyObject, @sil_unmanaged AnyObject) -> (B, @sil_unowned B, AnyObject, @sil_unmanaged AnyObject) {
2754-
bb0(%0 : @guaranteed $B, %1 : @guaranteed $@sil_unowned B, %2 : @guaranteed $AnyObject, %3 : $@sil_unmanaged AnyObject):
2755-
%4 = ref_to_unowned %0 : $B to $@sil_unowned B
2756-
%5 = unowned_to_ref %4 : $@sil_unowned B to $B
2757-
%6 = unowned_to_ref %1 : $@sil_unowned B to $B
2758-
%7 = ref_to_unowned %6 : $B to $@sil_unowned B
2759-
2760-
%8 = ref_to_unmanaged %2 : $AnyObject to $@sil_unmanaged AnyObject
2761-
%9 = unmanaged_to_ref %8 : $@sil_unmanaged AnyObject to $AnyObject
2762-
%10 = unmanaged_to_ref %3 : $@sil_unmanaged AnyObject to $AnyObject
2763-
%11 = ref_to_unmanaged %10 : $AnyObject to $@sil_unmanaged AnyObject
2764-
2765-
%9999 = tuple(%5 : $B, %7 : $@sil_unowned B, %9 : $AnyObject, %11 : $@sil_unmanaged AnyObject)
2766-
return %9999 : $(B, @sil_unowned B, AnyObject, @sil_unmanaged AnyObject)
2767-
}
2768-
27692736
// CHECK-LABEL: sil [ossa] @collapse_existential_pack_unpack_unchecked_ref_cast :
27702737
// CHECK: bb0([[Ref:%.*]] : @guaranteed $MyClass):
27712738
// CHECK-NOT: init_existential_ref

test/SILOptimizer/simplify_unconditional_check_cast.sil

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ bb0(%0 : $@thick T.Type):
3838
}
3939

4040

41-
// CHECK-LABEL: sil [ossa] @test_non_metatype :
42-
// CHECK: %1 = unconditional_checked_cast %0
43-
// CHECK-NEXT: return %1
44-
// CHECK: } // end sil function 'test_non_metatype'
45-
sil [ossa] @test_non_metatype : $@convention(thin) (@guaranteed C) -> any PC {
46-
bb0(%0 : @guaranteed $C):
47-
%1 = unconditional_checked_cast %0 to any PC
48-
return %1
49-
}
50-
5141
// CHECK-LABEL: sil [ossa] @test_non_existential_target :
5242
// CHECK: %1 = unconditional_checked_cast %0
5343
// CHECK-NEXT: return %1

test/SILOptimizer/simplify_value_to_bridge_object.sil

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,3 @@ bb0(%0 : $Builtin.Int64):
1717
%4 = value_to_bridge_object %3 : $Builtin.Int64
1818
return %4 : $Builtin.BridgeObject
1919
}
20-
21-
// CHECK-LABEL: sil [ossa] @keep_both_vtbo_instructions
22-
// CHECK: %1 = value_to_bridge_object %0
23-
// CHECK: %2 = value_to_bridge_object %0
24-
// CHECK: %3 = tuple (%1 : $Builtin.BridgeObject, %2 : $Builtin.BridgeObject)
25-
// CHECK: return %3
26-
// CHECK: } // end sil function 'keep_both_vtbo_instructions'
27-
sil [ossa] @keep_both_vtbo_instructions : $@convention(thin) (Builtin.Int64) -> (Builtin.BridgeObject, Builtin.BridgeObject) {
28-
bb0(%0 : $Builtin.Int64):
29-
%1 = value_to_bridge_object %0 : $Builtin.Int64
30-
%2 = unchecked_trivial_bit_cast %1 : $Builtin.BridgeObject to $UInt64
31-
%3 = struct_extract %2 : $UInt64, #UInt64._value
32-
%4 = value_to_bridge_object %3 : $Builtin.Int64
33-
%5 = tuple (%1 : $Builtin.BridgeObject, %4 : $Builtin.BridgeObject)
34-
return %5 : $(Builtin.BridgeObject, Builtin.BridgeObject)
35-
}
36-

0 commit comments

Comments
 (0)