Skip to content

Commit 30f59c7

Browse files
committed
Remove an assert from visitForwardedGuaranteedOperands
Some guaranteed forwarding instructions have multiple operands: mark_dependence, ref_to_bridge_object. The corresponding instruction types checked here already have documentation that the forwarded operand is the first operand. The assert is overly cautious, and checking for indiviudal opcodes would be tedious maintenance.
1 parent 447e524 commit 30f59c7

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/SIL/Utils/OwnershipUtils.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,8 +1779,6 @@ bool swift::visitForwardedGuaranteedOperands(
17791779
|| isa<OwnershipForwardingMultipleValueInstruction>(inst)
17801780
|| isa<MoveOnlyWrapperToCopyableValueInst>(inst)
17811781
|| isa<CopyableToMoveOnlyWrapperValueInst>(inst)) {
1782-
assert(inst->getNumRealOperands() == 1
1783-
&& "forwarding instructions must have a single real operand");
17841782
assert(!isa<SingleValueInstruction>(inst)
17851783
|| !BorrowedValue(cast<SingleValueInstruction>(inst))
17861784
&& "forwarded operand cannot begin a borrow scope");

test/SILOptimizer/borrow_introducer_unit.sil

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,29 @@ exit:
222222
%retval = tuple ()
223223
return %retval : $()
224224
}
225+
226+
// CHECK-LABEL: begin running test 1 of 1 on introducer_dependence: find-borrow-introducers with: @trace[0]
227+
// CHECK: Introducers:
228+
// CHECK: %0 = argument of bb0 : $C
229+
// CHECK-LABEL: end running test 1 of 1 on introducer_dependence: find-borrow-introducers with: @trace[0]
230+
sil [ossa] @introducer_dependence : $@convention(thin) (@guaranteed C, @guaranteed Builtin.NativeObject) -> () {
231+
entry(%0 : @guaranteed $C, %1 : @guaranteed $Builtin.NativeObject):
232+
test_specification "find-borrow-introducers @trace[0]"
233+
%dependent = mark_dependence %0 : $C on %1 : $Builtin.NativeObject
234+
debug_value [trace] %dependent : $C
235+
%retval = tuple ()
236+
return %retval : $()
237+
}
238+
239+
// CHECK-LABEL: begin running test 1 of 1 on introducer_bridge: find-borrow-introducers with: @trace[0]
240+
// CHECK: Introducers:
241+
// CHECK: %0 = argument of bb0 : $C
242+
// CHECK-LABEL: end running test 1 of 1 on introducer_bridge: find-borrow-introducers with: @trace[0]
243+
sil [ossa] @introducer_bridge : $@convention(thin) (@guaranteed C, Builtin.Word) -> () {
244+
entry(%0 : @guaranteed $C, %1 : $Builtin.Word):
245+
test_specification "find-borrow-introducers @trace[0]"
246+
%bridge = ref_to_bridge_object %0 : $C, %1 : $Builtin.Word
247+
debug_value [trace] %bridge : $Builtin.BridgeObject
248+
%retval = tuple ()
249+
return %retval : $()
250+
}

0 commit comments

Comments
 (0)