Commit Graph

703 Commits

Author SHA1 Message Date
Guillaume Chatelet 07f93a1e39 [libc][automemcpy] Discard aggrated samples from JSON
The benchmark framework synthesizes fake "aggregate" Samples representing mean, median and cv.
We're only interested in "iteration" samples.

Differential Revision: https://reviews.llvm.org/D120062
2022-02-18 15:24:13 +00:00
Alex Brachet d66983861a [libc] Add exit and atexit
Often atexit is implemented using __cxa_atexit. I have not implemented __cxa_atexit here because it potentially requires more discussion. It is unique for llvm-libc (I think) that it is an exported symbol that wouldn’t be defined in any spec file because it doesn’t have a header. Implementing it will be trivial given what is here already, but I figured it would be more contentious so it can be implemented later.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D119512
2022-02-17 17:21:55 +00:00
Guillaume Chatelet da5a4f16e8 [libc][automemcpy] Introduce geomean of scores as a tie breaker
Differential Revision: https://reviews.llvm.org/D120040
2022-02-17 13:37:05 +00:00
Guillaume Chatelet 48e0e6cedc [llvm][automemcpy] Allow distribution filtering in analysis
Differential Revision: https://reviews.llvm.org/D120037
2022-02-17 13:10:46 +00:00
Guillaume Chatelet b254a2a703 [libc][automemcpy] Add mean/variance and simplify implementation
Differential Revision: https://reviews.llvm.org/D120031
2022-02-17 12:11:05 +00:00
Alex Brachet 64f5f6d759 [libc] Use '+' constraint on inline assembly
As suggested by @mcgrathr in D118099

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D119978
2022-02-17 03:00:17 +00:00
Tue Ly f1ec99f973 [libc] Improve hypotf performance with different algorithm correctly rounded to all rounding modes.
Algorithm for hypotf: compute (a*a + b*b) in double precision, then use Dekker's algorithm to find the rounding error, and then correcting it after taking its square-root.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D118157
2022-02-16 09:48:51 -05:00
Siva Chandra Reddy 86bebe1a90 [lib][Obvious] Fix style in a few include directives. 2022-02-16 05:57:12 +00:00
Jeff Bailey 171cb8f53f Rewrite much of the index page for libc
The prior page was the proposal doc, this one is now
more about what the project intends to do, written in the
present tense.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D119379
2022-02-16 03:46:20 +00:00
Jeff Bailey 55120aad4e Implement basic loader for Linux aarch64
This implements a basic arm64 loader for Linux, and all the currently
enabled linker tests pass.  TLS is not implemented, and functions
using it will have undefined behaviour.  Notably, the TLS test is
currently disabled on x86_64.

Much of the structure is copied from x86_64 to allow for a refactoring
of the start code between architectures.

Tested:
ninja libc_loader_tests on aarch64-linux.

Co-authored-by: Raman Tenneti <rtenneti@google.com>

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D119641
2022-02-16 03:42:44 +00:00
Michael Jones 148a4b240e [libc] change ASAN condition to generator expression
Previously, building LLVM-libc with GWP ASAN was conditioned on the flag
COMPILER_RT_BUILD_GWP_ASAN, which caused issues do to the default value
of the flag being set in the compiler-rt cmake, which is seperate. Now
GWP ASAN is included based on if it exists as a target, which is more
consistent.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D119789
2022-02-15 16:12:12 -08:00
Tue Ly 9371d95ed2 [libc] Improve performance of generic hypot when the exponent difference is sufficiently large.
Simplify the logic when the exponent difference is at least MantissaLength + 2, while still maintaining correct rounding for all rounding modes.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D119843
2022-02-15 11:57:36 -05:00
Siva Chandra Reddy 4ef02da094 [libc] Add a platform independent buffered file IO data structure.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D119458
2022-02-15 05:34:29 +00:00
Raman Tenneti 31eccf99ec [libc] [Obvious] Fix.
Disable getenv_test.

Reviewed By: rtenneti

Differential Revision: https://reviews.llvm.org/D119758
2022-02-14 11:56:01 -08:00
Raman Tenneti b305de142c [libc] [Obvious] Fix.
Removed getenv from entrypoints.

Reviewed By: rtenneti

Differential Revision: https://reviews.llvm.org/D119753
2022-02-14 11:48:07 -08:00
Alex Brachet 6291454658 [libc] Create cpp::IntegerSequence analogous to std::integer_sequence
Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D119511
2022-02-14 18:13:00 +00:00
Raman Tenneti f2a7f83595 Introduce getenv to LLVM libc
Add support for getenv as defined by the Open Group's "System Interface &
 Header" in https://pubs.opengroup.org/onlinepubs/7908799/xsh/getenv.html

getenv requires a standard way of accessing the environment,
so a pointer to the environment is added to the startup in crt1.
Consquently, this function is not usable on top of other libcs.

Added starts_with method to StringView. getenv function uses it.

Co-authored-by: Jeff Bailey <jeffbailey@google.com>

Reviewed By: sivachandra, rtenneti

Differential Revision: https://reviews.llvm.org/D119403
2022-02-14 10:10:13 -08:00
Siva Chandra Reddy 19b4e9d76e [libc][cpp] Add a constructor to ArrayRef to construct from void * data.
Also modified operator[] to return a reference to the array element.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D119725
2022-02-14 17:02:54 +00:00
Guillaume Chatelet ae8b63866d [libc][benchmark] Fix change in JSon API 2022-02-14 15:55:27 +00:00
Siva Chandra Reddy 2a7ed8fcee [libc][Obvious][NFC] Move CPP tests to the correct nested directory. 2022-02-12 06:15:58 +00:00
Michael Jones 7eb5cb7f9e [libc] Fix allocator inclusion
Previously, allocator functions were only available if they were included
from scudo or by using the system libc headers (i.e. by turning off the
full build). This patch changes the logic to include the prototypes for
the allocator functitons in all cases, which allows the linker to link
in the system's allocator.

Reviewed By: sivachandra, abrachet

Differential Revision: https://reviews.llvm.org/D119587
2022-02-11 14:58:21 -08:00
Michael Jones 03731ed393 [libc][obvious] only include vector with malloc
the vector class, due to being dynamically resized, needs malloc. This
fixes the build so that it only includes it when malloc should be
available.

Differential Revision: https://reviews.llvm.org/D119464
2022-02-10 11:17:35 -08:00
Michael Jones 06cfb7a345 [libc] add a vector internal class
Add a basic implementation of the vector class for use internally to
LLVM-libc.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D118954
2022-02-10 11:04:18 -08:00
Guillaume Chatelet d2c5954662 [libc] undefined reference in LibcTest.cpp
GCC complains about undefined reference in LibcTest.cpp and indeed the wrong version of the template has been explicitly instanciated.
This is necessary to get llvm-libc compile with GCC.

Mentionning D119002 here for navigability.

Differential Revision: https://reviews.llvm.org/D119242
2022-02-09 20:45:56 +00:00
Siva Chandra Reddy 545331abf3 [libc][Obvious] Fix typo in mkdir and mkdirat implementations.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D119265
2022-02-08 21:48:12 +00:00
Guillaume Chatelet 7e7ecef980 [libc] Replace type punning with bit_cast
Although type punning is defined for union in C, it is UB in C++.
This patch introduces a bit_cast function to convert between types in a safe way.

This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002.

Differential Revision: https://reviews.llvm.org/D119145
2022-02-08 20:45:59 +00:00
Alex Brachet 70ae480c82 [libc][NFC] Remove all Linux specific code to respective linux/ directories
These were all the non OS agnostic implementations I could find in general directories.

Currently none of these functions are actually enabled, but for when they do it makes sense that they be in linux/ specific directories.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D119164
2022-02-08 18:32:18 +00:00
Guillaume Chatelet 83f9b13d8c [libc] Optimized version of memmove
This implementation relies on storing data in registers for sizes up to 128B.
Then depending on whether `dst` is less (resp. greater) than `src` we move data forward (resp. backward) by chunks of 32B.
We first make sure one of the pointers is aligned to increase performance on large move sizes.

Differential Revision: https://reviews.llvm.org/D114637
2022-02-08 11:55:09 +00:00
Guillaume Chatelet f231599666 [libc] Don't use Clang flags on other compilers
This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002.

Differential Revision: https://reviews.llvm.org/D119143
2022-02-08 11:00:48 +00:00
Guillaume Chatelet a33e98543a [libc] Disable rtti/expections
llvm-libc exhibits a C interface but its source is C++.
This patch explicitly disables the use of exceptions and RTTI when compiling the entrypoints.

Differential Revision: https://reviews.llvm.org/D118889
2022-02-08 10:46:28 +00:00
Guillaume Chatelet c28a522fc7 [libc][NFC] moving template specialization outside class declaration
This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002.

Differential Revision: https://reviews.llvm.org/D119142
2022-02-08 10:35:44 +00:00
Tue Ly e5e93f60ee [libc] Return a float NaN for log1pf instead of double NaN. 2022-02-07 21:07:09 -05:00
Tue Ly 6472421840 [libc] Fix mixed-sign comparison warnings and an out-of-bound access in high_precision_decimal.h
Fix mixed-sign comparison warnings and an out-of-bound access in high_precision_decimal.h

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D119156
2022-02-07 16:23:09 -05:00
Tue Ly 5753218852 [libc][Obvious] Suppress unused-variable warnings from syscall_unittest.
The unused vararibles in the tests are intentional.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D119183
2022-02-07 16:22:08 -05:00
Tue Ly 9e7688c71e [libc] Implement log1pf correctly rounded to all rounding modes.
Implement log1pf correctly rounded to all rounding modes relying on logf implementation for exponent > 2^(-8).

Reviewed By: sivachandra, zimmermann6

Differential Revision: https://reviews.llvm.org/D118962
2022-02-07 16:17:18 -05:00
Tue Ly 700aebaf74 [libc] Set default CXX_STANDARD to C++17 and let targets set their own standard if needed.
CMAKE_CXX_STANDARD 14 is set in the llvm-project/llvm folder overriding all COMPILE_OPTIONS -std=c++17.  We need to override the CXX_STANDARD property of the target in order to set the correct C++ standard flags.

Reviewed By: gchatelet

Differential Revision: https://reviews.llvm.org/D118871
2022-02-04 09:59:21 -05:00
Tue Ly 25d50a00c5 [libc][Obvious] Fix a mismatch signature of HighPrecisionDecimal::should_round_up.
Its input should be int32_t instead of uint32_t.

Reviewed By: michaelrj, sivachandra

Differential Revision: https://reviews.llvm.org/D118791
2022-02-03 22:36:03 -05:00
Guillaume Chatelet d5bb0de75e
[libc] Populate rtti/eh flags for all targets 2022-02-02 15:15:39 +01:00
Guillaume Chatelet 36c36c1ee3 [libc] use llvm_update_compile_flags to populate rtti/exception compilation flags 2022-02-02 13:36:30 +00:00
Guillaume Chatelet 02022ccccc [NFC][libc] Remove unneeded gtest and benchmark configuration
Differential Revision: https://reviews.llvm.org/D118770
2022-02-02 12:23:44 +00:00
Guillaume Chatelet b840f30d1e [libc] Fix automemcpy test by adding memmove configuration 2022-02-02 11:28:06 +00:00
Siva Chandra be7c865af1 [libc] Add a few missing deps, includes, and fix a few typos.
This allows us to enable rmdir, mkdir, mkdirat, unlink and unlinkat for
aarch64.
2022-02-01 00:26:36 -08:00
Siva Chandra Reddy 4c1b44160a [libc] Adjust few fcntl macros for aarch64. 2022-02-01 08:14:32 +00:00
Siva Chandra Reddy b8385162c2 [libc] Add implementations of POSIX mkdir, mkdirat, rmdir, unlink and unlinkat.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D118641
2022-02-01 05:17:10 +00:00
Jeff Bailey 4465c29906 Move LLVM Proposal to doc directory, create index
The LLVM Libc project is no longer just a proposal and should have
a webpage tracking the status of the project.  This changes
puts the pieces into the right place so that the webpage can be
created.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D117436
2022-01-29 00:29:31 +00:00
Siva Chandra 0e91c48df0 [libc] Enable creat, fsync, open, openat, read and write for aarch64. 2022-01-28 12:06:08 -08:00
Siva Chandra Reddy 4abfe47e1f [libc] Add implementations of the POSIX creat and openat functions.
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D118435
2022-01-28 19:28:12 +00:00
Tue Ly ad4ee2d778 [libc] Refactor sqrt implementations and add tests for generic sqrt implementations.
Re-apply https://reviews.llvm.org/D118173 with fix for aarch64.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D118433
2022-01-28 13:39:03 -05:00
Siva Chandra Reddy a858e25f1c [libc][NFC] Create file with all permissions for the user in read_write_test. 2022-01-28 16:41:52 +00:00
Dominic Chen 3f72f9da43 [libc] Fix 64-bit Apple ARM support and header includes
Summary:

Reviewers: sivachandra

Subscribers:

Differential Revision: https://reviews.llvm.org/D114236
2022-01-28 00:22:47 -08:00