Skip to content

Commit 72029d4

Browse files
committed
Add REQUIRES: swift_stdlib_no_asserts to dead_array_elim.swift
One of the subtests cannot be fully optimized without swift_stdlib_no_asserts because, with runtime verification enabled, "array.finalize" becomes a mutating operation, preventing SILCombine from deleting it when it removes dead pure instructions. After inlining, DeadObjectElimination is still unable to remove the array because a second array is initialized by copying the first. This problem can be overcome by handling non-trivial stores in OSSA, as described here: [OSSA] Improve DeadObjectElimination to handle array copies https://bugs.swift.org/browse/SR-13782
1 parent 40afb68 commit 72029d4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

test/SILOptimizer/OSLogFullOptTest.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-swift-frontend -emit-ir -swift-version 5 -O -primary-file %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
22
//
33
// REQUIRES: VENDOR=apple
4+
// REQUIRES: swift_stdlib_no_asserts
45

56
// This tests the optimality of the IR generated for the new os log APIs. This
67
// is not testing the output of a specific optimization pass (which has separate
@@ -9,6 +10,13 @@
910
// os log APIs. TODO: eventually these optimization should also happen in Onone
1011
// mode.
1112

13+
// With stdlib asserts, this test exhibits the same problem as
14+
// dead_array_elim.swift. The problem can be overcome by handling
15+
// non-trivial stores in OSSA, as described here:
16+
// [OSSA] Improve DeadObjectElimination to handle array copies
17+
// https://bugs.swift.org/browse/SR-13782
18+
// Once that bug is fixed, remove the requirement: swift_stdlib_no_asserts.
19+
1220
import OSLogTestHelper
1321
import Foundation
1422

test/SILOptimizer/dead_array_elim.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
// RUN: %target-swift-frontend -O -emit-sil -primary-file %s | %FileCheck %s
22

3+
// REQUIRES: swift_stdlib_no_asserts
4+
35
// These tests check whether DeadObjectElimination pass runs as a part of the
46
// optimization pipeline and eliminates dead array literals in Swift code.
57
// Note that DeadObjectElimination pass relies on @_semantics annotations on
68
// the array initializer that is used by the compiler to create array literals.
79
// This test would fail if in case the initializer used by the compiler to
810
// initialize array literals doesn't match the one expected by the pass.
911

12+
// testDeadArrayElimination requires swift_stdlib_no_asserts because,
13+
// with runtime verification enabled, "array.finalize" becomes a
14+
// mutating operation, preventing SILCombine from deleting it when it
15+
// removes dead pure instructions. After inlining,
16+
// DeadObjectElimination is still unable to remove the array because a
17+
// second array is initialized by copying the first. This problem can be
18+
// overcome by handling non-trivial stores in OSSA, as described here:
19+
// [OSSA] Improve DeadObjectElimination to handle array copies
20+
// https://bugs.swift.org/browse/SR-13782
21+
// Once that bug is fixed, remove the requirement: swift_stdlib_no_asserts.
22+
1023
// CHECK-LABEL: sil hidden @$s15dead_array_elim24testDeadArrayEliminationyyF
1124
func testDeadArrayElimination() {
1225
_ = [1, 2, 3]

0 commit comments

Comments
 (0)