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
123123
124124 // If we have an inout parameter that isn't ever actually written to, return
125125 // false.
126- if (arg->getKnownParameterInfo ().isIndirectMutating ()) {
126+ if (!arg->isIndirectResult () &&
127+ arg->getKnownParameterInfo ().isIndirectMutating ()) {
127128 auto wellBehavedWrites = ctx.addressToExhaustiveWriteListCache .get (arg);
128129 if (!wellBehavedWrites.hasValue ()) {
129130 return answer (true );
Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ final class Klass {
5656extension Klass : MyFakeAnyObject {
5757 func myFakeMethod()
5858}
59+
60+ struct NonTrivialStruct {
61+ var val: Klass
62+ }
63+
5964sil @guaranteed_klass_user : $@convention(thin) (@guaranteed Klass) -> ()
6065sil @guaranteed_fakeoptional_klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
6166sil @guaranteed_fakeoptional_classlet_user : $@convention(thin) (@guaranteed FakeOptional<ClassLet>) -> ()
@@ -1496,3 +1501,16 @@ bb3:
14961501 %9999 = tuple()
14971502 return %9999 : $()
14981503}
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