Skip to content

Commit 586b42e

Browse files
authored
Merge pull request #23708 from gottesmm/pr-677c6cc4ceb8103971123ee40b6022281bdcdeef
2 parents a9d4c6e + 674721b commit 586b42e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static bool isConsumed(
8989
})) {
9090
forwardingInsts.get()->push_back(user);
9191
for (SILValue v : user->getResults()) {
92+
if (v.getOwnershipKind() != ValueOwnershipKind::Owned)
93+
continue;
9294
copy(v->getUses(), std::back_inserter(worklist));
9395
}
9496
continue;

test/SILOptimizer/semantic-arc-opts.sil

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ struct NativeObjectPair {
1818

1919
class Klass {}
2020

21+
struct MyInt {
22+
var value: Builtin.Int32
23+
}
24+
2125
struct AnotherStruct {
2226
var i : Builtin.Int32
2327
var c : Klass
@@ -378,3 +382,16 @@ bb3:
378382
%9999 = tuple()
379383
return %9999 : $()
380384
}
385+
386+
// CHECK-LABEL: sil [ossa] @do_not_add_trivial_users_of_owned_values_to_isconsumed_worklist : $@convention(thin) (@guaranteed (Klass, MyInt)) -> Builtin.Int32 {
387+
// CHECK-NOT: copy_value
388+
// CHECK-NOT: destroy_value
389+
// CHECK: } // end sil function 'do_not_add_trivial_users_of_owned_values_to_isconsumed_worklist'
390+
sil [ossa] @do_not_add_trivial_users_of_owned_values_to_isconsumed_worklist : $@convention(thin) (@guaranteed (Klass, MyInt)) -> Builtin.Int32 {
391+
bb0(%0 : @guaranteed $(Klass, MyInt)):
392+
%1 = copy_value %0 : $(Klass, MyInt)
393+
(%2, %3) = destructure_tuple %1 : $(Klass, MyInt)
394+
%4 = struct_extract %3 : $MyInt, #MyInt.value
395+
destroy_value %2 : $Klass
396+
return %4 : $Builtin.Int32
397+
}

0 commit comments

Comments
 (0)