Commit Graph

111 Commits

Author SHA1 Message Date
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
Siva Chandra Reddy e4767a6f14 [libc] Add fully-qualified target names.
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-10 18:01:52 -07:00
Paula Toth be54ea52f1 [libc] Change minimum cmake requirement.
Summary: As per this thread: http://lists.llvm.org/pipermail/llvm-dev/2020-April/140744.html, changed the minimum requirement to reflect the decision made to upgrade to cmake 3.13.4.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D77781
2020-04-09 20:42:55 -07:00
Siva Chandra Reddy 939fa1b560 [libc] Collect objects only from visible deps of an object library.
A typo in an earlier change allowed this check to be missed.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D77256
2020-04-09 10:40:37 -07:00
Paula Toth 66d00feb18 [libc][NFC] Make all top of file comments consistent.
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-08 10:18:37 -07:00
Kazuaki Ishizaki 0570de73c4 [libc] NFC: Fix trivial typo in comments, documents, and messages
Differential Revision: https://reviews.llvm.org/D77462
2020-04-06 16:19:34 +09:00
Paula Toth 90eb7be6a1 [libc] Fix memcpy to adhere to qualified calls.
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 15:27:57 -07:00
Paula Toth 1fcfd30fae [libc] Add strlen implementation.
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-04-03 15:11:35 -07:00
Alex Brachet 123a5328f9 [libc] Add sigfillset and sigdelset
Summary: Add's `sigfillset` and `sigdelset` which will be used in D76676.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D76936
2020-04-01 15:07:49 -04:00
Alex Brachet 6a4f8423ae [libc] Only use __has_builtin on clang
The preprocessor reads the whole line even if the first condition of an and is false so this broke when compiling on older gcc versions which don't recognize `__has_builtin`
2020-03-28 12:28:43 -04:00
Siva Chandra Reddy 51b899c846 [libc] Extend add_object rule to handle helper object libraries.
The rule is now called add_object_library.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D76826
2020-03-28 00:07:46 -07:00
Alex Brachet 255e634bf7 [libc][NFC] Ensure internal implementation is in __llvm_libc namespace
Summary: In preparation for D76818.

Reviewers: PaulkaToast, sivachandra, gchatelet

Reviewed By: PaulkaToast, sivachandra

Subscribers: MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D76967
2020-03-28 02:59:42 -04:00
Siva Chandra Reddy 911f2e7dc4 [libc] Add a GNU extensions spec containing sincosf from math.h.
Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D76783
2020-03-25 15:13:22 -07:00
Siva Chandra Reddy f6ccb4fef2 [libc] Add a simple x86_64 linux loader.
This adds a very simple loader. This will be extended to a full loader
in future patches. A utility rule to add unittests has been added to
serve us while we are building out the full loader.

Reviewers: abrachet, phosek

Differential Revision: https://reviews.llvm.org/D76412
2020-03-25 10:12:35 -07:00
Siva Chandra Reddy 2c080a3f23 [libc] Generate math.h instead of the static file it is currently.
Just enough to help a follow up patch adding cosf and sinf has been
added.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D76723
2020-03-24 21:17:55 -07:00
Paula Toth dab219eedd [libc] Enable llvmlibc clang-tidy checks
Summary:
Add  clang-tidy for llvm-libc source directory.

Example of check in action:
```
/workspace/llvm-project/libc/src/string/strcpy.cpp:10:1: error: system include stdio.h not allowed [llvmlibc-restrict-system-libc-headers,-warnings-as-errors]
#include <stdio.h>
^~~~~~~~~~~~~~~~~~
```

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra, abrachet

Subscribers: aheejin, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D76559
2020-03-23 20:34:39 -07:00
Alex Brachet a1762f9ceb [libc] Don't configure test and fuzzer when -DLLVM_INCLUDE_TESTS=OFF
Summary:  Fixes problem reported in D74397#1935863

Reviewers: nathanchance, gchatelet, sivachandra, MaskRay

Reviewed By: sivachandra, MaskRay

Subscribers: mgorny, MaskRay, tschuett

Differential Revision: https://reviews.llvm.org/D76577
2020-03-23 01:50:16 -04:00
Alex Brachet 0e1e9b9a81 [libc][NFC] Fix typo in milliseconds 2020-03-22 15:11:22 -04:00
Alex Brachet ca04d0c8fd [libc] Add signal
Summary:
This patch adds a Linux implementation for `signal`
It also fixes `ASSERT|EXPECT_THAT` macros

Reviewers: sivachandra, PaulkaToast, MaskRay

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D76536
2020-03-22 14:15:47 -04:00
Siva Chandra Reddy 25294708f5 [libc] NFC - Move the round redirector from its own nested directory.
We have moved away from directories for entrypoints but this function
was not moved out.

Submitting as obvious.
2020-03-20 12:15:27 -07:00