Commit Graph

168 Commits

Author SHA1 Message Date
Siva Chandra Reddy f5db2411c2 [libc][Obvious] Cleanup of include lines and target listings in FPUtil. 2020-07-17 00:09:36 -07:00
serge-sans-paille 515bc8c155 Harmonize Python shebang
Differential Revision: https://reviews.llvm.org/D83857
2020-07-16 21:53:45 +02:00
Andre Vieira c051312eb2 [libc][benchmark] Add display option to render.py3
Differential Revision: https://reviews.llvm.org/D83380
2020-07-13 12:09:14 +01:00
cgyurgyik 7859242a37 [libc] [Obvious] Remove unneeded header in strchr.
Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D83589
2020-07-10 19:33:55 -04:00
cgyurgyik a4f0c58c6e [libc] Add strchr implementation. Fixes bug in memchr.
Summary: [libc] Adds strchr implementation with unit tests. Fixes signed character bug in memchr.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D83353
2020-07-10 14:30:20 -04:00
Chris Gyurgyik 9d8b4defd3
[libc] Fix typographical error in math_utils.h. 2020-07-08 11:56:21 -04:00
cgyurgyik b6a20a4970 [libc] Add memchr implementation. 2020-07-07 17:08:50 -04:00
Paula Toth ab25ed26c6 [libc] Add documentation for clang-tidy checks.
Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D82846
2020-07-06 18:15:35 -07:00
Paula Toth aa6ef6fea0 [libc] Add documentation for integration tests.
Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: MaskRay, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D82907
2020-07-06 12:44:32 -07:00
cgyurgyik b07feef873 [libc] This commit fixes the strcmp fuzzing test. It uses a single input and
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-28 12:50:04 -05:00
Siva Chandra Reddy d4adac4832 [libc] Add the remaining long double flavors of nearest integer functions.
Specifically: ceill, floorl and roundl have been added.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82591
2020-06-25 22:45:05 -07:00
Siva Chandra 25ac19de4b [libc] Enable copysignl, frexpl, logbl and modfl on aarch64. 2020-06-24 00:16:23 -07:00
Siva Chandra Reddy 7abdb2b948 [libc][Obvious] Remove a debug #include of iostream. 2020-06-24 00:01:03 -07:00
Siva Chandra Reddy a00fb593b4 [libc] Add long double flavors of the floating point manipulation functions.
Specifically: copysignl, frexpl, logbl and modfl have been added.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82357
2020-06-23 23:46:58 -07:00
Siva Chandra Reddy dc72be4e01 [libc][Obvious] Fix few typos in tests. 2020-06-23 13:11:41 -07:00
cgyurgyik 8bec88e638 Remove strcmp fuzz from CMakeList since it breaks build. 2020-06-23 12:52:36 -04:00
Simon Pilgrim f1c671925b Add stddef.h to fix missing size_t type build errors. 2020-06-23 13:12:18 +01:00
cgyurgyik 4ffe2b24f5 [libc] Add fuzz test for strcmp.
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-23 07:24:03 -04:00
cgyurgyik 5540765be6 Add strcmp fuzz test.
Reviewed-by: todo
Differential Revision: https://reviews.llvm.org/D82247
2020-06-23 07:20:39 -04:00
Siva Chandra Reddy 987fac79c9 [libc] Match x86 long double NaN classification with that of the compiler.
Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82330
2020-06-22 23:02:05 -07:00
cgyurgyik 05e1612c43 [libc] This adds the strcmp (string compare) implementation.
Reviewed-by: sivachandra
Differential Revision: https://reviews.llvm.org/D82134
2020-06-19 16:09:44 -04:00
Anthony Steinhauser 1a377055a7 [libc] Migrate the libc benchmark instruction to ninja.
Reviewers: sivachandra

    Reviewed By: sivachandra

    Differential Revision: https://reviews.llvm.org/D82143
2020-06-18 21:54:30 -07:00
Siva Chandra Reddy 139018265b [libc] Add implementations long double fabsl and truncl functions.
Current implementations of single precision and double precision
floating point operations operate on bits of the integer type of
same size. The code made use of magic masks which were listed as
literal integer values. This is not possible in the case of long
double type as the mantissa of quad-precision long double type used
on non-x86 architectures is wider that the widest integer type for
which we can list literal values. So, in this patch, to avoid
using magic masks specified with literal values, we use packed
bit-field struct types and let the compiler generate the masks.
This new scheme allows us to implement long double flavors of the
various floating point operations. To keep the size of the patch
small, only the implementations of fabs and trunc have been
switched to the new scheme. In following patches, all exisiting
implementations will be switched to the new scheme.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D82036
2020-06-18 11:08:26 -07:00
Siva Chandra Reddy 438f7fc068 [libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc.
Summary:
To get the target order correct, the benchmarks directory has been moved
one level higher. Previously, it was living in the utils directory. The
utils directory is a collection of utils which are to be used by the
tests and implementations. However, benchmarks *use* the
implementations. So, moving it out of utils helps us setup proper
target level dependencies.

Reviewers: gchatelet

Differential Revision: https://reviews.llvm.org/D81910
2020-06-17 11:42:26 -07:00
Siva Chandra Reddy 6fb7f3a3cf [lib][NFC] Split the floating point util functions into multiple files.
The grouping now reflects the grouping on cppreference.com.
2020-06-15 23:12:00 -07:00
Siva Chandra 7e54df6829 [libc] Enable string functions for aarch64. 2020-06-15 09:36:40 -07:00
Siva Chandra Reddy 051f0ffdbf [libc] Extract an architecture independent copy of memcpy implementation.
Along that way, platform specific options to memcpy, memset and bzero
builds have been enclosed in conditionals. Also, the optimization level
has been set to -O2 for the memory function builds to actually see the
static functions inlined.

Reviewers: gchatelet

Differential Revision: https://reviews.llvm.org/D81621
2020-06-15 09:24:32 -07:00
Siva Chandra Reddy 118c13c691 [libc] Add implementation of few floating point manipulation functions.
Implementations of copysign[f], frexp[f], logb[f], and modf[f] are added.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D81134
2020-06-11 12:23:11 -07:00
Paula Toth 0dcdc1c863 [libc] Fix integration test header dependency. 2020-06-10 21:52:27 -07:00
Siva Chandra Reddy b622a255a3 [libc][Obvious] Use full path with cmake's if(EXISTS ...).
That if(EXISTS ...) works only with full paths was missed in couple of
places a in recent cleanup.
2020-06-10 15:08:00 -07:00
Siva Chandra 1f567b2c6f [libc] Add a simple linux aarch64 config.
Summary:
With this change, "ninja check-libc" on linux/aarch64 succeeds.

However, all entrypoints with machine dependent implementations
have been skipped. A good number of these skipped entrypoints can
be enabled once we have aarch64 syscall support available.

Reviewers: abrachet, asteinhauser

Differential Revision: https://reviews.llvm.org/D81533
2020-06-10 11:19:52 -07:00
Siva Chandra c76a1d0fc0 [libc][NFC] Make cpu feature check tolerate non-x86 architectures.
The feature check should probably be enhanced for non-x86 architectures,
but this change shields them from x86 specific pieces until then.

This patch has been split out from https://reviews.llvm.org/D81533.
2020-06-10 11:11:04 -07:00
Siva Chandra Reddy 4be1c116ad [libc] Add implementations of round and roundf.
Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D80779
2020-06-09 23:01:20 -07:00
Siva Chandra Reddy 9894236e70 [libc] Skip fuzzer as well if its dependent entrypoints are skipped.
Reviewers: asteinhauser

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D81519
2020-06-09 21:49:50 -07:00
Siva Chandra Reddy ef0ea8717a [libc][NFC] Adjust sinf and cosf around -infinity inputs.
The current tests verify if the result of -infinity is a quiet NaN with
sign bit set. But, that need not be the case on all platforms. So, just
checking that the result is a quiet NaN and ignoring the sign bit is
good enough.
2020-06-09 16:23:12 -07:00
Siva Chandra Reddy 235e9cc924 [libc][NFC][Obvious] Tidy up some CMake files.
Conditionally adding subdirectories was missed in a few places previously.
This change adds the conditionals. A sub-directory was being added
needlessly in another place. That has been removed.
2020-06-09 15:54:07 -07:00
Siva Chandra Reddy fd3295fb6f [libc] Skip entrypoints not present in the entrypoints list.
Summary:
If a test depends on a skipped entrypoint, then the test is also
skipped. This setup will be useful as we gradually add support for
more operating systems and target architectures.

Reviewers: asteinhauser

Differential Revision: https://reviews.llvm.org/D81489
2020-06-09 14:40:28 -07:00
Siva Chandra Reddy 11eafdb1d9 [libc][NFC] Add few more missing entrypoints to the entrypoint list.
They were likely missed while rebasing.
2020-06-08 22:08:42 -07:00
Siva Chandra Reddy 63bbddf4cd [libc][NFC] Add bzero to list of entrypoints.
A new LLVM libc specific extension standard spec has been added.
2020-06-08 21:44:39 -07:00
Siva Chandra Reddy e9de9e3368 [libc][NFC][Obvious] Add names to various string entrypoints. 2020-06-08 17:13:53 -07:00
Siva Chandra Reddy b28167928d [libc][NFC] Add ceil[f], floor[f] and trunc[f] to the spec and config files. 2020-06-03 22:39:34 -07:00
Paula Toth d5e0dfd507 [libc] Remove integration test target from check libc.
Summary:
This is failing on the asan build because we use `-nostdlib`.
I also took this opportunity to make the target name match the naming structure we've been using.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D81029
2020-06-02 13:32:21 -07:00
Paula Toth b836ae24a9 [libc] Add integration tests.
Summary:
This patch aims to add integration tests to check the following:
1) Header files are generated as expected.
2) Libc functions have the correct public name.
3) Libc functions have the correct return type and parameter types.
4) Symbols are exposed in the public lib.a files.

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra

Subscribers: aheejin, ecnelises, dxf, mgorny, jfb, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D79192
2020-06-02 12:14:07 -07:00
Paula Toth 1ab092b758 [libc] Expose APIGenerator.
Summary: This is split off from D79192 and exposes APIGenerator (renames to APIIndexer) for use in generating the integrations tests.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D80832
2020-06-01 12:30:35 -07:00
Siva Chandra Reddy 1caedd0c55 [libc] Add implementations of ceil[f], floor[f] and trunc[f] from math.h.
Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D80612
2020-06-01 08:36:59 -07:00
Siva Chandra Reddy 0baf0e8cfc [libc] Add implementation of call_once from threads.h.
Reviewers: abrachet, maskray

Differential Revision: https://reviews.llvm.org/D79828
2020-05-28 23:45:09 -07:00
Siva Chandra Reddy c7614faa05 [libc][NFC][Obvious] Fix few header guards in src/threads. 2020-05-28 15:07:27 -07:00
Siva Chandra Reddy 10bb03c1c1 [libc][NFC][Obvious] Remove line break from a CMake message.
The line break was giving an impression of something going wrong.
2020-05-28 14:55:24 -07:00
Anthony Steinhauser 504d8d9d8a [libc] Fixing the build command for benchmarks.
Building libc without clang fails with:
CMake Error at /home/asteinhauser/llvm-project/libc/CMakeLists.txt:49 (message):
'clang' and 'clang-tools-extra' are required in LLVM_ENABLE_PROJECTS to
lint llvm-libc. The linting step performs important checks to help prevent
the introduction of subtle bugs, but it may increase build times.

Reviewers: sivachandra

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D80495
2020-05-28 11:19:20 -07:00
Siva Chandra Reddy 9f69d3d0bc [libc][NFC][Obvious] Convert the MPFR operations enum to an enum class.
This was suggested in https://reviews.llvm.org/D79149.
2020-05-26 22:26:41 -07:00