aboutsummaryrefslogtreecommitdiff
path: root/libc/fuzzing
AgeCommit message (Collapse)AuthorFilesLines
2025-12-30[libc][fuzzing] Delete test buffs for asan checks (#174018)Kyungtak Woo1-6/+5
I'm currently getting "Detected memory leaks" errors due to this. This change should always delete the buffers after use.
2025-12-16[libc][fuzzing] Improve printf long double fuzzing (#172113)Michael Jones1-5/+12
Previously we only checked the long double value of the provided double. This meant we didn't check any values near the edge of the long double range, which meant we were missing several bugs. This patch adds a second long double value to check which is generated separately from the double value and can be anywhere in the range.
2025-12-01[libc][malloc] Ensure a minimum block alignment of 4 (#169447)Daniel Thornburgh1-4/+4
Most platforms inherently have a size_t alignment of 4, but this isn't true on every platform LLVM has some degree of backend support for. Accordingly, it's simple enough to just set the min alignment of Block to 4 and lose the static_assert.
2025-11-10[libc] add an SVE implementation of strlen (#167259)Schrodinger ZHU Yifan3-1/+41
This PR creates an SVE-based implementation for strlen by translating from the AOR code in tree. Microbenchmark shows improvements against NEON when N>=64. Although both implementations fall behind glibc by a large margin, this may be a good start point to explore SVE implementations. Together with the PR: 1. Added two more tests of strlen with special nul symbols. 2. Added strlen's fuzzer and fix a typo in previous heap fuzzer. ``` === strlen(16 bytes) === libc: 1.56115 ns/call, 9.54499 GiB/s neon: 1.59393 ns/call, 9.34867 GiB/s sve: 1.66097 ns/call, 8.97134 GiB/s === strlen(64 bytes) === libc: 2.06967 ns/call, 28.7991 GiB/s neon: 2.59914 ns/call, 22.9325 GiB/s sve: 2.58628 ns/call, 23.0465 GiB/s === strlen(256 bytes) === libc: 3.74165 ns/call, 63.7202 GiB/s neon: 8.98243 ns/call, 26.5428 GiB/s sve: 7.36426 ns/call, 32.3751 GiB/s === strlen(1024 bytes) === libc: 10.5327 ns/call, 90.5438 GiB/s neon: 34.363 ns/call, 27.7529 GiB/s sve: 26.9329 ns/call, 35.4092 GiB/s === strlen(4096 bytes) === libc: 37.7304 ns/call, 101.104 GiB/s neon: 145.911 ns/call, 26.144 GiB/s sve: 103.208 ns/call, 36.9612 GiB/s === strlen(1048576 bytes) === libc: 9623.4 ns/call, 101.478 GiB/s neon: 36138.2 ns/call, 27.023 GiB/s sve: 26605.6 ns/call, 36.7051 GiB/s ```
2025-10-02[libc] Fix issue with fuzz input too short for atoi diff fuzz (#161705)Michael Jones1-0/+4
The string to integer differential fuzzer assumes at least one byte of meaningful input, but wasn't explicitly checking that. Now it does.
2025-07-25[libc] Fuzz tests for fsqrt, f16sqrt, and hypot (#150489)sribee84-0/+200
Added fuzz tests for f16sqrt, fsqrt, and hypot --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-22[libc] cbrt fuzz test (#150063)sribee82-0/+59
Implemented fuzz test for cbrt Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-16[libc] Updated exp fuzz tests (#148912)sribee84-56/+108
Fuzz tests were previously in the wrong format, updated them to correct format. --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-16[libc] Updated fuzz tests for trig functions (#148891)sribee811-103/+196
Fuzz tests were set up incorrectly so updated trig functions to match the correct format. --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-15[libc] sqrt and log functions fuzz tests (#148006)sribee88-48/+298
added fuzz tests for sqrt and log functions --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-14[libc] exp fuzz tests (#148086)sribee85-0/+188
Created fuzz tests for exp functions --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-10[libc] asin fuzz testing (#147786)sribee82-0/+47
Added fuzz test for asin --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-10[libc] Fuzz tests for acos and atan (#147843)sribee83-0/+94
created fuzz tests for acos and atan --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-07-10[libc] sincos fuzz test (#147855)sribee82-0/+60
Created fuzz test for sincos --------- Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-13[libc] Fix missing errno include in fuzzer (#144132)Michael Jones1-0/+1
The printf parser uses errno for setting up the %m conversion. It was presumably getting this include indirectly until a recent change. This patch adds a direct dependency to fix it.
2025-05-13[libc] Add proxy header for ENTRY type. (#139746)lntue2-1/+2
https://github.com/llvm/llvm-project/issues/139561
2025-04-22[libc] Fix warnings for freelist_heap_test/fuzz (#136634)Daniel Thornburgh3-16/+9
Fixes #122367
2025-01-23[libc][NFC] Strip all training whitespace and missing newlines (#124163)Joseph Huber1-1/+1
2025-01-05[libc] Improve qsort (with build fix) (#121482)Lukas Bergdoll3-34/+30
2024-12-16[libc] Exclude FreeListHeap test and fuzzer on GPU (#120137)Petr Hosek1-1/+3
FreeListHeap uses the _end symbol which conflicts with the _end symbol defined by GPU start.cpp files so for now we exclude the test and the fuzzer on GPU.
2024-12-16[libc] Breakup freelist_malloc into separate files (#119806)Petr Hosek2-7/+33
This better matches the structure we use for the rest of libc.
2024-12-10[libc] move bcmp, bzero, bcopy, index, rindex, strcasecmp, strncasecmp to ↵Nick Desaulniers2-2/+2
strings.h (#118899) docgen relies on the convention that we have a file foo.cpp in libc/src/\<header\>/. Because the above functions weren't in libc/src/strings/ but rather libc/src/string/, docgen could not find that we had implemented these. Rather than add special carve outs to docgen, let's fix up our sources for these 7 functions to stick with the existing conventions the rest of the codebase follows. Link: #118860 Fixes: #118875
2024-11-21[libc] Fix wrong name in Compare.h (#117223)Chuvak1-1/+1
Fix for some mistakes in source code found using PVS Studio. Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/ Fixed: - [Bug 5](https://pvs-studio.com/en/blog/posts/cpp/1188/#IDF23EA2CEAB)
2024-11-21Reapply "[libc] Use best-fit binary trie to make malloc logarithmic (#117065)"Daniel Thornburgh2-0/+235
This reverts commit 93b83642ee34d0092b94776728dad0117c2b72a1. - Correct riscv32 assumption about alignment (bit of a hack). - Fix test case where the largest_small and smallest sizes are the same.
2024-11-21Revert "[libc] Use best-fit binary trie to make malloc logarithmic (#117065)"Daniel Thornburgh2-235/+0
This reverts commit b05600d96f46697e21f6b1b7ad901391326243a8. riscv32 unit test still broken
2024-11-21Reapply "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)Daniel Thornburgh2-0/+235
- Fix assertion expressions. - Fix incorrect small size in freestore_test. - There may only be one small size for high alignment and small pointers (riscv32). - Don't rely on stack alignment in FreeList test.
2024-11-20Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)Daniel Thornburgh2-235/+0
Reverts llvm/llvm-project#106259 Unit tests break on AArch64.
2024-11-20[libc] Use best-fit binary trie to make malloc logarithmic (#106259)Daniel Thornburgh2-0/+235
This reworks the free store implementation in libc's malloc to use a dlmalloc-style binary trie of circularly linked FIFO free lists. This data structure can be maintained in logarithmic time, but it still permits a relatively small implementation compared to other logarithmic-time ordered maps. The implementation doesn't do the various bitwise tricks or optimizations used in actual dlmalloc; it instead optimizes for (relative) readability and minimum code size. Specific optimization can be added as necessary given future profiling.
2024-11-18[libc] avoid type-punning with inactive union member (#116685)Schrodinger ZHU Yifan1-8/+8
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.