Skip to content

[ownership] Now that we can run -Onone tests with both ownership and … #27091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions test/SILOptimizer/pound_assert.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %target-swift-frontend -enable-experimental-static-assert -emit-sil %s -verify
// RUN: %target-swift-frontend -enable-experimental-static-assert -enable-ownership-stripping-after-serialization -emit-sil %s -verify

// REQUIRES: optimized_stdlib
// REQUIRES: asserts
Expand Down Expand Up @@ -67,18 +68,6 @@ func test_loops() {
#assert(infiniteLoop() == 1)
}

// NOTE: We currently hit the limit of 512 on a debug_value in the prelude of
// this function. TODO: What is the right thing to do here?
func recursive(a: Int) -> Int { // expected-note {{limit exceeded here}}
return a == 0 ? 0 : recursive(a: a-1)
}

func test_recursive() {
// expected-error @+2 {{#assert condition not constant}}
// expected-note @+1 {{exceeded instruction limit: 512 when evaluating the expression at compile time}}
#assert(recursive(a: 20000) > 42)
}

func conditional(_ x: Int) -> Int {
if x < 0 {
return 0
Expand Down
22 changes: 22 additions & 0 deletions test/SILOptimizer/pound_assert_test_recursive.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: not %target-swift-frontend -enable-experimental-static-assert -emit-sil %s 2>&1 | %FileCheck %s
// RUN: not %target-swift-frontend -enable-experimental-static-assert -enable-ownership-stripping-after-serialization -emit-sil %s 2>&1 | %FileCheck %s

// This is a special FileCheck test for testing that we properly catch that we
// are recursing here. The reason why this is separate from the other
// pound_assert tests is that the "limit exceeded" here diagnostic can vary
// depending on the codegen since we are using an arbitrary limit of 512. If the
// codegen changes, the line where we stop evaluating can change meaning that
// the note moves around lines. With FileCheck we have more flexibility to just
// match what we actually want.

// CHECK: error: #assert condition not constant
// CHECK: note: exceeded instruction limit: 512 when evaluating the expression at compile time
// CHECK: limit exceeded here
func recursive(a: Int) -> Int {
return a == 0 ? 0 : recursive(a: a-1)
}

func test_recursive() {
#assert(recursive(a: 20000) > 42)
}