Skip to content

Commit af86ad1

Browse files
committed
Test predictable memopt mark_dependence semantics.
Unit tests for mark_dependence support. Required to fix unsafeAddress.
1 parent 19c1617 commit af86ad1

File tree

5 files changed

+582
-5
lines changed

5 files changed

+582
-5
lines changed

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,18 @@ struct AvailableValueDataflowFixup: AvailableValueFixup {
485485

486486
// Verify ownership of promoted instructions in asserts builds or when
487487
// -sil-verify-all is set.
488+
//
489+
// Clears insertedInsts.
488490
void verifyOwnership(DeadEndBlocks &deBlocks);
489491

490-
/// Fix ownership of inserted instructions and delete dead instructions.
492+
// Fix ownership of inserted instructions and delete dead instructions.
493+
//
494+
// Clears insertedInsts.
491495
void fixupOwnership(InstructionDeleter &deleter,
492496
DeadEndBlocks &deBlocks);
493497

498+
// Deletes all insertedInsts without fixing ownership.
499+
// Clears insertedInsts.
494500
void deleteInsertedInsts(InstructionDeleter &deleter);
495501
};
496502

@@ -532,6 +538,7 @@ void AvailableValueDataflowFixup::verifyOwnership(DeadEndBlocks &deBlocks) {
532538
result.verifyOwnership(&deBlocks);
533539
}
534540
}
541+
insertedInsts.clear();
535542
}
536543

537544
// In OptimizationMode::PreserveAlloc, delete any inserted instructions that are

test/SILOptimizer/constant_evaluable_subset_test.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
// especially performance inlining as it inlines functions such as String.+=
1515
// that the evaluator has special knowledge about.
1616
//
17-
// RUN: not %target-sil-opt -opt-mode=speed -silgen-cleanup -diagnose-invalid-escaping-captures -diagnose-static-exclusivity -capture-promotion -access-enforcement-selection -allocbox-to-stack -noreturn-folding -definite-init -raw-sil-inst-lowering -closure-lifetime-fixup -semantic-arc-opts -ownership-model-eliminator -mandatory-inlining -predictable-memaccess-opts -os-log-optimization -diagnostic-constant-propagation -predictable-deadalloc-elim -mandatory-arc-opts -diagnose-unreachable -diagnose-infinite-recursion -yield-once-check -dataflow-diagnostics -split-non-cond_br-critical-edges -constexpr-limit 3000 -test-constant-evaluable-subset %t/constant_evaluable_subset_test_silgen.sil > /dev/null 2> %t/error-output-mandatory
17+
// RUN: not %target-sil-opt -opt-mode=speed -silgen-cleanup -diagnose-invalid-escaping-captures -diagnose-static-exclusivity -capture-promotion -access-enforcement-selection -allocbox-to-stack -noreturn-folding -definite-init -raw-sil-inst-lowering -closure-lifetime-fixup -semantic-arc-opts -mandatory-inlining -predictable-memaccess-opts -os-log-optimization -diagnostic-constant-propagation -predictable-deadalloc-elim -mandatory-arc-opts -diagnose-unreachable -diagnose-infinite-recursion -yield-once-check -dataflow-diagnostics -split-non-cond_br-critical-edges -constexpr-limit 3000 -test-constant-evaluable-subset %t/constant_evaluable_subset_test_silgen.sil > /dev/null 2> %t/error-output-mandatory
1818
//
1919
// RUN: %FileCheck %S/Inputs/constant_evaluable.swift < %t/error-output-mandatory

test/SILOptimizer/lifetime_dependence/lifetime_dependence_scope_fixup.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ func test6(_ a: Array<Int>) {
156156

157157
// CHECK-LABEL: sil hidden @$s31lifetime_dependence_scope_fixup5test7yySWF : $@convention(thin) (UnsafeRawBufferPointer) -> () {
158158
// CHECK: [[CONT:%.*]] = alloc_stack [var_decl] $View
159+
// function_ref View.init(_:_:)
160+
// CHECK: [[VIEW1:%.*]] = apply %{{.*}}(%0, %{{.*}}, %{{.*}}) : $@convention(method) (UnsafeRawBufferPointer, Int, @thin View.Type) -> @lifetime(borrow 0) @owned View // users: %14, %9, %12, %8
159161
// CHECK: [[BA:%.*]] = begin_access [read] [static] [[CONT]] : $*View
160-
// CHECK: [[LD:%.*]] = load [[BA]] : $*View
161162
// CHECK: [[FUNC:%.*]] = function_ref @$s31lifetime_dependence_scope_fixup16getBorrowingViewyAA0G0VADF : $@convention(thin) (@guaranteed View) -> @lifetime(borrow 0) @owned View
162-
// CHECK: [[VIEW:%.*]] = apply [[FUNC]]([[LD]]) : $@convention(thin) (@guaranteed View) -> @lifetime(borrow 0) @owned View
163-
// CHECK: [[MDI:%.*]] = mark_dependence [nonescaping] [[VIEW]] : $View on [[BA]] : $*View
163+
// CHECK: [[VIEW2:%.*]] = apply [[FUNC]]([[VIEW1]]) : $@convention(thin) (@guaranteed View) -> @lifetime(borrow 0) @owned View
164+
// CHECK: [[MDI:%.*]] = mark_dependence [nonescaping] [[VIEW2]] : $View on [[BA]] : $*View
164165
// CHECK: [[USE:%.*]] = function_ref @$s31lifetime_dependence_scope_fixup3useyyAA4ViewVF : $@convention(thin) (@guaranteed View) -> ()
165166
// CHECK: apply [[USE]]([[MDI]]) : $@convention(thin) (@guaranteed View) -> ()
166167
// CHECK: release_value [[MDI]] : $View

0 commit comments

Comments
 (0)