-
Notifications
You must be signed in to change notification settings - Fork 277
C front-end: evaluate __builtin_clz over constants #5735
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
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5735 +/- ##
============================================
- Coverage 69.54% 32.22% -37.33%
============================================
Files 1243 985 -258
Lines 100700 83689 -17011
============================================
- Hits 70036 26970 -43066
- Misses 30664 56719 +26055
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
4ad93ad
to
499b63a
Compare
We seem to have a variety of ways to assert that something can be simplified, and perhaps we should consolidate. This test, I believe, introduces a new way. |
499b63a
to
74eea92
Compare
You're of course right, this is a much better approach. Done. |
74eea92
to
5d1f9f5
Compare
!int_constant.has_value() || *int_constant == 0 || | ||
argument.type().id() != ID_unsignedbv) | ||
{ | ||
return nil_exprt{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That just means it will be treated as a regular function call, not a "special function." So we fall back to using the library implementation.
^warning: ignoring | ||
-- | ||
For this example, __builtin_clz is fully evaluated in the front-end. This test | ||
ensures that the function call no longer shows up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it actually check that the function call is gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out this outdated comment! This is now fixed.
This avoids warnings about missing declarations.
The Linux kernel uses __builtin_clz{,l,ll} in expressions that are expected to be compile-time constants. To support this, evaluate such expressions during type checking.
5d1f9f5
to
fef9e89
Compare
The Linux kernel uses __builtin_clz(ll) in expressions that are expected
to be compile-time constants. To support this, evaluate such expressions
during type checking.