File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
lib/SILOptimizer/SemanticARC Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,8 @@ class StorageGuaranteesLoadVisitor
123
123
124
124
// If we have an inout parameter that isn't ever actually written to, return
125
125
// false.
126
- if (arg->getKnownParameterInfo ().isIndirectMutating ()) {
126
+ if (!arg->isIndirectResult () &&
127
+ arg->getKnownParameterInfo ().isIndirectMutating ()) {
127
128
auto wellBehavedWrites = ctx.addressToExhaustiveWriteListCache .get (arg);
128
129
if (!wellBehavedWrites.hasValue ()) {
129
130
return answer (true );
Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ final class Klass {
56
56
extension Klass : MyFakeAnyObject {
57
57
func myFakeMethod()
58
58
}
59
+
60
+ struct NonTrivialStruct {
61
+ var val: Klass
62
+ }
63
+
59
64
sil @guaranteed_klass_user : $@convention(thin) (@guaranteed Klass) -> ()
60
65
sil @guaranteed_fakeoptional_klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
61
66
sil @guaranteed_fakeoptional_classlet_user : $@convention(thin) (@guaranteed FakeOptional<ClassLet>) -> ()
@@ -1496,3 +1501,16 @@ bb3:
1496
1501
%9999 = tuple()
1497
1502
return %9999 : $()
1498
1503
}
1504
+
1505
+ // Make sure we don't crash on this code. We used to crash for @out args on the access path to the load
1506
+ sil [ossa] @test_opt_out_arg : $@convention(thin)(@in NonTrivialStruct) -> (@out NonTrivialStruct) {
1507
+ bb0(%0 : $*NonTrivialStruct, %1 : $*NonTrivialStruct):
1508
+ copy_addr %1 to [initialization] %0 : $*NonTrivialStruct
1509
+ %ele = struct_element_addr %0 : $*NonTrivialStruct, #NonTrivialStruct.val
1510
+ %ld = load [copy] %ele : $*Klass
1511
+ destroy_value %ld : $Klass
1512
+ destroy_addr %1 : $*NonTrivialStruct
1513
+ %9999 = tuple()
1514
+ return %9999 : $()
1515
+ }
1516
+
You can’t perform that action at this time.
0 commit comments