aboutsummaryrefslogtreecommitdiff
path: root/libc/fuzzing
AgeCommit message (Collapse)AuthorFilesLines
2024-08-07[libc] math fuzzing MPFR include statement (#102358)RoseZhang033-3/+3
Updated the include statement for MPFR
2024-08-01[libc] created tan function fuzzer (#101570)RoseZhang034-2/+51
Also edited file header formatting on sin_fuz and cos_fuzz
2024-08-01[libc] added cos function fuzzing test (#101556)RoseZhang033-4/+53
2024-08-01[libc] heap_sort_fuzz deleted unnecessary includes (#101535)RoseZhang031-1/+0
Including src/__suppot/macros/config.h is unnecessary
2024-08-01[libc] Fix math fuzzers (#101529)Michael Jones2-3/+5
Fix minor typos that accumulated while the math fuzzers were disabled.
2024-08-01[libc] created fuzz test for sin function (#101411)RoseZhang033-1/+50
Verifies that sin function output is correct by comparing with MPFR output. NaN and inf are not tested (as our output will vary compared to MPFR), and signed zeroes are already tested in unit tests.
2024-07-30[libc] fuzz test for heap_sort (#100826)RoseZhang032-0/+57
Made a fuzz test for heap_sort based off of qsort_fuzz implementation
2024-07-28[libc] Fix the remaining isnan and isinf in tests. (#100969)lntue2-12/+18
Fixes https://github.com/llvm/llvm-project/issues/100964
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek1-2/+3
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini1-3/+2
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek1-2/+3
This is a part of #97655.
2024-05-02[libc] add hashtable fuzzing (#87949)Schrodinger ZHU Yifan3-0/+211
2024-04-06[libc][NFC] Rename `UInt.h` to `big_int.h` and `UInt128.h` to `uint128.h` ↵Guillaume Chatelet2-2/+2
for consistency (#87808)
2024-04-05[libc] Add proxy header math_macros.h. (#87598)lntue4-2/+4
Context: https://github.com/llvm/llvm-project/pull/87017 - Add proxy header `libc/hdr/math_macros.h` that will: - include `<math.h>` in overlay mode, - include `"include/llvm-libc-macros/math-macros.h"` in full build mode. - Its corresponding CMake target `libc.hdr.math_macros` will only depend on `libc.include.math` and `libc.include.llvm-libc-macros.math_macros` in full build mode. - Replace all `#include "include/llvm-libc-macros/math-macros.h"` with `#include "hdr/math_macros.h"`. - Add dependency to `libc.hdr.math_macros` CMake target when using `add_fp_unittest`. - Update the remaining dependency. - Update bazel overlay: add `libc:hdr_math_macros` target, and replacing all dependency on `libc:llvm_libc_macros_math_macros` with `libc:hdr_math_macros`.
2024-04-04[reland][libc] Refactor `BigInt` (#87613)Guillaume Chatelet3-0/+78
This is a reland of #86137 with a fix for platforms / compiler that do not support trivially constructible int128 types.
2024-04-04Revert "[libc] Refactor `BigInt`" (#87612)Guillaume Chatelet3-78/+0
Reverts llvm/llvm-project#86137 Some aarch64 compilers seem to consider that `uint128_t` is not `is_trivially_constructible` which prevents `bit_cast`-ing.
2024-04-04[libc] Refactor `BigInt` (#86137)Guillaume Chatelet3-0/+78
This patch moves most of the multiprecision logic to the `multiword` namespace and simplifies some logic in `BigInt`. It also fully implements the mask and count functions and increases test coverage. `math_extras.h` is also reworked to make it more concise.
2024-03-18[libc] Remove direct math.h includes (#85324)Michael Jones5-7/+4
Reland of #84991 A downstream overlay mode user ran into issues with the isnan macro not working in our sources with a specific libc configuration. This patch replaces the last direct includes of math.h with our internal math_macros.h, along with the necessary build system changes.
2024-02-29[libc] Revert https://github.com/llvm/llvm-project/pull/83199 since it broke ↵lntue1-1/+1
Fuchsia. (#83374) With some header fix forward for GPU builds.
2024-02-27[libc] Add "include/" to the LLVM include directories (#83199)Joseph Huber1-1/+1
Summary: Recent changes added an include path in the float128 type that used the internal `libc` path to find the macro. This doesn't work once it's installed because we need to search from the root of the install dir. This patch adds "include/" to the include path so that our inclusion of installed headers always match the internal use.
2024-02-27[libc] Add fixed point support to printf (#82707)Michael Jones2-0/+147
This patch adds the r, R, k, and K conversion specifiers to printf, with accompanying tests. They are guarded behind the LIBC_COPT_PRINTF_DISABLE_FIXED_POINT flag as well as automatic fixed point support detection.
2024-01-23[reland][libc] Remove unnecessary `FPBits` functions and properties (#79128)Guillaume Chatelet1-1/+1
- reland #79113 - Fix aarch64 RISC-V build
2024-01-23Revert "[libc] Remove unnecessary `FPBits` functions and properties" (#79118)Guillaume Chatelet1-1/+1
Reverts llvm/llvm-project#79113 It broke aarch64 build bot machines.
2024-01-23[libc] Remove unnecessary `FPBits` functions and properties (#79113)Guillaume Chatelet1-1/+1
This patch reduces the surface of `FPBits`.
2024-01-11[libc] Add memcmp / bcmp fuzzers (#77741)Guillaume Chatelet3-0/+129
2024-01-03[libc][NFC] Remove `FloatProperties` (#76508)Guillaume Chatelet1-4/+3
Access is now done through `FPBits` exclusively. This patch also renames a few internal structs and uses `T` instead of `FP` as a template parameter.
2023-12-28[libc][NFC] Integrate `FloatProperties` into `FPBits` (#76506)Guillaume Chatelet2-2/+2
`FloatProperties` is always included when `FPBits` is. This will help further refactoring.
2023-12-15[libc][NFC] Rename `MANTISSA_WIDTH` in `FRACTION_LEN` (#75489)Guillaume Chatelet2-2/+2
This one might be a bit controversial since the terminology has been introduced from the start but I think `FRACTION_LEN` is a better name here. AFAICT it really is "the number of bits after the decimal dot when the number is in normal form." `MANTISSA_WIDTH` is less precise as it's unclear whether we take the leading bit into account. This patch also renames most of the properties to use the `_LEN` suffix and fixes useless casts or variables.
2023-10-16[libc] Add simple long double to printf float fuzz (#68449)michaelrj-google1-6/+24
Recent testing has uncovered some hard-to-find bugs in printf's long double support. This patch adds an extra long double path to the fuzzer with minimal extra effort. While a more thorough long double fuzzer would be useful, it would need to handle the non-standard cases of 80 bit long doubles such as unnormal and pseudo-denormal numbers. For that reason, a standalone long double fuzzer is left for future development.
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet14-84/+94
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-09-21[libc] Template the printf / scanf parser class (#66277)Joseph Huber2-8/+3
Summary: The parser class for stdio currently accepts different argument providers. In-tree this is only used for a fuzzer test, however, the proposed implementation of the GPU handling of printf / scanf will require custom argument handlers. This makes the current approach of using a preprocessor macro messier. This path proposed folding this logic into a template instantiation. The downside to this is that because the implementation of the parser class is placed into an implementation file we need to manually instantiate the needed templates which will slightly bloat binary size. Alternatively we could remove the implementation file, or key off of the `libc` external packaging macro so it is not present in the installed version.
2023-08-15[libc] Add fuzzing for printf floatsMichael Jones2-0/+133
To guarantee accuracy for all potential float values, this patch adds a fuzzer to compare the results for float conversions from our printf against MPFR's. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D156495
2023-07-18[libc] Set min precision for strtofloat fuzzMichael Jones1-53/+62
MPFR has a minimum precision of 2, but the strtofloat fuzz sometimes would request a precision of 1 for the case of the minimum subnormal. This patch tells the fuzzer to ignore any case where the precision would go below 2. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D155130
2023-07-11[libc] adjust strtofloat precision for subnormalsMichael Jones1-5/+26
Subnormal floating point numbers have a lower effective precision than normal floating point numbers. This can cause issues for the fuzz test since the MPFR floats have a constant precision regardless of the exponent, and the precision must match exactly or else create rounding errors. To solve this problem, the precision of the MPFR floats is dynamically calculated. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D154909
2023-07-05[libc] fix MPFR rounding problems in fuzz testMichael Jones2-7/+48
The accuracy for the MPFR numbers in the strtofloat fuzz test was set too high, causing rounding issues when rounding to a smaller final result. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D154150
2023-05-22[libc] Use MPFR for strtofloat fuzzingMichael Jones3-57/+56
The previous string to float tests didn't check correctness, but due to the atof differential test proving unreliable the strtofloat fuzz test has been changed to use MPFR for correctness checking. Some minor bugs have been found and fixed as well. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D150905
2023-04-28[libc] add exception to atof differential fuzzMichael Jones2-1/+40
The differential fuzzer for atof found a bug in glibc's handling of hexadecimal rounding. Since we can't easily update glibc and we want to avoid false positives when running the fuzzer, I've added an exception to skip all hexadecimal subnormal cases. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D149359
2023-02-27[libc] use vars in string to num fuzz targetsMichael Jones2-3/+25
The string to integer and string to float standalone fuzz targets just ran the functions and didn't do anything with the output. This was intentional, since they are intended to be used with sanitizers to detect buffer overflow bugs. Not using the variables was causing compile warnings, so this patch adds trivial checks to use the variables. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D144208
2023-02-17[libc] Add basic fuzz target for the printf parserMichael Jones3-0/+83
The goal is to fuzz the entirety of printf, but the plan is to do it in pieces for simplicity. This test fuzzes just the parser, while later tests will fuzz the converters. This also adds a mock version of the arg_list class. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D143784
2023-02-15[libc][NFC] Make tuning macros start with LIBC_COPT_Guillaume Chatelet2-2/+2
Rename preprocessor definitions that control tuning of llvm libc. Differential Revision: https://reviews.llvm.org/D143913
2023-02-10[libc] add standalone strtoint/float fuzzersMichael Jones3-0/+145
Fuzzing the string to integer and float functions without relying on the system libc allows for tests to be run in a wider variety of places. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D143616
2022-12-20[libc] add fuzz target for strtointeger functionsMichael Jones4-1/+139
The string to integer conversion functions are well suited to differential fuzzing, and this patch adds a target to enable just that. It also fixes a bug in the fuzzing comparison logic and changes atoi slightly to match the behavior described in the C standard. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D140178
2022-08-31[libc][cmake] split fputil into individual targetsMichael Jones1-1/+1
The libc.src.__support.FPUtil.fputil target encompassed many unrelated files, and provided a lot of hidden dependencies. This patch splits out all of these files into component parts and cleans up the cmake files that used them. It does not touch any source files for simplicity, but there may be changes made to them in future patches. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D132980
2022-07-29[libc][NFC] Use STL case for type_traitsGuillaume Chatelet1-4/+3
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion. Starting with the type_traits header. Differential Revision: https://reviews.llvm.org/D130727
2022-03-08[libc][NFC] split standalone_cpp into single headersMichael Jones1-1/+1
Previously, the entire support/CPP folder was in one header library, which meant that a lot of headers were included where they shouldn't be. This patch splits each header into its own target, as well as adjusting each place they were included to only include what is used. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D121237
2021-12-07[libc] apply new lint rulesMichael Jones1-2/+2
This patch applies the lint rules described in the previous patch. There was also a significant amount of effort put into manually fixing things, since all of the templated functions, or structs defined in /spec, were not updated and had to be handled manually. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D114302
2021-11-19[libc][Obvious][NFC] A bunch of cosmetic cleanup.Siva Chandra Reddy3-2/+7
* Added missing header guards. * Fixed license header format in a few files. * Renamed files to more suitable names.
2021-10-28[libc][NFC] Move utils/CPP to src/__support/CPP.Siva Chandra Reddy2-2/+2
The idea is to move all pieces related to the actual libc sources to the "src" directory. This allows downstream users to ship and build just the "src" directory. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D112653
2021-10-18[libc] add atof, strtof and strtodMichael Jones3-0/+77
Add the string to floating point conversion functions. Long doubles aren't supported yet, but floats and doubles are. The primary algorithm used is the Eisel-Lemire ParseNumberF64 algorithm, with the Simple Decimal Conversion algorithm as backup. Links for more information on the algorithms: Number Parsing at a Gigabyte per Second, Software: Practice and Experience 51 (8), 2021 (https://arxiv.org/abs/2101.11408) https://nigeltao.github.io/blog/2020/eisel-lemire.html https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html Differential Revision: https://reviews.llvm.org/D109261
2021-09-24[libc] Add an implementation of qsort.Siva Chandra Reddy3-0/+55
A fuzzer for qsort has also been added. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D110382