Commit Graph

318 Commits

Author SHA1 Message Date
Frederich Munch 922b602683 [builtins] Implement emulated TLS on Windows.
Summary:
LLVM JIT needs to be able to use emulated TLS on all platforms, and this provides a reference one can compile to enable emutls for Linux/Mac/Windows.

Reviewers: chh, howard.hinnant

Reviewed By: chh

Subscribers: mgorny, llvm-commits

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

llvm-svn: 301350
2017-04-25 19:04:19 +00:00
Hans Wennborg ac4799b3fc Revert r301089 "[builtins] Implement emulated TLS on Windows."
This broke the self-host build on Windows (PR32777).

Original commit message:

> [builtins] Implement emulated TLS on Windows.
>
> Summary:
> LLVM JIT needs to be able to use emulated TLS on all platforms, and this provides a reference one can compile to enable emutls for Linux/Mac/Windows.
>
> Reviewers: chh, howard.hinnant
>
> Reviewed By: chh
>
> Subscribers: mgorny, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D30787

llvm-svn: 301274
2017-04-24 23:16:49 +00:00
Frederich Munch 5de7f2d7b8 [builtins] Implement emulated TLS on Windows.
Summary:
LLVM JIT needs to be able to use emulated TLS on all platforms, and this provides a reference one can compile to enable emutls for Linux/Mac/Windows.

Reviewers: chh, howard.hinnant

Reviewed By: chh

Subscribers: mgorny, llvm-commits

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

llvm-svn: 301089
2017-04-22 18:45:17 +00:00
Reid Kleckner bfad55fbc0 [builtins] Make some ISA macro checks work with MSVC
llvm-svn: 299786
2017-04-07 17:18:43 +00:00
Reid Kleckner 3ae87c4650 [builtins] Fix MSVC build
Avoid __attribute__((constructor)) in cpu_model.c.

Use more C99 _Complex emulation in divtc3.c. Joerg Sonnenberger added
this builtin just after the last round of C99 _Complex emulation landed
in r249514 (Oct 2015).

llvm-svn: 299784
2017-04-07 16:54:32 +00:00
Reid Kleckner 8c78ca2e8f [builtins] Get the builtins tests passing on Windows
Many things were broken:

- We stopped building most builtins on Windows in r261432 for reasons
  that are not at all clear to me. This essentially reverts that patch.

- Fix %librt to expand to clang_rt.builtins-$arch.lib on Windows instead
  of libclang_rt.builtins-$arch.a.

- Fix memory protection tests (trampoline, enable executable, clear
  cache) on Windows. One issue was that the MSVC incremental linker
  generates ILT thunks for functions with external linkage, so memcpying
  the functions into the executable stack buffer wasn't working. You
  can't memcpy an RIP-relative jump without fixing up the offset.

- Disable tests that rely on C99 complex library functions when using
  the MSVC CRT, which isn't compatible with clang's C99 _Complex.

In theory, these could all be separate patches, but it would not green
the tests, so let's try for it all at once. Hopefully this fixes the
clang-x64-ninja-win7 bot.

llvm-svn: 299780
2017-04-07 16:35:09 +00:00
Dimitry Andric 01220bf9d2 Add __ffssi2 implementation to compiler-rt builtins
Summary:
During MIPS implementation work for FreeBSD, John Baldwin (jhb@FreeBSD.org)
found that gcc 6.x emits calls to __ffssi2() when compiling libc and some
userland programs in the base system.

Add it to compiler-rt's builtins, based off of the existing __ffsdi2()
implementation.  Also update the CMake files and add a test case.

Reviewers: howard.hinnant, weimingz, rengolin, compnerd

Reviewed By: weimingz

Subscribers: dberris, mgorny, llvm-commits, emaste

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

llvm-svn: 299675
2017-04-06 18:12:02 +00:00
Weiming Zhao fbe67da29b [Builtins] Fix div0 error in udivsi3
Summary: Need to save `lr` before bl to aeabi_div0

Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: llvm-commits

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

llvm-svn: 299628
2017-04-06 06:13:39 +00:00
Weiming Zhao d8ca74176e [Builtin] Unxfail tests for armhf
Summary:
Originally, a few tests fail for armhf target due to:
1) COMPILER_RT_ARMHF_TARGET was not set when building the lib
2) COMPILER_RT_ABI should not be defined as `__attribute__((pcs("aapcs")))` for armhf when building for both lib and tests

This address https://bugs.llvm.org//show_bug.cgi?id=32261

mulsc3_test.c is a newly exposed issue, which will be addressed separately.

Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: aemerson, llvm-commits, mgorny

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

llvm-svn: 298974
2017-03-29 03:36:46 +00:00
Weiming Zhao a78ae8a172 Revert "builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA."
This reverts commit c3709191b6d36c4c936173f4a9a29a734b12cb15.
(commit by mistake)

llvm-svn: 298715
2017-03-24 17:08:35 +00:00
Weiming Zhao 19bf8bfa15 builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA.
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.

Due to this:
 - use  __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB
 - use '.thumb' directive consistently  in all affected files
 - decorate all thumb functions using
   DEFINE_COMPILERRT_THUMB_FUNCTION()

---------
Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 !

Reviewers: weimingz, rengolin, compnerd

Subscribers: aemerson, dim

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

llvm-svn: 298713
2017-03-24 17:06:00 +00:00
Alex Lorenz d2677c8ed5 [compiler-rt][builtins] Ignore the deprecated warning for
CFPropertyListCreateFromXMLData that's used in __isOSVersionAtLeast

I forgot to add the pragmas in r297760.

llvm-svn: 297827
2017-03-15 12:13:20 +00:00
Alex Lorenz ca1fab5d66 [compiler-rt][builtins] __isOSVersionAtLeast should load CoreFoundation
symbols dynamically

The CoreFoundation symbols uses by __isOSVersionAtLeast should be loaded at
runtime to ensure that the programs that don't use @available won't have to be
linked to CoreFoundation.

The Clang frontend IRGen library will need to emit a CoreFoundation symbol
when @available is used to ensure that programs that actually use @available
are linked to CoreFoundation.

rdar://31039554

llvm-svn: 297760
2017-03-14 17:53:37 +00:00
Alex Lorenz c630f349b8 [compiler-rt][builtins] Ignore the deprecated warning for
CFPropertyListCreateFromXMLData that's used in __isOSVersionAtLeast

llvm-svn: 297613
2017-03-13 11:00:44 +00:00
Erik Pilkington eea05ec3f3 Silence a pedantic warning, NFC
llvm-svn: 297515
2017-03-10 21:38:59 +00:00
Erik Pilkington 0490e1c5f4 Reapply r297382: "[compiler-rt][builtins] Add __isOSVersionAtLeast()"
Looks like the problem was a case-insensitive include of dispatch/dispatch.h.

llvm-svn: 297392
2017-03-09 17:02:16 +00:00
Erik Pilkington 4d297df95c Revert "[compiler-rt][builtins] Add __isOSVersionAtLeast()"
This reverts r297382, it was causing build failures.

llvm-svn: 297388
2017-03-09 15:58:26 +00:00
Erik Pilkington 6fa97926e9 [compiler-rt][builtins] Add __isOSVersionAtLeast()
This predicate compares the host's marketing OS version to one passed as
argument. Currently, only darwin targets are supported. This is done by parsing
the SystemVersion.plist file.

Also added in this patch is some lit testing infrastructure for builtins, which
previously had none. This part of the patch was written by Alex Lorenz (with
some minor modifications).

This patch is part of a feature I proposed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

Differential revision: https://reviews.llvm.org/D30136

llvm-svn: 297382
2017-03-09 14:17:36 +00:00
Renato Golin fc1ccec9bb [RT ARM] Avoid Linux include with a redefinition
To avoid depending on kernel headers, we just repeat the single define
we need, which is likely never going to change.

Patch by Joakim Sindholt <opensource@zhasha.com>

llvm-svn: 295738
2017-02-21 17:40:26 +00:00
Weiming Zhao a164f470e6 [Builtin][ARM] Fix subsf3vfp for non-HF target
Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: hans, aemerson

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

llvm-svn: 294886
2017-02-12 05:10:25 +00:00
Weiming Zhao d53f34618b [Builtin][ARM] Implement addsf3/__aeabi_fadd for Thumb1
Summary:
This patch implements addsf3/__aeabi_fadd in asm for Thumb1.
Compared with generic C version (lib/fp_add_impl.inc), it
1. all constants are materialized instead of loading from constant pool
2. no stack spills (C version uses 136 bytes stack space)
3. clz() is called only when necessary. (C version always calls it)

Reviewers: compnerd, rengolin, asl

Reviewed By: asl

Subscribers: efriedma, aemerson, mgorny, llvm-commits

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

llvm-svn: 294172
2017-02-06 06:04:10 +00:00
Weiming Zhao a000b467d3 [Bultin][ARM] Make aeabi_uldivmod and aeabi_ldivmod be Thumb1 compatible
Summary:
in aeabi_ldivmod and uldivmod, using r6 instead of r12 as the temp reg due to limitation of Thumb1 ISA.
Now, all EABI sources are Thumb1 compatible.

Also added test cases by reusing the test cases from divmodsi4_test.c, udivmodsi4_test and udivmoddi4_test.c

Reviewers: rengolin, compnerd

Reviewed By: rengolin

Subscribers: javed.absar, aemerson, mgorny, llvm-commits

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

llvm-svn: 293527
2017-01-30 18:48:05 +00:00
Weiming Zhao 68e20da3f9 [Builtin][ARM] Add Thumb1 support for aeabi_c{f,d}cmp.S and dcmp.S
Reviewers: compnerd, rengolin

Reviewed By: rengolin

Subscribers: aemerson, llvm-commits, mgorny

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

llvm-svn: 293247
2017-01-27 01:21:00 +00:00
Saleem Abdulrasool 309b3bfa6a builtins: remove an errant ':'
Thanks to Dave Lee for pointing this out!

llvm-svn: 293120
2017-01-26 00:37:55 +00:00
Weiming Zhao 19f47ace40 [Bultin][ARM] Make aeabi_memset be Thumb1 compatible and other asm
syntax fix

Summary:
Make the asm of  aeabi_memset be assembled for thumb1.
Also fix some instructions to conform with the syntax of ARM reference manual.
For example, muls requires the form of "Rd, Rn, Rd" and orrs requires
the form of "Rd, Rm". Clang-as is benign but it may fail other assembler
if not in the exact form.

Reviewers: rengolin, compnerd, kubamracek

Reviewed By: rengolin, compnerd

Subscribers: aemerson, llvm-commits, mgorny

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

llvm-svn: 292727
2017-01-21 18:24:55 +00:00
Weiming Zhao 93b558a486 [Builtin] [ARM] Update CMake to support the build of armv6m
Summary:
Setting -DCOMPILER_RT_TEST_TARGET_TRIPLE=armv6m-none-eabi  will enable the build of builtin functions ARMv6m.
Currently, only those asms that support armv6m are added.

TODO:All asm sin ARM_EABI_Sources are ported for thumb1 so Thumb1_EABI_Sources will be deprecated.

Reviewers: rengolin, compnerd

Reviewed By: compnerd

Subscribers: aemerson, mgorny, llvm-commits

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

llvm-svn: 292504
2017-01-19 18:46:11 +00:00
Saleem Abdulrasool 9c287bca23 builtins: support building ARM builtins for a HF target
The `-target` impacts the CC for the builtins.  HF targets (with either
floating point ABI) always use AAPCS VFP for the builtins unless they
are AEABI builtins, in which case they use AAPCS.  Non-HF targets (with
either floating point ABI) always use AAPCS for the builtins and AAPCS
for the AEABI builtins.  This introduces the thunks necessary to switch
CC for the floating point operations.  This is not currently enabled,
and should be dependent on the target being used to build compiler-rt.
However, as a stop-gap, a define can be added for ASFLAGS to get the
thunks.

llvm-svn: 291677
2017-01-11 16:19:25 +00:00
Saleem Abdulrasool 7a0838b9b6 builtins: repair __gtsf2 after SVN r291396
The argument adjustment was accidentally removed, resulting in the use
of stale register values.

llvm-svn: 291591
2017-01-10 19:48:50 +00:00
Weiming Zhao ccd3e6803c [Builtins] [ARM] Adding Thumb1 support for fcmp
Summary: Mainly translate IT block into cmp/branch for functions in comparesf2.S

Reviewers: rengolin, compnerd

Subscribers: aemerson, llvm-commits

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

llvm-svn: 291396
2017-01-08 18:51:12 +00:00
Michal Gorny 42af8da4c8 [builtins] Implement __floattitf() & __floatuntitf()
Implement the missing __floattitf() and __floatuntitf() functions, to
convert 128-bit (unsigned) integers to quad-precision floating-point
types. This is needed e.g. on AArch64 where 'long double' is
a quad-precision type.

The code is based on the existing code for __floattixf()
and __floatuntixf(), updated to account for different bit field lengths
of quad-precision float. The tests are also copied, with the rounding
tests adjusted for longer significand.

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

llvm-svn: 291259
2017-01-06 18:46:35 +00:00
Weiming Zhao 0a274c5954 [builtin] Add Thumb1 implementation for idivsi3 and aeabi_idivmod
Summary:
For idivsi3, convert the Thumb2 only instruction to thumb1.
For aeabi_idivmod, using __divsi3.

Reviewers: rengolin, compnerd

Subscribers: llvm-commits

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

llvm-svn: 288960
2016-12-07 19:14:29 +00:00
Weiming Zhao a913f7ddbe [builtin] for the condition for check __ARM_FEATURE_CLZ
Summary: Since CLZ is not available for Thumb1, we use __ARM_ARCH_ISA_THUMB != 1 as one of the conditions.

Reviewers: rnk, compnerd, rengolin

Subscribers: aemerson, rengolin, llvm-commits

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

llvm-svn: 288954
2016-12-07 18:41:07 +00:00
Weiming Zhao 05fec0907d builtins: Add ARM Thumb1 implementation for uidiv and uidivmod
This is a resubmit of r288710 due to breakage of Darwin armv7em.

llvm-svn: 288777
2016-12-06 07:13:15 +00:00
Chris Bieneman 31150cbdc9 Revert "builtins: Add ARM Thumb1 implementation for uidiv and uidivmod"
This reverts commit r288710.

r288710 breaks building the builtin libraries on Darwin for armv7em.

Build logs may still be avaialable here:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/12035/console

llvm-svn: 288773
2016-12-06 05:41:32 +00:00
Weiming Zhao adf4258f50 builtins: Add ARM Thumb1 implementation for uidiv and uidivmod
Summary:
The current uidiv supports archs without clz. However, the asm is for thumb2/arm.
For uidivmod, the existing code calls the C version of uidivmodsi4, which then calls uidiv. The extra push/pop/bl makes it less efficient.

Reviewers: jmolloy, jroelofs, joerg, compnerd, rengolin

Subscribers: llvm-commits, aemerson

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

llvm-svn: 288710
2016-12-05 21:40:36 +00:00
Saleem Abdulrasool aba0edb340 build: fix building for Windows after SVN r287465
The previous change for enabling MinGW did not preserve the Win32 check and
added the EABI specific routines to a Windows build which does not use the EABI
routines.  Correct the conditional check for that.

llvm-svn: 288422
2016-12-01 22:00:54 +00:00
Saleem Abdulrasool f9d34dfbe4 builtins: switch to c11 from c99
This fixes an incorrect standard usage of GNU99 when the compiler check was for
the ISO standard C99.  Furthermore, bump the dependency up to C11.  The
motivation for this change is ARM EHABI compatibility with clang 3.8.  We rely
on a type definition redefinition which causes an error with -Werror builds.
This is problematic for FreeBSD builds.  Switching to C11 allows the
compatibility without the unnecessary pedantic warning.  The alternative would
be to clutter the support header with a `pragma clang diagnostic ignore`.  GCC
4.8+ and the supported clang revisions along with MSVC support enough of C11 to
allow building the builtins in C11 mode.  No functional change intended.

llvm-svn: 288099
2016-11-29 02:31:40 +00:00
Martin Storsjo 8c59680ac2 builtins: Allow building windows arm functions for mingw
When building with clang/LLVM in MSVC mode, the msvcrt libraries contain
these functions.

When building in a mingw environment, we need to provide them somehow,
e.g. via compiler-rt.

The aeabi divmod functions work in the same way as the corresponding
__rt_*div* functions for windows, but their parameters are swapped.
The functions for converting float to integer and vice versa are the
same as their aeabi equivalents, only with different function names.

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

llvm-svn: 287465
2016-11-19 21:22:38 +00:00
Saleem Abdulrasool 865a671fa2 builtins: repair the builtins build with clang 3.8
When the C unwinding personality was corrected to match the ARM EHABI
specification, the unwind header in clang was updated with necessary
declarations.  However, when building with an older compiler, we would not have
the necessary declarations.  This would result in a build failure.  Provide a
supplementary header to ensure that the necessary declarations are present for
the build of the C unwinding personality.

Note that this is NOT an ABI break.  It merely is a compile time failure due to
the constants not being present.  The constants here are reproduced
equivalently.  This header should permit building with clang[<3.9] as well as
gcc.

Addresses PR31035!

llvm-svn: 287359
2016-11-18 18:21:06 +00:00
Saleem Abdulrasool 2678d023ca build: give aliases the same visibility
ARM EABI also uses function aliases.  Ensure that those aliased functions are
given proper visibility annotations.

llvm-svn: 285478
2016-10-28 23:37:50 +00:00
Saleem Abdulrasool 2594717436 builtins: ensure that VISIBILITY_HIDDEN is defined properly
The CMake build system had missed this macro as part of the build of the
builtins.  This would result in the builtins exporting symbols which are
implemented in assembly with global visibility.  Ensure that the assembly
optimized routines are given the same visibility as the C routines.

llvm-svn: 285477
2016-10-28 23:19:03 +00:00
Richard Smith f8520559ce Atomics library: provide operations for __int128 when it is available.
llvm-svn: 285265
2016-10-27 01:46:24 +00:00
Renato Golin 81e8b771d7 [ARM RT] Fix broken clear_cache debug build on ARM
clear_cache is using R7 for the SVC call and that's the frame pointer in
GCC, which is only disabled on -O2/3, so Release builds finish, Debug don't.

Fixes PR30797.

llvm-svn: 285204
2016-10-26 15:20:33 +00:00
Saleem Abdulrasool 81eb5f6a60 builtins: use thumb-2 if possible on comparesf2
This code can be built with thumb-2 like many of the other builtin routines.
Enable that here as well.

llvm-svn: 282530
2016-09-27 19:12:31 +00:00
Saleem Abdulrasool d14c2c0139 builtins: make sure that flags is setup properly for __clear_cache
On Linux ARM, the syscall will take 3 arguments (start, end, flags).  Ensure
that we do not pass garbage to the flags, which can cause the cacheflush call to
fail, and therefore cause an abort at runtime.

llvm-svn: 280877
2016-09-07 22:59:54 +00:00
Chris Bieneman 90646fe815 [CMake] Add option (defaulted off) to exclude atomic.c
The atomic builtin source is problematic when cross-compiling builtins because it requires a variable and sometimes large set of system headers. This option allows users to optionally prevent it from being built.

llvm-svn: 280416
2016-09-01 21:05:49 +00:00
Chris Bieneman d470f434ab Delete remaining compiler-rt makefiles
Summary:
Since we can now build the builtins without a full toolchain these files should no longer be needed.

This is the last vestige of autoconf!

Reviewers: compnerd, iains, jroelofs

Subscribers: dberris, llvm-commits

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

llvm-svn: 279539
2016-08-23 17:32:38 +00:00
Francis Ricci f9153eb305 [builtins] Don't always use -ffreestanding when compiling builtins
This can break on some sysroots. Let the user define it if necessary.

llvm-svn: 279496
2016-08-23 00:49:03 +00:00
Francis Ricci 0f488dc215 [compiler-rt] Use flags found when configuring builtins during compilation
Summary: This fixes the omission of -fPIC when building the builtins.

Reviewers: compnerd, beanz

Subscribers: dberris, llvm-commits

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

llvm-svn: 279469
2016-08-22 20:33:47 +00:00
Chris Bieneman 86412e56fb [CMake] Renaming test variable to be consistent
Based on post-commit review by compnerd.

llvm-svn: 278728
2016-08-15 20:12:43 +00:00
Chris Bieneman 98ee3de514 [CMake] If the compiler supports _Atomic include atomic.c in builtins libraries
This fixes a long-standing TODO by implementing a compiler check for supporting the _Atomic keyword. If the _Atomic keyword is supported by the compiler we should include it in the builtin library sources.

llvm-svn: 278454
2016-08-12 01:29:26 +00:00
Saleem Abdulrasool b4022f9782 builtins: better categorisation of Thumb1 builtins
Adjust the builtins to better annotate the Thumb1 routines and their purpose.
Exclude the remaining thumb1 sources on Windows ARM.

llvm-svn: 277828
2016-08-05 16:24:56 +00:00
Saleem Abdulrasool b44444b3f1 builtins: split out the EABI and VFP ARM sources
These are meant to only be included on certain targets.  This only disables it
for Windows ARM for now.  Ideally these would be conditionally included as
appropriate.

llvm-svn: 277777
2016-08-04 21:58:39 +00:00
Jonas Hahnfeld 9b2c3ab620 [CMake] Load LLVMConfig for standalone build of builtins
Therefore move some code into reusable macros.

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

llvm-svn: 277418
2016-08-02 05:51:05 +00:00
Reid Kleckner 1bd5e3ec56 Use 'unsigned long' to match the APIs of the MS bitscan intrinsics
We were getting warnings about how 'uint32_t*' is different from
'unsigned long*' even though they are effectively the same on Windows.

llvm-svn: 277363
2016-08-01 18:39:27 +00:00
Chris Bieneman 56e3827e92 Revert "Enable cross-compilation across architectures on android"
This reverts commit r276333.

As I commented in the review (https://reviews.llvm.org/D22415), this change isn't needed because CMAKE_C_FLAGS is implicitly added by CMake to the command line for all C source files.

With this patch enabled CMAKE_C_FLAGS is duplicated on all C sources, and applied to ASM sources, which is not ideal.

I sent an email about this to llvm-commits on the commit thread. I suspect the problem the patch author was actually seeing is that CMAKE_C_FLAGS isn't applied to ASM files, and the builtins library has quite a few of those. The correct solution there is to specify CMAKE_ASM_FLAGS with whatever flags need to be passed to the compiler when compiling ASM files.

If there are other problems with flag propagation, please let me know.

llvm-svn: 276683
2016-07-25 20:25:38 +00:00
Francis Ricci 283d8df277 Enable cross-compilation across architectures on android
Summary:
This patch fixes cross-architecture compilation,
by allowing flags like -target and --sysroot to be set for
architecture testing and compilation.

Reviewers: tberghammer, srhines, danalbert, beanz, compnerd

Subscribers: tberghammer, llvm-commits, danalbert

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

llvm-svn: 276333
2016-07-21 21:05:14 +00:00
Alina Sbirlea 9b47673e3f [compiler-rt] Change all asm directives to __asm__ in cpu_model.
Summary:
Aiming to resolve failure in sanitizer bot by changning all asm directives to __asm__.
Also, consistency.

Reviewers: llvm-commits, echristo, vitalybuka

Subscribers: mehdi_amini

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

llvm-svn: 275740
2016-07-17 23:45:55 +00:00
Alina Sbirlea 36f57fbc66 Add runtime support for __cpu_model (__builtin_cpu_supports)
Summary:
    This aims to add support for __cpu_model and address Bug 25510. It uses
    the code from lib/Support/Host.cpp for cpu detection, and creates
    __cpu_model with that info.

    Tested on OSX and built on Linux as well (though libgcc is the default).
    The use of "asm" required -std=gnu99, hence the cmake change. Corrections
    on better addressing this are welcome.

    Previously reverted, up for review again to iron out outstanding issues.

Reviewers: llvm-commits, joerg, echristo, mehdi_amini

Subscribers: mehdi_amini

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

llvm-svn: 275484
2016-07-14 22:02:35 +00:00
Renato Golin 2931b21286 [RT-ARM] Syntax unified for aeabi_mem* functions
Use unified syntax for builtins/arm/aeabi_mem*.S.

This makes these files consistent with the others.

This fixes a problem on the linker, which can fail with the message
"relocation truncated to fit: R_ARM_THM_JUMP11 against symbol"

Patch by Kor Nielsen.

llvm-svn: 275264
2016-07-13 14:01:15 +00:00
Etienne Bergeron ab42f4ddba [compiler-rt] Fix VisualStudio virtual folders layout
Summary:
This patch is a refactoring of the way cmake 'targets' are grouped.
It won't affect non-UI cmake-generators.

Clang/LLVM are using a structured way to group targets which ease
navigation through Visual Studio UI. The Compiler-RT projects
differ from the way Clang/LLVM are grouping targets.

This patch doesn't contain behavior changes.

Reviewers: kubabrecka, rnk

Subscribers: wang0109, llvm-commits, kubabrecka, chrisha

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

llvm-svn: 275111
2016-07-11 21:51:56 +00:00
Alina Sbirlea 0efdda0956 Revert "Add runtime support for __cpu_model (__builtin_cpu_supports)"
This reverts commit r274873 until additional fixes are resolved.

llvm-svn: 274944
2016-07-08 22:22:43 +00:00
Alina Sbirlea 9ebebce2df Add runtime support for __cpu_model (__builtin_cpu_supports)
Summary:
This aims to add support for __cpu_model and address Bug 25510. It uses
the code from lib/Support/Host.cpp for cpu detection, and creates
__cpu_model with that info.

Tested on OSX, it builts successfully, but the current version does
*not* resolve Bug 25510. The __cpu_model symbol is present in the
library but it only gets loaded with -all_load. This patch will not land
until this issue is clarified.

Built on Linux as well (though libgcc is the default). The use of "asm"
required -std=gnu99, hence the cmake change. Corrections on better
addressing this are welcome.

Note: See additional comments on D20988 (committed as r271921).

Reviewers: llvm-commits, joerg, echristo, mehdi_amini

Subscribers: mehdi_amini

Differential revision: http://reviews.llvm.org/D21033

llvm-svn: 274873
2016-07-08 16:28:54 +00:00
Alina Sbirlea fb11f27253 Revert r274865-r274870
llvm-svn: 274872
2016-07-08 16:28:52 +00:00
Alina Sbirlea d6ce086f32 Added comments identifing code source
llvm-svn: 274870
2016-07-08 16:18:41 +00:00
Alina Sbirlea 13a4583714 Check cpuid supported for i386.
Summary:

Reviewers:

Subscribers:

llvm-svn: 274868
2016-07-08 16:18:39 +00:00
Alina Sbirlea 7847598113 Add default initialization. Add unit test.
llvm-svn: 274867
2016-07-08 16:18:38 +00:00
Alina Sbirlea 05241bfe7a clang-format it
llvm-svn: 274866
2016-07-08 16:18:36 +00:00
Alina Sbirlea b0b29c958a Add runtime support for __cpu_model (__builtin_cpu_supports)
Summary:
This aims to add support for __cpu_model and address Bug 25510. It uses the code from lib/Support/Host.cpp for cpu detection, and creates __cpu_model with that info.

Tested on OSX, it builts successfully, but the current version does *not* resolve Bug 25510. The __cpu_model symbol is present in the library but it only gets loaded with -all_load. This patch will not land until this issue is clarified.

Built on Linux as well (though libgcc is the default). The use of "asm" required -std=gnu99, hence the cmake change. Corrections on better addressing this are welcome.

Note: See additional comments on D20988 (committed as r271921).

Reviewers: llvm-commits, joerg, echristo, mehdi_amini

Subscribers: mehdi_amini

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

llvm-svn: 274865
2016-07-08 16:18:34 +00:00
Saleem Abdulrasool 590e85b575 builtins: tag with noexecstack
These routines do not require executable stacks.  However, by default ELFish
linkers may assume an executable stack on GNUish environments (and some non-GNU
ones too!).  The GNU extension to add a note to indicate a non-executable stack
is honoured by these environments to mark the stack as non-executable (the
compiler normally emits this directive on appropriate targets whenever
possible).  This allows normal builds from getting executable stacks due to
linking to the compiler rt builtins.

llvm-svn: 273500
2016-06-22 22:09:42 +00:00
Jeroen Ketema af0bbd92a2 [builtins] Make SOFT_FP versions of floatdidf and floatundidf compile
llvm-svn: 272551
2016-06-13 15:24:16 +00:00
Jeroen Ketema 0b748f220b [builtins] replace tabs by spaces and remove whitespace at end of line NFC
llvm-svn: 272550
2016-06-13 15:21:04 +00:00
Chris Bieneman 5c3112cebe [CMake] Update to requiring CMake 3.4.3
Summary:
This is as per the discussions on developer lists:

http://lists.llvm.org/pipermail/llvm-dev/2016-April/098780.html
http://lists.llvm.org/pipermail/llvm-dev/2016-May/100058.html

Subscribers: llvm-commits

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

llvm-svn: 271327
2016-05-31 20:21:42 +00:00
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