summaryrefslogtreecommitdiff
path: root/libc/fuzzing/string
AgeCommit message (Collapse)Author
2025-11-10[libc] add an SVE implementation of strlen (#167259)Schrodinger ZHU Yifan
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 ```
2024-12-10[libc] move bcmp, bzero, bcopy, index, rindex, strcasecmp, strncasecmp to ↵Nick Desaulniers
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-01-11[libc] Add memcmp / bcmp fuzzers (#77741)Guillaume Chatelet
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
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
2020-07-29[libc] Adds fuzz test for strstr and alphabetizes string fuzz CMakeList.cgyurgyik
Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D84611
2020-06-28[libc] This commit fixes the strcmp fuzzing test. It uses a single input andcgyurgyik
splits it into two by using the value of the first byte to determine the length of the first string. Reviewed-by: PaulkaToast, Differential Revision: https://reviews.llvm.org/D82427 Summary: [libc] Since only one input is given, it is necessary to split the string into two containers so that they can be compared for the purposes of this fuzz test. This is done in the following manner: 1. Take the value of the first byte; this is size1. (Credits to @PaulkaToast for this idea). 2. size2 is the value of size - size1. 3. Copy the characters to new containers, data1 and data2 with corresponding sizes. 4. Add a null terminator to the first container, and verify the second container has a null terminator. 5. Verify output of strcmp. A simpler alternative considered was simply splitting the input data into two, but this means the two strings are always within +- 1 character of each other. This above implementation avoids this. ninja check-libc was run; no issues. Reviewers: PaulkaToast, sivachandra Reviewed By: PaulkaToast Subscribers: mgorny, tschuett, ecnelises, libc-commits, PaulkaToast Tags: #libc-project Differential Revision: https://reviews.llvm.org/D82427
2020-06-23Remove strcmp fuzz from CMakeList since it breaks build.cgyurgyik
2020-06-23Add stddef.h to fix missing size_t type build errors.Simon Pilgrim
2020-06-23[libc] Add fuzz test for strcmp.cgyurgyik
Summary: Adds a fuzz test for string comparison. This takes in two strings with associated lengths. Verifies each string contains at least one character, and that the last character is the null terminator. Then, finds the first instance where one of the following does not hold: 1. i < min(size1, size2) 2. s1[i] == s2[i] 3. s1[i] != '\0' The result of strcmp is then compared to the value of the difference between s1[i] and s2[i]. For thoroughness, the operands are reversed and also checked. Reviewers: sivachandra, PaulkaToast Reviewed By: sivachandra, PaulkaToast Subscribers: mgorny, tschuett, ecnelises, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D82247
2020-06-23Add strcmp fuzz test.cgyurgyik
Reviewed-by: todo Differential Revision: https://reviews.llvm.org/D82247
2020-04-10[libc] Add fully-qualified target names.Siva Chandra Reddy
Only targets setup by the special LLVM libc rules now have fully qualified names. The naming style is similar to fully qualified names in Python. Reviewers: abrachet, PaulkaToast, phosek Differential Revision: https://reviews.llvm.org/D77340
2020-04-08[libc][NFC] Make all top of file comments consistent.Paula Toth
Summary: Made all header files consistent based of this documentation: https://llvm.org/docs/CodingStandards.html#file-headers. And did the same for all source files top of file comments. Reviewers: sivachandra, abrachet Reviewed By: sivachandra, abrachet Subscribers: MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D77533
2020-04-03[libc] Fix memcpy to adhere to qualified calls.Paula Toth
Summary: Switched to using the new memcpy implementation. Reviewers: sivachandra, abrachet, gchatelet Reviewed By: abrachet, gchatelet Subscribers: mgorny, MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D77277
2020-04-03[libc] Add strlen implementation.Paula Toth
Summary: This should fix the call to a non internal libc function. Reviewers: sivachandra, abrachet Reviewed By: sivachandra Subscribers: xbolva00, mgorny, MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D77279
2020-02-21[libc] Lay out framework for fuzzing libc functions.Paula Toth
Summary: Added fuzzing test for strcpy and some documentation related to fuzzing. This will be the first step in integrating this with oss-fuzz. Reviewers: sivachandra, abrachet Reviewed By: sivachandra, abrachet Subscribers: gchatelet, abrachet, mgorny, MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D74091