Skip to content

Commit 6e48e05

Browse files
committed
[Test] Fix shrink_borrow_scope.
1 parent 7e05f1d commit 6e48e05

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

lib/SILOptimizer/Utils/ShrinkBorrowScope.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -501,35 +501,28 @@ bool swift::shrinkBorrowScope(
501501
namespace swift::test {
502502
// Arguments:
503503
// - BeginBorrowInst - the introducer for the scope to shrink
504-
// - bool - the expected return value of shrinkBorrowScope
505-
// - variadic list of values consisting of the copies expected to be rewritten
506504
// Dumps:
507505
// - DELETED: <<instruction deleted>>
508506
static FunctionTest ShrinkBorrowScopeTest(
509-
"shrink-borrow-scope", [](auto &function, auto &arguments, auto &test) {
507+
"shrink_borrow_scope", [](auto &function, auto &arguments, auto &test) {
510508
auto instruction = arguments.takeValue();
511-
auto expected = arguments.takeBool();
512509
auto *bbi = cast<BeginBorrowInst>(instruction);
513510
auto *analysis = test.template getAnalysis<BasicCalleeAnalysis>();
514511
SmallVector<CopyValueInst *, 4> modifiedCopyValueInsts;
515512
InstructionDeleter deleter(
516513
InstModCallbacks().onDelete([&](auto *instruction) {
517514
llvm::outs() << "DELETED:\n";
518515
instruction->print(llvm::outs());
516+
instruction->eraseFromParent();
517+
519518
}));
520519
auto shrunk =
521520
shrinkBorrowScope(*bbi, deleter, analysis, modifiedCopyValueInsts);
522-
unsigned index = 0;
521+
auto *shrunkString = shrunk ? "shrunk" : "did not shrink";
522+
llvm::outs() << "Result: " << shrunkString << "\n";
523+
llvm::outs() << "Rewrote the following copies:\n";
523524
for (auto *cvi : modifiedCopyValueInsts) {
524-
auto expectedCopy = arguments.takeValue();
525-
llvm::outs() << "rewritten copy " << index << ":\n";
526-
llvm::outs() << "expected:\n";
527-
expectedCopy->print(llvm::outs());
528-
llvm::outs() << "got:\n";
529525
cvi->print(llvm::outs());
530-
assert(cvi == expectedCopy);
531-
++index;
532526
}
533-
assert(expected == shrunk && "didn't shrink expectedly!?");
534527
});
535528
} // namespace swift::test

test/SILOptimizer/shrink_borrow_scope.unit.sil

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ sil [ossa] @callee_guaranteed: $@convention(thin) (@guaranteed C) -> ()
1111
// CHECK-LABEL: begin running test 1 of {{[^,]+}} on nohoist_over_rewritten_copy
1212
// CHECK-NOT: DELETED:
1313
// CHECK-NOT: end_borrow
14+
// CHECK: Result: did not shrink
1415
// CHECK-LABEL: end running test 1 of {{[^,]+}} on nohoist_over_rewritten_copy
1516
sil [ossa] @nohoist_over_rewritten_copy : $@convention(thin) () -> (@owned C, @owned C) {
1617
entry:
17-
specify_test "shrink-borrow-scope @trace true @trace[1]"
18+
specify_test "shrink_borrow_scope %lifetime"
1819
%get_owned_c = function_ref @get_owned_c : $@convention(thin) () -> (@owned C)
1920
%instance = apply %get_owned_c() : $@convention(thin) () -> (@owned C)
2021
%lifetime = begin_borrow [lexical] %instance : $C

0 commit comments

Comments
 (0)