Commit Graph

195 Commits

Author SHA1 Message Date
Chris Bieneman c49e5e336b [CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.

This patch contains the following specific changes:

* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration

I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.

This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.

Reviewers: samsonov, iains, jroelofs

Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits

Differential Revision: http://reviews.llvm.org/D19742

llvm-svn: 268977
2016-05-09 21:45:52 +00:00
Saleem Abdulrasool de120799a0 builtins: fix -Werror,-Wunused-variable warning
This removes the unused variable `flags`.  NFC

llvm-svn: 266892
2016-04-20 17:43:43 +00:00
Saleem Abdulrasool 28e1b977d4 builtins: remove use of __attribute__((pcs("aapcs"))) on Windows
Windows does not honour the __attribute__((pcs)) on ARM.  Although this will
result in ABI mismatches, compiler-rt should largely be unneeded for resolving
dependencies as we generate MS ABI compliant library calls now for the most
part.

llvm-svn: 266891
2016-04-20 17:43:40 +00:00
George Burgess IV 908dacf91d Fix StaticAnalyzer complaints. NFC.
Clang's StaticAnalyzer seems to (correctly) complain about code like:

    T *p = calloc(sizeof(U), N);

...Where T and U are different types.

This patch removes some instances of this pattern from compiler-rt.

Patch by Apelete Seketeli.
Differential Revision: http://reviews.llvm.org/D19085

llvm-svn: 266388
2016-04-14 23:58:26 +00:00
Chris Bieneman ac400900da [Darwin] [Builtins] Cleaning up OS X exclude lists. NFC.
This just gets rid of a bunch of empty object file warnings. It doesn't impact the generated archives.

llvm-svn: 264751
2016-03-29 17:34:13 +00:00
Chris Bieneman 8de525696f [Darwin] [Builtins] Remove multi3 from the exclude list.
This addresses PR27077. For some historical reason Darwin wasn't shipping multi3 in the compiler builtin library or in the OS builtin library. This caused building ffmpeg to fail because Polly was generating calls to multi3. It is easy enough to just add the builtin.

llvm-svn: 264750
2016-03-29 17:24:23 +00:00
Chris Bieneman c4613f457a [Darwin] [Builtins] Cleaning up 10.4 exclude lists NFC
This just gets rid of a bunch of empty object file warnings. It doesn't impact the generated archives.

llvm-svn: 264749
2016-03-29 17:24:21 +00:00
Saleem Abdulrasool 61e970607e builtins: make __clear_cache work on Linux-ARM
__clear_cache on Android is identical to the version on Linux.  Use __linux__
instead of __ANDROID__ as __linux__ is defined for Linux and Android.

llvm-svn: 263833
2016-03-18 21:06:06 +00:00
Saleem Abdulrasool fb21509509 builtins: port __clear_cache to Windows ARM
Support __clear_cache on Windows on ARM using the `FlushInstructionCache`
library call.

llvm-svn: 263832
2016-03-18 21:06:03 +00:00
Logan Chien 5b7b9e946c Add ARM EHABI support to gcc_personality_v0.
Until now the only exception APIs supported by gcc_personality_v0
are DWARF EH and SJLJ. This adds support for ARM EHABI as well.

This is achieved by
a) changing the function signature on ARM EHABI,
b) unwinding the stack before returning _URC_CONTINUE_UNWIND.

See "Exception Handling ABI for the ARM Architecture" for details
(http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf).

Patch by Timon Van Overveldt.

llvm-svn: 263010
2016-03-09 13:20:17 +00:00
Saleem Abdulrasool 2b972dfebb builtins: adjust the clobbers list for android __clear_cache
Adjust the clobbers list.  This use to work with older versions of gcc, but now
will error on newer versions (tested against 5.3) (as well as clang).

Patch by Tee Hao Wei!

llvm-svn: 261821
2016-02-25 04:04:37 +00:00
Andrey Turetskiy bc0122bca9 [CMake] Add partial support for MSVC in compiler-rt builtins, by Roman Shirokiy.
This enables MSVC build of complex number arithmetic compiler-rt builtins.

Differential Revision: http://reviews.llvm.org/D17452

llvm-svn: 261432
2016-02-20 12:56:04 +00:00
Chih-Hung Hsieh c2fab48145 builtins: Fix struct __emutls_control to match GCC
The type of size and align in struct __emutls_control must be
  typedef unsigned int gcc_word __attribute__((mode(word)));
to match GCC. When gcc_word is larger than size_t, which is the case
for x32, the upper extra bits are all zeros. We can use variables of
size_t to operate on size and align.

Fix one trivial C99 warning about mixed declaration and code.

Differential Revision: http://reviews.llvm.org/D16886

llvm-svn: 259824
2016-02-04 20:26:00 +00:00
Anna Zaks c77a080bdb [asan] Add iOS support.
llvm-svn: 259451
2016-02-02 02:01:17 +00:00
Dan Gohman 746cd84e3c [WebAssembly] Enable the builtins library for WebAssembly.
llvm-svn: 257619
2016-01-13 16:56:15 +00:00
Dan Gohman 01731fc150 [WebAssembly] clang supports int128_t on wasm32 in addition to wasm64.
llvm-svn: 257618
2016-01-13 16:47:51 +00:00
Nico Weber 6341a79387 fix a gcc warning
llvm-svn: 256256
2015-12-22 17:22:25 +00:00
Sumanth Gundapaneni c1c674c60b builtins: Fix the sysroot's reference to si_int in int_types.h
si_int is already defined in sysroot's siginfo.h
emutls.c includes pthread.h which includes asm/siginfo.h which
in turn includes asm-generic/siginfo.h and that defines si_int.
si_int is also defined in builtin's int_types.h and this leads to
errors. This patch fixes the issue by undefining the si_int in int_types.h

Differential Revision: http://reviews.llvm.org/D15086

llvm-svn: 254472
2015-12-01 23:06:23 +00:00
Sumanth Gundapaneni 9af8961a86 builtins: Build emutls.c on MINGW builds
Differential Revision: http://reviews.llvm.org/D15083

llvm-svn: 254470
2015-12-01 23:04:33 +00:00
Joerg Sonnenberger 47174a5a2c Add a generic version of __divtc3.c for long double complex division.
Mark the unit test as applying to all platforms.

llvm-svn: 253831
2015-11-22 19:13:49 +00:00
Joerg Sonnenberger 132069c167 Move prototypes for the double-double helpers into the common header.
llvm-svn: 253828
2015-11-22 18:49:56 +00:00
Joerg Sonnenberger 0a22a96dc6 Don't use implementation namespace for include guard. Fix spacing.
llvm-svn: 253827
2015-11-22 18:48:32 +00:00
George Burgess IV b47c02f39b Silence "unrecognised -std=c99" warning on MSVC.
Thanks to angelsl for the patch!

Differential Revision: http://reviews.llvm.org/D13692

llvm-svn: 253646
2015-11-20 03:37:12 +00:00
Chris Bieneman 73d0562542 [CMake] [Darwin] [Builitins] Removing muloti4 from the blacklists for arm.
llvm-svn: 252965
2015-11-12 22:37:01 +00:00
Chris Bieneman 77e5eea728 [CMake] [Darwin] [Builtins] Sorting and uniquing blacklists. NFC.
llvm-svn: 252964
2015-11-12 22:36:57 +00:00
Chris Bieneman b3df467fc8 [CMake] [builtins] Removing a few non-source files from the arm list.
I was a little too aggressive about adding sources from the arm subdirectory.

llvm-svn: 252929
2015-11-12 19:27:29 +00:00
Chris Bieneman 7beed7eb6c [CMake] Actually adding the TODO comment I mentioned in r252927.
Turns out you need to save before committing.

llvm-svn: 252928
2015-11-12 19:17:05 +00:00
Chris Bieneman a2151fdceb [CMake] [builtins] Adding missing architecture-specific builtins.
Also added a TODO comment to make the build system throw an error if the CMakeLists gets out of sync again.

llvm-svn: 252927
2015-11-12 19:15:56 +00:00
Sergey Dmitrouk 195f3a15e6 [compiler-rt][aarch64] New tests for 128-bit floating-point builtins, fixes of tests and __fixuint
Summary:
The following tests for 128-bit floating-point type behaved in a strange way, thought it were bugs, but seem to be mistakes in tests:

 * `fixtfsi` test checked for `0x80000001` as a value returned for number less than can be represented, while `LONG_MIN` should be returned on saturation;
 * `fixunstfdi` wasn't enabled for AArch64, only for PPC, but there is nothing PPC specific in that test;
 * `multf3` tried to underflow multiplication by producing result with 16383 exponent, while there are still 112 bits of fraction plus implicit bit, so resultant exponent should be 16497.

Tests for some other builtins didn't exist:

 * `fixtfdi`
 * `fixtfti`
 * `fixunstfti`

They were made by copying similar files and adjusting for wider types and adding/removing some reasonable/extra checks.

Also `__fixuint` seems to have off by one error, updated tests to catch this case.

Reviewers: rengolin, zatrazz, howard.hinnant, t.p.northover, jmolloy, enefaim

Subscribers: aemerson, llvm-commits, rengolin

Differential Revision: http://reviews.llvm.org/D14187

llvm-svn: 252180
2015-11-05 18:36:42 +00:00
Martell Malone 53f8a53fb6 Fix r251928 build error
llvm-svn: 251931
2015-11-03 16:04:28 +00:00
Martell Malone 40eb83ba56 Support for 32-bit mingw-w64 in compiler-rt.
Add chkstk/alloca for gcc objects.
Replace or instructions with test, the latter should be marginally more
efficent, as it does not write to memory.

Differential Revision: http://reviews.llvm.org/D14044

Patch by vadimcn

llvm-svn: 251928
2015-11-03 15:46:23 +00:00
Saleem Abdulrasool b5bba5c256 builtins: Expand out floating point exponents for MSVC
MSVC 2013 doesnt support C99 fully, including the hexidecimal floating point
representation.  Use the expanded value to permit building with it.

Patch by Tee Hao Wei!

llvm-svn: 250365
2015-10-15 04:26:19 +00:00
Saleem Abdulrasool 9ca87a63ad builtins: use C implementation on MSVC
The assembly implementations use GNU syntax which MSVC doesn't handle.  Rather
than duplicate the code in a second syntax, use the C implementations.

Patch by Tee Hao Wei!

llvm-svn: 250360
2015-10-15 02:47:19 +00:00
Saleem Abdulrasool 956365ef7f builtins: __builtin_clzll for x86 on MSVC
Add an implementation for __builtin_clzll on MSVC even when _BitScanForward4 is
unavailable.

Patch by Tee Hao Wei!

llvm-svn: 250359
2015-10-15 02:46:37 +00:00
Saleem Abdulrasool 565872584b Revert "builtins: enable builtins build for MSVC"
Revert once more.  This seems to fail to build on the buildbots which build with
ninja rather than MSBuild/Visual Studio.  This requires further build
infrastructure changes to deal with the assembly routines.

llvm-svn: 250001
2015-10-11 22:30:10 +00:00
Saleem Abdulrasool 76e70699d5 Revert "Revert "builtins: enable builtins build for MSVC""
Previous changes should now permit building on MSVC 2013 in addition to MSVC
2015.

llvm-svn: 250000
2015-10-11 22:00:46 +00:00
Saleem Abdulrasool e49971517a builtins: define and use ALWAYS_INLINE
Abstract out the always inline spelling similar to ASAN.  NFC.

llvm-svn: 249986
2015-10-11 17:35:42 +00:00
Saleem Abdulrasool 8b3353f20f builtins: use NORETURN macro
Now that we have the NORETURN macro, use that to mark the function as noreturn,
rather than the GNU __attribute__.

llvm-svn: 249985
2015-10-11 17:35:38 +00:00
Saleem Abdulrasool 911cfc11c4 builtins: spell inline as __inline
__inline is a vendor specific spelling for inline.  clang and gcc treat it the
same as inline, and is available in MSVC 2013 which does not implement C99
(VS2015 supports the inline keyword though).  This will allow us to build the
builtins using MSVC.

llvm-svn: 249953
2015-10-10 21:21:28 +00:00
Saleem Abdulrasool 114aae4ac7 Revert "builtins: enable builtins build for MSVC"
Seems to break on the sanitizer buildbot.  Revert until it can be fixed
properly.

llvm-svn: 249950
2015-10-10 18:52:01 +00:00
Saleem Abdulrasool 9650c4a26e builtins: silence a MSVC warning
_BitReverse64 is only available on ARM and x64.  Guard it accordingly.

llvm-svn: 249949
2015-10-10 17:57:37 +00:00
Saleem Abdulrasool fbd8bb6fee builtins: enable builtins build for MSVC
Patch by Tee Hao Wei!

llvm-svn: 249948
2015-10-10 17:57:33 +00:00
Chris Bieneman 6ed46bd380 [CMake] [macho_embedded] [builtins] Need to also drop the bswap builtins.
llvm-svn: 249914
2015-10-09 22:46:19 +00:00
Chris Bieneman 0ed9bc1995 [CMake] hand tuning the macho_embedded export lists to match the current Xcode distribution.
llvm-svn: 249912
2015-10-09 22:40:47 +00:00
Chris Bieneman b9cca18f11 [CMake] Hand tuning the exclude lists for libclang_rt.10.4.a
llvm-svn: 249888
2015-10-09 19:53:54 +00:00
Oliver Stannard 28d2edad5b Add ARM RTABI aliases for half-precision conversions
The ARM RTABI defines these functions as __aeabi_h2f, __aeabi_f2h and
__aeabi_d2h, so we need aliases for them.

llvm-svn: 249559
2015-10-07 16:15:22 +00:00
Saleem Abdulrasool e597ace1fe builtins: fix build
__GNUC__ indicates the GNU compiler, not __GNU__.  This got through due to
building with clang rather than gcc.

llvm-svn: 249516
2015-10-07 03:30:02 +00:00
Saleem Abdulrasool 396e794459 builtins: implement instrinics for cl
cl does not support the same intrinsics as clang.  Provide implementations for
the intrinsics using MSVC builtins.

Patch by Tee Hao Wei!

llvm-svn: 249515
2015-10-07 02:58:11 +00:00
Saleem Abdulrasool b0b7c8a8dd builtins: emulate _Complex for cl
cl does not support C99 completely as of VS2015.  Emulate _Complex to allow
building with MSVC.

Patch by Tee Hao Wei!

llvm-svn: 249514
2015-10-07 02:58:07 +00:00
Saleem Abdulrasool 71c47e5a86 builtins: use MSVC intrinsics with cl
Use MSVCRT functions for floating-point builtins unavailable on MSVC.

Patch by Tee Hao Wei!

llvm-svn: 249513
2015-10-07 02:58:02 +00:00