Math library models: add missing *BSD variants, cleanup#9020
Math library models: add missing *BSD variants, cleanup#9020tautschnig wants to merge 2 commits into
Conversation
BSD systems appear to use `__` prefixed variants of several functions. Define these as needed. Also, avoid handling some GCC-style `__builtin_`-prefixed functions via models when others are done directly in the type checker: do all of them in the type checker. In addition to `__builtin_isfinite`, recognise its older glibc internal aliases `__builtin_finite`, `__builtin_finitef` and `__builtin_finitel` in the same isfinite_exprt branch of the type checker. Some glibc `<bits/mathcalls-helper-functions.h>` headers expose the legacy `finite()` API via these builtins, and without recognition CBMC would otherwise treat them as body-less functions returning nondet. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds BSD-style __-prefixed math library models (e.g., __isfinite, __isnand, __isnormal, __signbitl, __isfinitef/l), moves several GCC __builtin_* functions (fabs variants, isnan/isinf/finite variants) from library models into the C type checker for consistent direct handling, and replaces internal uses of __builtin_inf* in math.c with __CPROVER_inf*. Updates library_check.sh to filter the newly added/relocated symbols, and replaces the old KNOWNBUG placeholder tests with real assertion-based regression tests.
Changes:
- Add BSD
__-prefixed math library function models and remove__builtin_fabs[fl]models now handled in the type checker. - Extend
c_typecheck_exprto recognize__builtin_fabs[fl],__builtin_isnan[fl],__builtin_isinf[fl],__builtin_isfinite,__builtin_finite[fl]directly. - Replace
KNOWNBUGregression stubs with real assertion-based tests for isfinite/isinf/isnormal/signbit/fpclassify and their__/__builtin_variants; updatelibrary_check.shfilters accordingly.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ansi-c/library/math.c | Remove __builtin_fabs* models, add BSD __isfinite*/__isnand/__isnormal*/__signbitl, replace __builtin_inf* calls with __CPROVER_inf*. |
| src/ansi-c/c_typecheck_expr.cpp | Extend special-function handling for __builtin_fabs/isnan/isinf/isfinite/finite variants. |
| src/ansi-c/library_check.sh | Filter additional __-prefixed and is*[fl] symbols added in models. |
| regression/cbmc-library/isfinite/{main.c,test.desc} | Replace KNOWNBUG stub with real isfinite assertions; promote to CORE. |
| regression/cbmc-library/isnormal/{main.c,test.desc} | Replace stub with __builtin_isnormal static-assert test; promote to CORE. |
| regression/cbmc-library/isinf/main.c | Add __builtin_isinf / __builtin_isinf_sign runtime and static assertions. |
| regression/cbmc-library/signbit/main.c | Add real signbit assertions for double and long double. |
| regression/cbmc-library/__fpclassify/main.c | Add fpclassify and __builtin_fpclassify runtime and static assertions. |
| regression/cbmc-library/{__isinf,__isinff,__isinfl,__isnan,__isnanf,__isnanl,__isnormalf,__signbit,__signbitf,__builtin_fabs,__builtin_fabsf,__builtin_fabsl,isinff,isinfl,isnanf,isnanl}/* | Delete obsolete KNOWNBUG placeholder tests now covered by typechecker handling and library_check filters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| perl -p -i -e 's/^__isnan[dfl]?\n//' __functions # isnan | ||
| perl -p -i -e 's/^__isnormal[fl]?\n//' __functions # isnormal | ||
| perl -p -i -e 's/^__printf_chk\n//' __functions # printf/__printf_chk.desc | ||
| perl -p -i -e 's/^__signbit[fl]?\n//' __functions # signbit, __signbitd |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9020 +/- ##
===========================================
- Coverage 80.60% 80.59% -0.01%
===========================================
Files 1711 1711
Lines 189454 189460 +6
Branches 73 73
===========================================
- Hits 152712 152699 -13
- Misses 36742 36761 +19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ifacts
Temporary CI configuration to investigate the x86_64 long double layout
issue surfaced by signbit on macOS 15 Intel. All other PR-triggered
workflows are switched to workflow_dispatch only. pull-request-checks.yaml
now has only two jobs:
* debug-macos-15-intel: builds cbmc with Make, then collects the SDK
deployment macros, the native byte representation of long double on
real hardware, the preprocessed signbit/main.c, the cbmc trace and
show-goto-functions output, plus a manual-union repro that prints
the bytes CBMC stores for -1.0L.
* debug-macos-14-arm: same diagnostic collection, control case where
long double == double and the test passes.
The full original workflow is preserved at
.github/workflows/pull-request-checks.yaml.full and will be restored
once the underlying long double bug is fixed.
Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
BSD systems appear to use
__prefixed variants of several functions. Define these as needed. Also, avoid handling some GCC-style__builtin_-prefixed functions via models when others are done directly in the type checker: do all of them in the type checker.In addition to
__builtin_isfinite, recognise its older glibc internal aliases__builtin_finite,__builtin_finitefand__builtin_finitelin the same isfinite_exprt branch of the type checker. Some glibc<bits/mathcalls-helper-functions.h>headers expose the legacyfinite()API via these builtins, and without recognition CBMC would otherwise treat them as body-less functions returning nondet.