Skip to content

Commit f53525b

Browse files
committed
Revert "[ownership] Ignore non-consuming uses in dead end blocks when we are analyzing objects that are consumed once in the same block in which they are defined."
This reverts commit 9a67f2d.
1 parent 7a28a02 commit f53525b

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

lib/SIL/LinearLifetimeChecker.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,11 @@ LinearLifetimeError swift::valueHasLinearLifetime(
486486
// have been detected by initializing our consuming uses. So we are done.
487487
if (consumingUses.size() == 1 &&
488488
consumingUses[0].getParent() == value->getParentBlock()) {
489-
// Check if any of our non consuming uses are not in the parent block and
490-
// are reachable. We flag those as additional use after frees. Any in the
491-
// same block, we would have flagged.
489+
// Check if any of our non consuming uses are not in the parent block. We
490+
// flag those as additional use after frees. Any in the same block, we would
491+
// have flagged.
492492
if (llvm::any_of(nonConsumingUses, [&](BranchPropagatedUser user) {
493-
return user.getParent() != value->getParentBlock() &&
494-
!deBlocks.isDeadEnd(user.getParent());
493+
return user.getParent() != value->getParentBlock();
495494
})) {
496495
state.error.handleUseAfterFree([&] {
497496
llvm::errs() << "Function: '" << value->getFunction()->getName()

test/SIL/ownership-verifier/use_verifier.sil

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ sil @unowned_tuple_user : $@convention(thin) ((Builtin.Int32, Builtin.NativeObje
105105
sil @produce_owned_optional : $@convention(thin) () -> @owned Optional<Builtin.NativeObject>
106106
sil @guaranteed_nativeobject_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
107107

108-
class UnsafeUnownedFieldKlass {
109-
unowned(safe) var x: @sil_unowned Builtin.NativeObject
110-
}
111-
112108
////////////////
113109
// Test Cases //
114110
////////////////
@@ -1160,26 +1156,3 @@ bb0:
11601156
%9999 = tuple()
11611157
return %9999 : $()
11621158
}
1163-
1164-
// Make sure that we do not false positive due to borrow users of %12 in an
1165-
// unreachable block.
1166-
sil [ossa] @test_unreachable_users : $@convention(method) (@guaranteed UnsafeUnownedFieldKlass) -> () {
1167-
bb0(%0 : @guaranteed $UnsafeUnownedFieldKlass):
1168-
%3 = ref_element_addr %0 : $UnsafeUnownedFieldKlass, #UnsafeUnownedFieldKlass.x
1169-
%4 = load_borrow %3 : $*@sil_unowned Builtin.NativeObject
1170-
%5 = copy_unowned_value %4 : $@sil_unowned Builtin.NativeObject
1171-
end_borrow %4 : $@sil_unowned Builtin.NativeObject
1172-
%12 = begin_borrow %5 : $Builtin.NativeObject
1173-
%func = function_ref @guaranteed_nativeobject_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
1174-
apply %func(%12) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
1175-
end_borrow %12 : $Builtin.NativeObject
1176-
destroy_value %5 : $Builtin.NativeObject
1177-
%36 = tuple ()
1178-
return %36 : $()
1179-
1180-
bb1:
1181-
%func2 = function_ref @guaranteed_nativeobject_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
1182-
apply %func2(%12) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
1183-
unreachable
1184-
}
1185-

0 commit comments

Comments
 (0)