Commit Graph

503 Commits

Author SHA1 Message Date
Siva Chandra Reddy 2f4f452f16 [libc] Add a skeleton for C standard condition variable functions.
This patch adds a skeleton as a preparatory step for the next patch which
adds the actual implementations of the condition variable functions.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D108947
2021-09-01 19:41:52 +00:00
Siva Chandra Reddy 0239adac4a [libc] Mark return value of memcpy in strcpy as initialized for msan.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D109045
2021-09-01 19:01:25 +00:00
Michael Jones 7f2ce19d1c [libc][nfc][obvious] fix typos in FPUtil
Fix minor typos in FPUtil comments.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D108952
2021-08-30 22:39:02 +00:00
Siva Chandra Reddy 7a2a765745 [libc] Add mtx_destroy which does nothing.
There is not cleanup to be done for the mutex type so mtx_destroy does
nothing.
2021-08-30 20:43:46 +00:00
Siva Chandra Reddy 3383ec5fdd [libc] Ensure the result of the clone syscall is not on stack in thrd_create.
Also, added a call to munmap on error in thrd_create.
2021-08-30 04:35:40 +00:00
Siva Chandra Reddy f7e572b4f4 [libc][NFC] Add a check to catch mismatch in internal and public mutex types. 2021-08-30 04:08:35 +00:00
Roland McGrath 225eb8a22d [libc][NFC] Fix onre more -Wconversion warning in strtoul test code.
The last change missed one spot.

Differential Revision: https://reviews.llvm.org/D108845
2021-08-27 14:12:39 -07:00
Roland McGrath 4e1a164d7b [libc] Fix various -Wconversion warnings in strto*l test code.
The Fuchsia build compiles the libc and test code with lots
of warnings enabled, including all the integer conversion warnings.
There was some sloppy type usage here that triggered some of those.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D108800
2021-08-27 14:04:00 -07:00
Siva Chandra Reddy 8e284be04f [libc][Obvious] Add header guards for the generated linux syscall header file. 2021-08-27 16:17:53 +00:00
Siva Chandra Reddy 004c7b1da6 [libc][NFC] Move the mutex implementation into a utility class.
This allows others parts of the libc to use the mutex types without
actually pulling in public function implementations.

Along the way, few cleanups have been done, like using a uniform type to
refer the linux futex word.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D108749
2021-08-26 18:49:20 +00:00
Michael Jones 035325275c [libc] add inttypes header
Add inttypes.h to llvm libc. As its first functions strtoimax and
strtoumax are included.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108736
2021-08-26 18:04:21 +00:00
Michael Jones fdee2d768d [libc] Fix too long number in strtoul_test
I think this is the last windows type conversion fix, the rest of the
build seems to be okay.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108659
2021-08-24 20:17:09 +00:00
Michael Jones 6bbfd6a9c1 [libc] Fix type errors on Windows
Fix the errors caused by having some numbers too large for a 32 bit
number in the tests for windows. Also fix the base causing some type
confusion.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108653
2021-08-24 19:42:13 +00:00
Michael Jones 1d02a8bcd3 [libc] fix string conversion tests for windows
There were some copy paste errors as well as some oddities around how
windows handles the difference between long and long long types. This
change fixes those.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108591
2021-08-24 18:06:21 +00:00
Michael Jones eff11176c5 [libc] Enable string to integer conversion functions in the default build
Adds atoi, atol, atoll, strtol, strtoll, strtoul, and strtoull to the
list of entrypoints for Windows and aarch64 linux, as well as moving
them out of the LLVM_LIBC_FULL_BUILD condition for x86_64 linux.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108477
2021-08-23 21:18:14 +00:00
Alfonso Gregory 9cdd4ea06f [libc][NFC] Add explicit casts to ctype functions
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D106902
2021-08-23 18:17:20 +00:00
Siva Chandra Reddy 8e488c3cc0 [libc] Add a multi-waiter mutex test.
A corresponding adjustment to mtx_lock has also been made.
2021-08-23 05:47:30 +00:00
Siva Chandra Reddy ca6b354229 [libc] Add range reduction functions based on Paine and Hanek algorithm.
These functions will be used in a future patch to implement
trigonometric functions. Unit tests have been added but to the
libc-long-running-tests suite. The unit tests long running because we
compare against MPFR computations performed at 1280 bits of precision.

Some cleanups or elimination of repeated patterns can be done as follow
up changes.

Differential Revision: https://reviews.llvm.org/D104817
2021-08-23 05:18:41 +00:00
Siva Chandra Reddy 5e147d3058 [libc] Add a new suite called "libc-long-running-tests".
This suite is helpful is adding long running tests which take a long
time to finish that they can be run on the public builders. They
will probably be run on special builders in future.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D104816
2021-08-21 05:01:28 +00:00
Fangrui Song 40aab0412f [test] Migrate -gcc-toolchain with space separator to --gcc-toolchain=
Space separated driver options are uncommon but Clang traditionally
did not do a good job. --gcc-toolchain= is the preferred form.
2021-08-20 15:24:58 -07:00
Michael Jones 6ce6fa4ad4 [libc] make the scudo integration test run
adds a custom command for libc-scudo-integration-test that makes it run
when it is built.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108409
2021-08-20 17:51:11 +00:00
Guillaume Chatelet 791d88f35f [libc] Align to 32B instead of 16B for optimized memcmp 2021-08-20 13:09:35 +00:00
Guillaume Chatelet b460534ac7 [libc] Add an optimized version for memcmp
Differential Revision: https://reviews.llvm.org/D108406
2021-08-20 06:40:37 +00:00
Siva Chandra Reddy 1cd3d19271 [libc] Add bcmp to the windows config. 2021-08-20 04:51:09 +00:00
Siva Chandra Reddy aeee014428 [libc][Obvious] Fix llvm_libc_ext.td. 2021-08-19 18:54:43 +00:00
Michael Jones bad3168b99 [libc] add atoi, atol, and atoll
This is based on the work done to add strtoll and the other strto
functions. The atoi functions also were added to stdc and
entrypoints.txt.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108330
2021-08-19 18:02:51 +00:00
Guillaume Chatelet c8f79892af [libc] Add a trivial implementation for bcmp
Differential Revision: https://reviews.llvm.org/D108225
2021-08-19 17:55:16 +00:00
Michael Jones d52f0aeca5 [libc] Add strtol, strtoul, and strtoull
Updates the internal string conversion function so that it
uses the new Limits.h added in a previous commit for max and min values,
and has a templated type. This makes implementing the other strto*
functions very simple.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107999
2021-08-17 21:05:37 +00:00
Siva Chandra Reddy 9a56d71f61 [libc][NFC] Disable double precision cos, sin and tan on Windows.
The current x86_64 implementations do not build on the windows bot
machine. We will enable them back after fixing the problem.
2021-08-17 16:47:20 +00:00
Guillaume Chatelet 83457d398d [libc] dedup handling of size 4 for memset 2021-08-16 22:29:10 +00:00
Guillaume Chatelet 8e4efad991 [libc] Optimize Loop strategy
Since the precondition for loop is `size >= T::kSize` we always expect
at least one run of the loop. This patch transforms the for-loop into a
do/while-loop which saves at least one test.

We also add a second template parameter to allow the Tail operation to
differ from the loop operation.
2021-08-16 22:17:56 +00:00
Michael Jones 472fa04de8 [libc][nfc] add CPP Limits.h for numeric_limits
Add an implementation of numeric_limits for use in str_conv_utils.
It currently only supports the basic integer types, with more types
coming as needed.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107987
2021-08-12 21:31:16 +00:00
Michael Jones b062d639bb [libc] add strtoll function and backend
This change adds the stroll function, but most of the implementation is
in the new file str_conv_utils.h since many of the other integer
conversion functions are implemented through what are effectively calls
to strtoll.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107792
2021-08-11 23:37:23 +00:00
Guillaume Chatelet c82ba4b820 [libc] Update size distributions for memory benchmarks
All distributions have been updated using 7 days worth of data.
2021-08-09 14:22:32 +00:00
Michael Jones c120edc7b3 [libc][nfc] move ctype_utils and FPUtils to __support
Some ctype functions are called from other libc functions (e.g. isspace
is used in atoi). By moving ctype_utils.h to __support it becomes easier
to include just the implementations of these functions. For these
reasons the implementation for isspace was moved into
ctype_utils as well.

FPUtils was moved to simplify the build order, and to clarify which
files are a part of the actual libc.

Many files were modified to accomodate these changes, mostly changing
the #include paths.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107600
2021-08-06 17:29:41 +00:00
Hedin Garca a9628e96ca [libc] Add diff and perf targets for more math functions
Comparing the run time of math functions from LLVM libc
with the MSVCRT libc:
|function	|perf-LLVM libc		    |perf-MSVCRT
|ceilf		|2.36 mins (141491389600 ns)|47.10 sec (47100940100 ns)
|exp2f             |6.37 mins (358441794700 ns)|12.39 mins (719404388300 ns)
|expf		|6.35 mins (381204661800 ns)|6.17 mins (346150163200 ns)
|fabsf		|1.18 mins (78425546600 ns) |53.75 sec (53745301900 ns)
|floorf		|3.15 mins (164770963800 ns)|45.94 sec (45935988400 ns)
|logbf		|4.38 mins (262508058800 ns)|55.47 sec (55466377700 ns)
|nearbyintf	|3.20 mins (167972868000 ns)|9.13 mins (523822963600 ns)
|rintf		|3.20 mins (168001498700 ns)|22.35 mins (1341266448800 ns)
|roundf		|2.35 mins (141151500600 ns)|1.42 mins (85326429800 ns)
|truncf		|2.31 mins (114846424000 ns)|59.41 sec (59414309100 ns)

Evaluating the number of differing results in Windows:
|function	|diff
|ceilf          |8388606 differing results
|exp2f         |213303887 differing results
|expf           |193922 differing results
|fabsf          |8388606 differing results
|floorf         |8388606 differing results
|logbf          |0 differing results
|nearbyintf     |0 differing results
|rintf          |0 differing results
|roundf         |0 differing results
|truncf 	|0 differing results

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107462
2021-08-05 17:57:04 +00:00
Michael Jones 6ed60fb8a2 [libc] add integration tests for scudo in libc
This change adds tests to make sure that SCUDO is being properly
included with llvm libc. This change also adds the toggles to properly
use SCUDO, as GWP-ASan is enabled by default and must be included for
SCUDO to function.

Reviewed By: sivachandra, hctim

Differential Revision: https://reviews.llvm.org/D106919
2021-08-04 20:06:09 +00:00
Andre Vieira 2f002817fb [libc] Fix Memory Benchmarks code after rename
Differential Revision: https://reviews.llvm.org/D107376
2021-08-04 09:17:12 +01:00
Guillaume Chatelet e4dee76224 [libc] Allow benchmarking several implementations at the same time.
Next step is to generate an archive with all implementations and a header listing them all.

Differential Revision: https://reviews.llvm.org/D107336
2021-08-03 10:53:11 +00:00
Hedin Garca 2ab18d57d7 [libc] Add differential and performance targets for sqrtf
Comparing the runtime of the sqrt functions from LLVM libc with the system libc:
|function       |perf - LLVM libc          |perf - MSVCRT
|sqrtf - Windows|44.05 sec (44051715500 ns)| 417.84 sec (417843359900 ns) = 6.96 mins

|function       |perf - LLVM libc          |perf - glibc
|sqrtf - Linux  |30.48 sec (30479458632 ns)|43.72 sec (43716901527 ns)

By running the differential test:
|function       |diff
|sqrtf - Windows|0 differing results
|sqrtf - Linux  |0 differing results

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D107229
2021-08-02 19:29:48 +00:00
Guillaume Chatelet 59198d062f [libc] Add a Google Benchmark target to support continuous monitoring of memory operation performance
The next step is to be able to benchmark several implementations at once and compare which one performs best on a particular machine.

Differential Revision: https://reviews.llvm.org/D107265
2021-08-02 12:14:11 +00:00
Siva Chandra Reddy 66d92efc66 [libc] Add trigonometric and exponential functions to the windows config. 2021-07-31 01:30:26 +00:00
Siva Chandra Reddy 3d758e68a7 [libc] Move FPExceptMatcher out of TestHelpers.h
TestHelpers.h pulls few pieces from LLVM libc's unittest framework
which aren't available on platforms like Fuchsia which use their own
unittest framework. So, by moving FPExceptMatcher to a different file
we can exclude LLVM libc specific pieces in a cleaner way.

In a later pass, it might make more sense to rename TestHelpers.h also
to FPMatcher.h. That way, we can make macros like EXPECT_FP_EQ to be
equivalent to EXPECT_EQ on platforms like Fuchsia.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D107129
2021-07-30 23:44:29 +00:00
Siva Chandra Reddy 381f9affab [libc][NFC] Add dummy errno target to satisfy mixed mode builds.
In mixed mode builds, we should not be including errno as part of
LLVM libc - errno from another library (or the system library) should be
used. But, other entrypoints which use errno list LLVM libc's errno as a
dep ta satisfy the full build mode. So, we add a dummy errno
implementation with empty files to make both mixed mode and full build
mode happy.
2021-07-30 17:42:48 +00:00
Guillaume Chatelet cd2f5d5b49 [libc] rewrite aarch64 memcmp implementation
This patch is simply rearranging the code layout so it's easier to understand.

Differential Revision: https://reviews.llvm.org/D106641
2021-07-29 14:41:12 +00:00
Alfonso Gregory 640ed21cce [libc][NFC] Add noreturn and constexpr qualifiers where appropriate
These functions make it clear to the compiler and user what the intended
behavior is so llvm can make them go as fast as possible.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D106807
2021-07-29 04:50:05 +00:00
Michael Jones c6d03b583b [libc] add strncmp to strings
Add strncmp as a function to strings.h. Also adds unit tests, and adds
strncmp as an entrypoint for all current platforms.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D106901
2021-07-28 21:37:12 +00:00
Guillaume Chatelet d3c70d9f77 [libc] Simplify implementation of benchmarks
This also allows to run the distribution benchmarks in other frameworks
like the Google Benchmark facility.
2021-07-28 15:04:19 +00:00
Alfonso Gregory 0784e62c3c [libc] Fix strtok_r crash when src and *saveptr are both nullptr
While working and testing my refactoring of multiple string functions in libc, I came across a bug that needs to be addressed in a patch on its own: src is checked for nullptr and assigned to *saveptr if it is nullptr. However, saveptr is initially nullptr when it comes to reentry. This could cause a problem if both saveptr and src are null; we need to do the check first and return nullptr if both are nullptr.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D106885
2021-07-27 21:49:23 +00:00
Siva Chandra Reddy dd8b93a9e7 [libc] Fix x86_64 fenv implementation for windows
All fenv functions are also enabled for windows. Since two tests,
enabled_exceptions_test and feholdexcept_test are still failing on
windows, they have been disabled.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D106808
2021-07-27 20:53:01 +00:00