Commit Graph

130 Commits

Author SHA1 Message Date
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
Guillaume Chatelet
0d52a7d038 [libc][NFC] Simplify memcpy implementation
Summary: This is a NFC, it aims at simplifying both the code and build files.

Reviewers: abrachet, sivachandra

Subscribers: mgorny, tschuett, ecnelises, libc-commits, courbet

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D80291
2020-05-26 11:38:48 +00:00
Paula Toth
2a4c30985d [libc] Make clang-tidy use host compiler's resource dir.
Summary: When building llvm-libc with linting enabled, clang-tidy would use the resource dir of the monorepo rather then the host compiler's resource dir. This presented issues when including headers from the host compiler e.g. for sanitizers. Therefore this patch explicitly tells clang-tidy to use the host compiler's resource dir.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, ecnelises, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D80265
2020-05-21 18:40:59 -07:00
Paula Toth
b2a485e37e [libc] Fix accidental inclusion of system libc headers.
Summary:
I found that because `--system-headers` flag was not included when running clang-tidy, errors produced from compiler provided headers were being suppressed. After passing this flag I realized that by including headers like stdint.h we were indirectly including headers from the system libc. To prevent this we pass `-ffreestanding`.
We don't want to pass `--system-headers` for all checks just the `llvmlibc-restrict-system-libc-headers` therefore we do a separate invocation of clang-tidy for this check.

Reviewers: abrachet, sivachandra

Reviewed By: sivachandra

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

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D80178
2020-05-21 01:21:37 -07:00
Mehdi Amini
c32d695b09 Fix typo in CMake error message "LLVM_LIBC_ENABLE_PROJECTS"->"LLVM_ENABLE_PROJECTS" (NFC) 2020-05-21 03:08:47 +00:00
Guillaume Chatelet
6ca54e0114 [libc] Add memset and bzero implementations
Summary: This patch adds general purpose `memset` and `bzero` implementations.

Reviewers: sivachandra, abrachet

Subscribers: mgorny, tschuett, ecnelises, libc-commits, courbet

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D80010
2020-05-20 06:35:13 +00:00
Siva Chandra Reddy
96d85726b0 [libc] Move implementations of expf and exp2f from the AOR to src/math.
Reviewers: phosek

Differential Revision: https://reviews.llvm.org/D79149
2020-05-15 12:43:03 -07:00
Siva Chandra Reddy
4a39a33d44 [libc] Add implementation of fabs and fabsf.
Reviewers: phosek

Differential Revision: https://reviews.llvm.org/D79725
2020-05-15 11:10:43 -07:00
Siva Chandra Reddy
32a22a423c [libc] Consolidate floating point utils into a single utils library.
A new utils library named 'fputil' is added. This library is used in
math tests and the MPFR wrapper. The math implementations will be
modified to use this library in a later round.

Reviewers: phosek

Differential Revision: https://reviews.llvm.org/D79724
2020-05-15 11:08:41 -07:00
Siva Chandra Reddy
b7afa92e75 [libc] Call mtx_init in mtx_test.
A typo which was caught has also been fixed.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D79826
2020-05-13 09:48:31 -07:00
Siva Chandra Reddy
e17a47b2d3 [libc][Obvious] Fix deps of few threads targets.
A missing dep has been added, and a few redundent deps have been
removed.
2020-05-12 16:14:12 -07:00
Paula Toth
bf6f3894c4 [libc] Fix warnings on release build.
Summary:
These warnings were present when building llvm-libc in release mode.

```
workspace/llvm-project/libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp:50:34: warning: 'None' is deprecated: Use Align() or Align(1) instead [-Wdeprecated-declarations]
  Conf.AddressAlignment = Align::None();

workspace/llvm-project/libc/utils/testutils/FDReaderUnix.cpp:19:7: warning: unused variable 'err' [-Wunused-variable]
  int err = ::pipe(pipefd);
```

For test-utils it seems in general we should use `report_fatal_error` instead of asserts as these are turned off when building in release mode.
https://llvm.org/docs/CodingStandards.html#assert-liberally

Reviewers: abrachet, sivachandra

Reviewed By: abrachet, sivachandra

Subscribers: tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D79469
2020-05-07 11:56:11 -07:00
Eric Christopher
880115e65e [libc] Reorganize and clarify a few points around benchmarking
A few documentation clarifications and moving one part of the
docs around to be closer to the first mention of display so that
it's easier to spot based on some user feedback.

Differential Revision: https://reviews.llvm.org/D79443
2020-05-06 13:54:13 -07:00
Siva Chandra Reddy
a7e1149699 [libc] Fix how math results are compared with MPFR results.
Summary:
Math results are compared with MPFR results by checking if they are
within a tolerance level of the MPFR result. The tolerance level is set
using additional bits of precision of the fractional part of a floating
point value. Hence, the actual value of the tolerance depends on not
only the additional bits, but also on the exponent part of the floating
point number.

Previously, the exponent part was not considered in evaluating the
tolerance value. While it was OK for small values less than 1 (hence
sinf, cosf, sincosf tests were OK), it breaks for large values which
functions like exp and friends produce. This change uses the exponent
value also to evaluate the tolerance value. LLVM libc produced results
can now be compared with MPFR produced results for large values also.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D79278
2020-05-06 10:47:23 -07:00
Paula Toth
d80715d1d4 [libc] Change target name for testing benchmark utils infrastructure.
Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: gchatelet, mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D79466
2020-05-06 01:22:15 -07:00
Siva Chandra Reddy
fbaaa16802 [libc] Add no_sanitize("address") attribute to the getMPFRMatcher function.
This dramtically reduces the run time of tests. For example,
sincosf_test takes over 25 minutes without this attribute but only 8
seconds with this attribute.
2020-05-05 13:30:30 -07:00
Siva Chandra Reddy
d69cbd826a [libc] Improve information printed on failure of a math test which uses MPFR.
A new test matcher class MPFRMatcher is added along with helper macros
EXPECT|ASSERT_MPFR_MATCH.

New type traits classes RemoveCV and IsFloatingPointType have been
added and used to implement the above class and its helpers.

Reviewers: abrachet, phosek

Differential Revision: https://reviews.llvm.org/D79256
2020-05-05 10:26:29 -07:00
Siva Chandra Reddy
9ae2564396 [libc] Include object files from alias entrypoints also in entrypoint libraries.
Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D79185
2020-05-04 11:39:37 -07:00
Siva Chandra Reddy
245cbd15a4 [libc] Add definitions of double_t and float_t to math.h.
This change does not handle any extensions. Only the C standard
variations are handled.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D79150
2020-04-30 11:59:11 -07:00
Siva Chandra Reddy
675eea46f0 [libc][NFC] Rename cpp::function to cpp::Function.
Summary: Just to be consistent with other names in cpp.

Reviewers: abrachet

Subscribers: tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D79189
2020-04-30 11:58:26 -07:00
Paula Toth
6b01964271 [libc] Add strlen to library entrypoints.
Reviewers: sivachandra, abrachet

Reviewed By: abrachet

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D79016
2020-04-28 16:14:54 -07:00
Siva Chandra Reddy
1852af16a1 [libc] Fix benchmarks build.
Reviewers: gchatelet, echristo

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D79040
2020-04-28 14:30:48 -07:00
Eric Christopher
f1ecf560bf Add StringRef include to libc benchmark. 2020-04-28 13:12:26 -07:00
Paula Toth
29213878e7 [libc] Add spec for sigdelset and sigfillset.
Summary: Caught by libc-tidy from patch D77281.

Reviewers: abrachet, sivachandra

Reviewed By: abrachet

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D78703
2020-04-23 16:38:47 -07:00
Paula Toth
d94af364ac [libc] Surround get_start_args_addr in __llvm_libc namespace.
Summary: Caught by libc-tidy from patch D77281.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D78700
2020-04-23 15:15:00 -07:00
Siva Chandra Reddy
1e2772c0a3 [libc] Link mpfr and gmp wrapper to the libcMPFRWrapper.
This will fix building the wrapper shared library when
BUILD_SHARED_LIBS is ON.

Reviewers: PaulkaToast

Differential Revision: https://reviews.llvm.org/D78737
2020-04-23 11:37:13 -07:00
Siva Chandra Reddy
c08af2c11a [libc][NFC] Cleanup dependencies in src/signal and test/src/signal.
Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D78585
2020-04-21 22:25:01 -07:00
Siva Chandra Reddy
7f12512db2 [libc][Take 2] Propagate entrypoint deps to downstream targets.
This reverts commit a8086ba4ac.
Setting couple of target properties to an empty string was missed in the
previous commit.
2020-04-21 10:29:09 -07:00
Siva Chandra Reddy
a8086ba4ac [libc] Revert "Propagate entrypoint deps to downstream targets."
This reverts commit 20cb440ea2 as the
target llvmlibc seems to be failing on the bots.
2020-04-21 10:10:18 -07:00
Siva Chandra Reddy
20cb440ea2 [libc] Propagate entrypoint deps to downstream targets.
Deps are recrusively evaluated at the place they are needed. With this
change, one does not have to list recursive deps of entrypoints when
listing test targets. One will still have to explicitly list all
entrypoint objects when setting up an "add_entrypoint_library" target.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D78537
2020-04-21 09:58:55 -07:00
Siva Chandra Reddy
8c2e66226f [libc] [NFC] Split the CMake rules into multiple files.
Summary:
The single file was getting too long to be convenient to navigate. This
patch splits it up two into 4 files one each for header rules,
object rules, library rules, and test rules.

Reviewers: abrachet, alexshap

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D78536
2020-04-21 09:24:17 -07:00
Alex Brachet
5793c84925 [libc] Add write(2) implementation for Linux and FDReader test utility
Summary: Adds `write` for Linux and FDReader utility which should be useful for some stdio tests as well.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D78184
2020-04-17 13:21:05 -04:00
Alex Brachet
d9e96b6a02 [libc] Add spec/*.td as dependencies to add_gen_header
Summary: It also re formats long lines in `add_gen_header`

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D78349
2020-04-17 13:10:46 -04:00
Siva Chandra Reddy
a127d61835 [libc] Disable AOR ulp tests for sinf, cosf and sincosf.
They seemed to fallback to the system libc and start depending on its
accuracy.
2020-04-17 09:01:44 -07:00
Alex Brachet
91c10f50f3 Use proper dependency name for libc.include.stdio 2020-04-17 05:10:22 -04:00
Paula Toth
741d3c2016 [libc] Add cmake target for linting libc.
Summary:
This patch implements running linting on llvm-libc using build rule targets.

1) adds a new target per entrypoint for linting with the naming convention `<qualified_target_name>.__lint__` e.g `libc.src.string.strlen.__lint__`.
2) makes the build target for each entrypoint depend on the linting targets so that they run along with compilation of each entrypoint.
3) adds a lint all target named `lint-libc`.  `check-libc` now depends on this new target.
4) linting creates a lot of additional targets from clang and clang-tidy that need to be built so an opt out flag can be passed to cmake: `LLVM_LIBC_ENABLE_LINTING`.

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra

Subscribers: abrachet, mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D77861
2020-04-16 17:41:03 -07:00
Siva Chandra Reddy
5fedf7f420 [libc] Move implementations of cosf, sinf, sincosf to src/math directory.
NFC intended in the implementaton. Only mechanical changes to fit the LLVM
libc implementation standard have been done.

Math testing infrastructure has been added. This infrastructure compares the
results produced by the libc with the high precision results from MPFR.
Tests making use of this infrastructure have been added for cosf, sinf and
sincosf.

Reviewers: abrachet, phosek

Differential Revision: https://reviews.llvm.org/D76825
2020-04-16 08:46:10 -07:00
Alex Brachet
99aea57928 [libc] Add very basic stdio FILE and fwrite
Summary:
This patch adds a very basic `FILE` type and basic `fwrite`.

It also removes `snprintf` from `StdIO`'s function spec because `VarArgType` was causing the generation to fail.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D77626
2020-04-14 04:02:27 -04:00
Alex Brachet
54d13b5b2d [libc] Remove <functional> dependency in syscall_test.cpp
Summary: Create self contained functional header which has a type similar to `std::function`

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D77948
2020-04-14 03:27:10 -04:00