Commit Graph

2518 Commits

Author SHA1 Message Date
Guillaume Chatelet
c2dcdf95eb [libc] Fix benchmarks CMakeLists.txt
Summary:
This is a follow up on https://reviews.llvm.org/rGaba80d0734d1#886881.
`target_link_options` requires CMake>=3.13.

Reviewers: abrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D73452
2020-01-29 15:56:47 +01:00
Guillaume Chatelet
2c1a142a78 Fix missing dependency in LibcUnitTest
Summary: LibcUnitTest is missing a dependency on LLVMSupport. This prevents building with shared libraries.

Reviewers: sivachandra

Subscribers: mgorny, MaskRay, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D73337
2020-01-27 10:14:39 +01:00
Siva Chandra Reddy
ec62bf2fd3 [libc] Move the implementation of mmap and munmap into a linux specific area.
This allows us to get rid of the PAGE_SIZE macro and use EXEC_PAGESIZE
from linux/param.h.

Few other points about this change:
1. The linux syscall functions have been moved into a linux specific area
instead of src/unistd/syscall.h. The Linux syscall function from unistd.h
is a public vararg function. What we have currently are linux speciif internal
overloaded C++ functions. So, moving them to a Linux only area is more
meaningful.
2. The implementations of mmap and munmap are now in a 'linux' directory
within src/sys/mman. The idea here is that platform specific
implementations will live in a platform specific subdirectories like these.
Infrastructure common to a platform will live in the platform's config
directory. For example, the linux syscall implementations live in
config/linux.

Reviewers: abrachet

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D73302
2020-01-24 15:42:28 -08:00
Guillaume Chatelet
aba80d0734 [llvm-libc] Add memory function benchmarks
Summary:
This patch adds a benchmarking infrastructure for llvm-libc memory functions.

In a nutshell, the code can benchmark small and large buffers for the memcpy, memset and memcmp functions.
It also produces graphs of size vs latency by running targets of the form `render-libc-{memcpy|memset|memcmp}-benchmark-{small|big}`.

The configurations are provided as JSON files and the benchmark also produces a JSON file.
This file is then parsed and rendered as a PNG file via the `render.py` script (make sure to run `pip3 install matplotlib scipy numpy`).
The script can take several JSON files as input and will superimpose the curves if they are from the same host.

TODO:
 - The code benchmarks whatever is available on the host but should be configured to benchmark the -to be added- llvm-libc memory functions.
 - Add a README file with instructions and rationale.
 - Produce scores to track the performance of the functions over time to allow for regression detection.

Reviewers: sivachandra, ckennelly

Subscribers: mgorny, MaskRay, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D72516
2020-01-24 11:30:58 +01:00
Siva Chandra Reddy
c7453fad06 [libc] Replace the use of gtest with a new light weight unittest framework.
Header files included wrongly using <...> are now included using the
internal path names as the new unittest framework allows us to do so.

Reviewers: phosek, abrachet

Differential Revision: https://reviews.llvm.org/D72743
2020-01-17 16:24:53 -08:00
Siva Chandra Reddy
880734aebb [libc] Add a convenience CMake rule to add testsuites.
Summary:
This rule helps avoid repeated setting of check-libc's dependency on the
various testsuites.

Reviewers: abrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D72353
2020-01-07 23:04:52 -08:00
Siva Chandra Reddy
188f72ab20 [libc] Move implementations of strcat and strcpy to the string directory.
Summary:
Now that tests live in separate top-level directory, keeping the
implementations of individual functions in a directory of their own is
not meaningful. Hence, this change moves them into the higher level
string directory.

NFC intended.

Reviewers: MaskRay

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D72295
2020-01-06 22:20:42 -08:00
Siva Chandra Reddy
6598af4a54 [libc] Add __attribute__((always_inline)) to x86_64 syscall functions.
Summary:
Some syscalls like SYS_clone do not tolerate a return instruction after
the syscall instruction. Marking the syscall functions with the
`always_inline` attribute accommodates such syscalls as inlining
eliminates the return instruction.

Reviewers: abrachet, phosek

Subscribers: MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D72102
2020-01-06 21:19:17 -08:00
Siva Chandra Reddy
5b24c08817 [libc] Move all tests to a top level test directory.
A toplevel target, `check-libc` has also been added.

Reviewers: abrachet, phosek

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D72177
2020-01-06 10:14:43 -08:00
Guillaume Chatelet
3e1f3b164c [llvm-libc] Fix missing virtual destructor
Summary: This patch adds a virtual destructor to the Command class.

Reviewers: sivachandra

Subscribers: mgorny, MaskRay, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D72253
2020-01-06 17:42:05 +01:00
Siva Chandra Reddy
e5a743c4f6 Add implementations of POSIX mmap and munmap functions.
Summary:
A set of of linux x86_64 internal syscall helpers have also been added.

This change does not try to be perfect with respect to OS and machine
abstractions. A TODO note has been added at places where such abstractions
would help and make the arrangement scalable and cleaner. Addressing the
TODOs and building such abstractions is not in the scope of this change.
It is hoped that follow up changes cleaning up the problem areas and
addressing the TODOs will better illustrate the need for the changes.

This change also does not try to imitate mmap and munmap implementations
of other libcs. The idea here is to put in the bare minimum required to
obtain a working mmap and munmap, and then add the rest of the
functionality on an as needed basis.

Reviewers: abrachet, phosek, stanshebs, theraven

Subscribers: mgorny, MaskRay, jfb, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D71634
2019-12-23 14:04:02 -08:00
Siva Chandra Reddy
453c85ff0f [libc] Add implementation of errno and define the other macros of errno.h.
Reviewers: stanshebs, alexbrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D71094
2019-12-09 13:34:08 -08:00
Siva Chandra Reddy
b47f9eb55d [libc] Add a TableGen based header generator.
Summary:
* The Python header generator has been removed.
* Docs giving a highlevel overview of the header gen scheme have been
  added.

Reviewers: phosek, abrachet

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D70197
2019-11-22 13:02:24 -08:00
Siva Chandra Reddy
9364107cf3 Illustrate a redirector using the example of round function from math.h.
Setup demonstrated in this patch is only for ELF-ish platforms.

Also note:

1. Use of redirectors is a temporary scheme. They will be removed once
   LLVM-libc has implementations for the redirected functions.
2. Redirectors are optional. One can choose to not include them in the
   LLVM-libc build for their platform.
3. Even with redirectors used, we want to link to the system libc
   dynamically.

Reviewers: dlj, hfinkel, jakehehrlich, phosek, stanshebs, theraven, alexshap

Subscribers: mgorny, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D69020
2019-11-01 11:06:12 -07:00
Siva Chandra
c1157d1e77 [libc] Do not add unittests if LLVM_INCLUDE_TESTS is OFF.
Reviewers: nathanchance

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D68726

llvm-svn: 374925
2019-10-15 17:42:28 +00:00
Siva Chandra
7a6d98325c Use arrays on stack and avoid use of new and delete operators.
Summary: Also fix an error found with LLVM_USE_SANITIZER=Address.

Reviewers: nelhage

Subscribers: libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D68761

llvm-svn: 374374
2019-10-10 16:06:21 +00:00
Siva Chandra
4380647e79 Add few docs and implementation of strcpy and strcat.
Summary:
This patch illustrates some of the features like modularity we want
in the new libc. Few other ideas like different kinds of testing, redirectors
etc are not yet present.

Reviewers: dlj, hfinkel, theraven, jfb, alexshap, jdoerfert

Subscribers: mgorny, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67867

llvm-svn: 373764
2019-10-04 17:30:54 +00:00
David L. Jones
ec80f531ca Add a director, along with README.txt and LICENSE.txt, for libc.
llvm-svn: 372036
2019-09-16 21:39:08 +00:00