Skip to content

[Constant Evaluator][Tests] Add tests to check constant evaluability of Swift code snippets #27208

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

Conversation

ravikandhadai
Copy link
Contributor

@ravikandhadai ravikandhadai commented Sep 17, 2019

This PR adds a new sil-opt pass: ConstantEvaluableSubsetCheck.cpp to check constant evaluability of Swift code snippets. This pass is only used in tests and will eventually replace pound_assert.swift tests.

This PR also adds a new test: constant_evaluable_subset_test.swift that contains Swift code snippets that are expected to be constant evaluable and those that are not. The goal of this test is to document Swift code snippets known to be constant evaluable (and not) and catch any regressions in the SILGen and mandatory passes that could change the constant evaluability of these code snippets.

(See only the most recent commit in this PR, which has the relevant changes.)

1. builtin "int_expect", which makes the evaluator work on more
integer operations such as left/right shift (with traps) and
integer conversions.

2. builtin "_assertConfiguration", which enables the evaluator
to work with debug stdlib.

3. builtin "ptrtoint", which enables the evaluator to track
StaticString

4. _assertionFailure API, which enables the evaluator to report
stdlib assertion failures encountered during constant evaluation.

Also, enable attaching auxiliary data with the enum "UnknownReason"
and use it to improve diagnostics for UnknownSymbolicValues,
which represent failures during constant evaluation.
@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test

…ility

of Swift code snippets. Add a new test: constant_evaluable_subset_test.swift
that tests Swift code snippets that are expected to be constant evaluable and
those that are not.
@ravikandhadai ravikandhadai force-pushed the constexpr-fragment-check branch from 37736f3 to 032442d Compare September 17, 2019 01:49
@ravikandhadai
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 37736f3efdad32c4d60be71d79732a53eb0f1e0b

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 37736f3efdad32c4d60be71d79732a53eb0f1e0b

@ravikandhadai ravikandhadai merged commit bcafb78 into swiftlang:master Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants