1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

145 Commits

Author SHA1 Message Date
Mark Lacey
6bac742f98 Add an LLVM_BUILTIN_DEBUGTRAP macro.
Summary:
This provides a macro that expands to __builtin_debugtrap() for clang,
and __debugbreak() for MSVC.

It intentionally expands to nothing for compilers that do not support a
similar mechanism that halts the debugger without otherwise crashing the
process.

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

llvm-svn: 263095
2016-03-10 05:15:03 +00:00
Justin Bogner
6b5f8cc6e0 Annotate our undefined behaviour to sneak it past the sanitizers
We have known UB in some ilists where we static cast half nodes to
(larger) derived types and use the address. See llvm.org/PR26753.

This needs to be fixed, but in the meantime it'd be nice if running
ubsan didn't complain. This adds annotations in the two places where
ubsan complains while running check-all of a sanitized clang build.

llvm-svn: 262683
2016-03-04 01:52:47 +00:00
Reid Kleckner
637b37f5e7 Enable constexpr on Visual Studio 2015, add support for two equivalent attributes
Patch by Alexander Riccio

This patch enables `constexpr` on Visual Studio 2015 by adding `||
LLVM_MSC_PREREQ(1900)` to the preprocessor `#if` statement. Since VS2013
doesn't support `constexpr`, that's purposely excluded. The
`LLVM_CONSTEXPR` macro is used in ~25 places.

I also added the MSVC/SAL equivalent of:

  - `__attribute__((__warn_unused_result__))` as an
    `LLVM_ATTRIBUTE_UNUSED_RESULT` definition

  - `__attribute__((returns_nonnull))` as an
    `LLVM_ATTRIBUTE_RETURNS_NONNULL` definition

...in case anybody ever decides to run `/analyze` on LLVM (probably
myself, if anybody)

Reviewers: rnk, aaron.ballman

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

llvm-svn: 260410
2016-02-10 19:07:47 +00:00
Justin Bogner
8b4ea7a451 Support: Teach Asan about BumpPtrAllocator
Based on patch by Pete Cooper.

llvm-svn: 254964
2015-12-07 23:12:26 +00:00
Xinliang David Li
3c4afd7651 Define portable macros for packed struct definitions:
1. A macro with argument: LLVM_PACKED(StructDefinition)
 2. A pair of macros defining scope of region with packing:
    LLVM_PACKED_START
     struct A { ... };
     struct B { ... };
    LLVM_PACKED_END

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

llvm-svn: 252099
2015-11-04 23:42:56 +00:00
Chandler Carruth
57fe727884 [Support] Fix the always_inline attribute macro to not include the
'inline' specifier. That specifier may or may not be valid for a given
function, or it may be required for correct linkage even when the
compiler doesn't support the always_inline attribute.

llvm-svn: 247252
2015-09-10 08:29:30 +00:00
Naomi Musgrave
45af381ae7 Rollback of commit "Repress sanitization on User dtor."
This would have suppressed bug 24578, about use-after-
destroy on User and MDNode. Rolled back suppression for
the sake of code cleanliness, in preferance for bug
tracking to keep track of this issue.

This reverts commit 6ff2baabc4625d5b0a8dccf76aa0f72d930ea6c0.

llvm-svn: 246484
2015-08-31 21:06:08 +00:00
Naomi Musgrave
12250f420e Undo reversion on commit: Revert "Revert "Repress sanitization on User dtor.
Modify msan macros for applying attribute""

This reverts commit 020e70a79878c96457e6882bcdfaf6628baf32b7.

llvm-svn: 246470
2015-08-31 18:49:31 +00:00
Naomi Musgrave
2a31db0a58 Revert "Repress sanitization on User dtor. Modify msan macros for applying attribute"
This reverts commit 5e3bfbb38eb3fb6f568b107f6b239e0aa4c5f334.

llvm-svn: 246450
2015-08-31 16:26:44 +00:00
Naomi Musgrave
26d47cc0d1 Repress sanitization on User dtor. Modify msan macros for applying attribute
to repress sanitization. Move attribute for repressing sanitization to
operator delete for User, MDNode.

Summary: In response to bug 24578, reported against failing LLVM test.

Reviewers: chandlerc, rsmith, eugenis

Subscribers: llvm-commits

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

llvm-svn: 246449
2015-08-31 15:57:40 +00:00
Peter Collingbourne
3ec59b51d4 Support: Clean up TSan annotations.
Remove support for Valgrind-based TSan, which hasn't been maintained for a
few years. We now use the TSan annotations only if LLVM is compiled with
-fsanitize=thread. We no longer need the weak function definitions as we
are guaranteed that our program is linked directly with the TSan runtime.

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

llvm-svn: 245374
2015-08-18 22:31:24 +00:00
David Blaikie
49042becff -Wdeprecated-clean: Remove uses of throw() in favor of noexcept
llvm-svn: 244115
2015-08-05 20:38:57 +00:00
Benjamin Kramer
0a8350b8d8 Remove macro guards for extern template instantiations.
This is a C++11 feature that both GCC and MSVC have supported as ane extension
long before C++11 was approved.

llvm-svn: 242042
2015-07-13 17:21:31 +00:00
Rafael Espindola
dc9a8f0f58 Simplify now that we always use an alignment of 2 for ELF files.
This saves 123144 bytes out of llvm-nm on powerpc64le.

llvm-svn: 238824
2015-06-02 12:05:27 +00:00
Peter Collingbourne
dda6a07fcf Revert r237766, "Support: Introduce LLVM_FALLTHROUGH macro."
The value of this macro seems to be very low unless we actually start
using it everywhere, and I don't have immediate plans to make that
happen.

llvm-svn: 237941
2015-05-21 19:44:44 +00:00
Peter Collingbourne
b32832c222 Support: Introduce LLVM_FALLTHROUGH macro.
llvm-svn: 237766
2015-05-20 02:44:14 +00:00
Richard Smith
8121317c88 Fix some minor abuse of C++ terminology in comments.
llvm-svn: 234265
2015-04-07 00:14:27 +00:00
Benjamin Kramer
8d06ccc89f Mark BumpPtrAllocator::Allocate as returning a noalias pointer.
The GCC attribute is curiously named 'malloc', but I think it's better
to use LLVM terminology for the wrapper macro.

llvm-svn: 234121
2015-04-05 17:02:25 +00:00
Reid Kleckner
53dc058e4d Add an LLVM_PTR_SIZE macro to make LLVM_ALIGNAS more useful
MSVC 2013 requires the argument to __declspec(align()) to be an integer
constant expression that doesn't involve any identifiers like sizeof.

For GCC and Clang, LLVM_PTR_SIZE is equivalent to __SIZEOF_POINTER__,
which dates back to GCC 4.6 and Clang 2010. If that's not available, we
get sizeof(void*), which works with alignas() and
__attribute__((aligned())).

For MSVC, LLVM_PTR_SIZE is 4 or 8 depending on _WIN64.

llvm-svn: 233929
2015-04-02 17:43:35 +00:00
Benjamin Kramer
6923c15ed3 [support] Add a macro wrapper for alignas and simplify some code.
We wrap __attribute((aligned)) for GCC 4.7 and __declspec(align) for
MSVC. The latter behaves weird in some contexts so this should be used
carefully.

llvm-svn: 233910
2015-04-02 11:32:48 +00:00
Aaron Ballman
cda3605b43 I believe we no longer require LLVM_HAS_INITIALIZER_LISTS; it's supported in MSVC 2013 and GCC. Added a trivial test to ensure the ArrayRef initializer list constructor is called and behaves as expected.
If any of the bots complain (perhaps due to an antiquated version of an STL implementation), I will revert.

llvm-svn: 229502
2015-02-17 15:37:53 +00:00
Aaron Ballman
0b45511a2e Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition.
llvm-svn: 229340
2015-02-15 22:54:22 +00:00
Aaron Ballman
0e19b5d670 Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition.
llvm-svn: 229335
2015-02-15 22:00:20 +00:00
Aaron Ballman
f48307f858 Since MSVC 1800 is our lowest common denominator, we don't need an explicit check for it in these macros any longer; NFC.
llvm-svn: 229333
2015-02-15 21:21:52 +00:00
Benjamin Kramer
c1b3bb4e32 Remove LLVM_HAS_VARIADIC_TEMPLATES and all the faux variadic workarounds guarded by it.
We no longer support compilers without variadic template support.

llvm-svn: 229324
2015-02-15 19:34:28 +00:00
Benjamin Kramer
4579422ac9 Update the docs to require at least MSVC 2013.
llvm-svn: 229323
2015-02-15 19:34:17 +00:00
Aaron Ballman
e5024a035a Now use the __debugbreak intrinsic instead of calling RaiseException; it requires no forward declares and still calls VEH.
llvm-svn: 228745
2015-02-10 21:13:04 +00:00
Aaron Ballman
39da612547 Changing the status code generated by LLVM_BUILTIN_TRAP on Windows to be something categorized as a valid error code. Fixes crashing uses (such as not --crash) with existing sys::Wait behavior.
llvm-svn: 228738
2015-02-10 20:13:52 +00:00
Aaron Ballman
a7a249093b Re-committing r228628 with a fix for 64-bit builds.
On Windows, we now use RaiseException to generate the kind of trap we require (one which calls our vectored exception handler), and fall back to using a volatile write to simulate a trap elsewhere.

llvm-svn: 228691
2015-02-10 14:28:11 +00:00
Aaron Ballman
da25678483 Reverting r228628; it broke at least one builder due to the forward declare of RaiseException.
llvm-svn: 228633
2015-02-10 00:00:54 +00:00
Aaron Ballman
230da450ab On Windows, we now use RaiseException to generate the kind of trap we require (one which calls our vectored exception handler), and fall back to using a volatile write to simulate a trap elsewhere.
llvm-svn: 228628
2015-02-09 23:11:39 +00:00
Chandler Carruth
567b79d945 [LPM] Remove a PPC64 hack to try to work around a bad interaction
between the linker's TLS optimizations and Clang's TLS code generation.

For now, Clang has been changed to disable linker TLS optimizations
until it (and LLVM more generally) are emitting TLS code sequences
compatible with the old bugs found in the linkers. That's a better fix
to handle bootstrapping on that platform.

llvm-svn: 227511
2015-01-29 23:26:37 +00:00
Chandler Carruth
ecec8c1eca [LPM] Try again to appease powerpc64 in its self host. I've been unable
to get a powerpc64 host so that I can reproduce and test this, but it
only impacts that platform so trying the only other realistic option.

According to Ulrich, who debugged this initially, initial-exec is likely
to be sufficient for our needs and not subject to this bug. Will watch
the build bots to see.

If this doesn't work, I'll be forced to cut a really ugly pthread-based
approach into the primary user (our stack trace printing) as that user
cannot use the ThreadLocal implementation due to lifetime issues.

llvm-svn: 227414
2015-01-29 02:34:17 +00:00
Chandler Carruth
e55b294fc7 [LPM] Fix an "obvious" typo from r227411. Really sorry for the noise.
Too many cases to compile everything quickly.

llvm-svn: 227412
2015-01-29 01:29:22 +00:00
Chandler Carruth
1916aacfbc [LPM] Clean up the use of TLS in pretty stack trace and disable it
entirely when threads are not enabled. This should allow anyone who
needs to bootstrap or cope with a host loader without TLS support to
limp along without threading support.

There is still some bug in the PPC TLS stuff that is not worked around.
I'm getting access to a machine to reproduce and debug this further.
There is some chance that I'll have to add a terrible workaround for
PPC.

There is also some problem with iOS, but I have no ability to really
evaluate what the issue is there. I'm leaving it to folks maintaining
that platform to suggest a path forward -- personally I don't see any
useful path forward that supports threading in LLVM but does so without
support for *very basic* TLS. Note that we don't need more than some
pointers, and we don't need constructors, destructors, or any of the
other fanciness which remains widely unimplemented.

llvm-svn: 227411
2015-01-29 01:23:04 +00:00
Justin Bogner
624af54ac3 Fix an inaccurate comment
llvm-svn: 222267
2014-11-18 22:17:30 +00:00
Reid Kleckner
e9ef7cfca3 Remove the END_WITH_NULL macro now that Clang doesn't use it
llvm-svn: 221218
2014-11-04 01:15:53 +00:00
Reid Kleckner
eae2fd67f3 Rename END_WITH_NULL to LLVM_END_WITH_NULL and move to Compiler.h
We shouldn't put this kind of attribute stuff in DataTypes.h.

Leave the END_WITH_NULL name for now so I can update clang without
making build spam.

llvm-svn: 221215
2014-11-04 01:12:21 +00:00
Reid Kleckner
6cad3ec813 Relax the LLVM_NOEXCEPT _MSC_VER version check back to 1900
Unconditional noexcept support was added in the VS 2013 Nov CTP. Given
that there have been three CTPs since then, I don't think we need
careful macro magic to target that specific tech preview. Instead,
target the major release version number of 1900, which corresponds to
the as-yet unreleased VS "14".

llvm-svn: 221169
2014-11-03 18:22:42 +00:00
Reid Kleckner
f1904c8960 Define LLVM_NOEXCEPT with MSVC 14 CTP 3 or newer
We have to use _MSC_FULL_VER here as CTP 2 and earlier didn't define
noexcept to my knowledge.

Fixes build error in lib/Support/Error.cpp when inheriting from
std::error_category, which has a noexcept virtual method.

llvm-svn: 221013
2014-10-31 23:02:40 +00:00
Reid Kleckner
e6f7feb7c7 GCC has supported C++11 ref-qualifiers since 4.8.1
This requires incorporating __GNUC_PATCHLEVEL__ into our prerequisite
check, and renaming our __GNUC_PREREQ to LLVM_GNUC_PREREQ, since it is
now functionally different.

Patch by Chilledheart!

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

llvm-svn: 220332
2014-10-21 21:15:45 +00:00
Hal Finkel
135a25bcb9 Enable use of __builtin_assume_aligned when self-hosting
Clang/LLVM trunk now have support for __builtin_assume_aligned, turn this &&
into an || so we can use it ourselves.

llvm-svn: 217545
2014-09-10 21:06:11 +00:00
Hans Wennborg
eeb27ba170 Use returns_nonnull in BumpPtrAllocator and MallocAllocator to avoid null-check in placement new
In both Clang and LLVM, this is a common pattern:

  Size = sizeof(DeclRefExpr) + SomeExtraStuff;
  void *Mem = Context.Allocate(Size, llvm::alignOf<DeclRefExpr>());
  return new (Mem) DeclRefExpr(...);

The annoying thing is that because the default placement-new operator has a
nothrow specification, the compiler will insert a null check of Mem before
calling the DeclRefExpr constructor. This null check is redundant for us,
because we expect the allocation functions to never return null.

By annotating the allocator functions with returns_nonnull, we can optimize
away these checks. Compiling clang with a recent version of Clang and measuring
with:

  $ perf stat -r20 bin/clang.patch -fsyntax-only -w gcc.c && perf stat -r20 bin/clang.orig -fsyntax-only -w gcc.c

Shows a 2.4% speed-up (+- 0.8%).

The pattern occurs in LLVM too. Measuring with -O3 (and now using bzip2.c
instead, because it's smaller):

  $ perf stat -r20 bin/clang.patch -O3 -w bzip2.c  &&  perf stat -r20 bin/clang.orig -O3 -w bzip2.c

Shows 4.4 % speed-up (+- 1%).

If anyone knows of a similar attribute we can use for MSVC, or some other
technique to get rid off the null check there, please let me know.

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

llvm-svn: 216192
2014-08-21 17:10:00 +00:00
Rafael Espindola
dc71be26e6 Add a LLVM_NOEXCEPT to Compiler.h.
This will be needed for the switch to std::error_code.

llvm-svn: 210581
2014-06-10 20:45:52 +00:00
Rui Ueyama
14c2e0979f Revert "[C++11] Do not check __GXX_EXPERIMENTAL_CXX0X__."
This reverts commit r204964 because it disabled "= delete", "constexpr"
and "explicit" on GCC.

llvm-svn: 204973
2014-03-27 22:36:06 +00:00
Rui Ueyama
97380631c6 [C++11] Do not check __GXX_EXPERIMENTAL_CXX0X__.
Summary: Checking the experimental flag for C++0x is no longer needed.

Differential Revision: http://llvm-reviews.chandlerc.com/D3206

llvm-svn: 204964
2014-03-27 21:56:29 +00:00
Chandler Carruth
6e284b6c8f [C++11] Replace LLVM_STATIC_ASSERT with static_assert, we now have
access to it on all host toolchains.

llvm-svn: 202642
2014-03-02 13:10:45 +00:00
Chandler Carruth
d74da4b3ff [C++11] Clarify in the Compiler.h support macros and comments (and
assert it with an #error) that we require MSVC 2012; MSVC 2010 will no
longer suffice.

llvm-svn: 202631
2014-03-02 10:07:45 +00:00
Craig Topper
a41ab31928 [C++11] Remove LLVM_FINAL and LLVM_OVERRIDE macros now that all their uses are gone.
llvm-svn: 202629
2014-03-02 09:54:13 +00:00
Craig Topper
4d40f8d303 Add back LLVM_FINAL macro. lld still needs it.
llvm-svn: 202619
2014-03-02 08:34:05 +00:00