Skip to content
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

SMTChecker: Ignore errors that might occur during constant evaluation #15863

Merged
merged 2 commits into from
Feb 17, 2025

Conversation

blishko
Copy link
Contributor

@blishko blishko commented Feb 14, 2025

Previously, if a fatal error would occur during constant evaluation in the model checker, it would throw an exception which the model checker would let escape and crash the compiler.

We introduce a new API to ConstantEvaluator that swallows any errors use it from the model checker.
This allows model checker to continue, treating any expression where an error would occur simply as not constant.

Fixes #15600 #15601 #15722.

Resolves point 3 of @cameel 's analysis in #15709.

cameel
cameel previously approved these changes Feb 14, 2025
Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some suggestions, but nothing critical. Overall looks good.

ErrorList l;
ErrorReporter e(l);
if (auto t = ConstantEvaluator::evaluate(e, _expr))
if (auto t = ConstantEvaluator::tryEvaluate(_expr))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have the helper, we should use it in StaticAnalyzer::visit(BinaryOperation) as well. Though that needs a changelog entry and some tests so maybe it's better off done in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this should be done in a separate PR.

@blishko blishko force-pushed the smt-fix-constant-evaluation branch 2 times, most recently from f824f3b to cb5d6a5 Compare February 16, 2025 17:17
@blishko blishko requested a review from cameel February 16, 2025 17:17
cameel
cameel previously approved these changes Feb 17, 2025
Previously, if a fatal error would occur during constant evaluation in
the model checker, it would throw an exception which the model checker
would let escape and crash the compiler.
We now use the new API that swallows any errors and the model checker
can continue, simply treating the expression as not constant.
@blishko blishko force-pushed the smt-fix-constant-evaluation branch from 74b9c33 to de36f55 Compare February 17, 2025 13:48
@blishko blishko enabled auto-merge February 17, 2025 14:04
@blishko blishko merged commit 7203070 into develop Feb 17, 2025
74 checks passed
@blishko blishko deleted the smt-fix-constant-evaluation branch February 17, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment