Commit Graph

77304 Commits

Author SHA1 Message Date
Clement Courbet 8c3343dfd5 [Builtins] Treat `bcmp` as a builtin.
Summary:
This makes it consistent with `memcmp` and `__builtin_bcmp`.

Also see the discussion in https://reviews.llvm.org/D56593.

Reviewers: jyknight

Subscribers: kristina, cfe-commits

Tags: #clang

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

llvm-svn: 354023
2019-02-14 12:00:34 +00:00
Nico Weber 023dd1eefa Print a note to the called macro when diagnosing err_embedded_directive
Fixes PR40713, see there for the motivation for this.

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

llvm-svn: 354009
2019-02-14 04:13:17 +00:00
Francis Visoiu Mistrih ee704c1d91 [NewPM] Add explicit triple to test
This prevents warnings like:

> warning: overriding the module target triple with x86_64-apple-darwin

on macOS.

llvm-svn: 354008
2019-02-14 04:13:00 +00:00
Yaxun Liu c18e9ecd4f [CUDA][HIP] Use device side kernel and variable names when registering them
__hipRegisterFunction and __hipRegisterVar need to accept device side kernel and variable names
so that HIP runtime can associate kernel stub functions in host code with kernel symbols in fat binaries,
and associate shadow variables in host code with device variables in fat binaries.

Currently, clang assumes kernel functions and device variables have the same name as the kernel
stub functions and shadow variables. However, when host is compiled in windows with MSVC C++
ABI and device is compiled with Itanium C++ ABI (e.g. AMDGPU), kernels and device symbols in fat
binary are mangled differently than host.

This patch gets the device side kernel and variable name by mangling them in the mangle context
of aux target.

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

llvm-svn: 354004
2019-02-14 02:00:09 +00:00
Douglas Yung 607a1b2234 Relax restriction in tests to where "-emit-llvm-bc" and "-emit-obj" must appear.
The CHECK lines as structured were requiring them to appear only in a certain
position while all that is really needed is to check that they are present.

llvm-svn: 354001
2019-02-14 01:11:32 +00:00
Leonard Chan 619b6d5378 Fix for asan bots
llvm-svn: 353999
2019-02-14 01:07:47 +00:00
Mitch Phillips b5fe6fdbc4 [HWASAN] Updated HWASAN design document to better portray the chance of missing a bug.
Summary: Provided rule of thumb percentage chances of miss for 4 and 8 bit tag sizes.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 353990
2019-02-13 23:14:54 +00:00
Leonard Chan 436fb2bd82 [NewPM] Second attempt at porting ASan
This is the second attempt to port ASan to new PM after D52739. This takes the
initialization requried by ASan from the Module by moving it into a separate
class with it's own analysis that the new PM ASan can use.

Changes:
- Split AddressSanitizer into 2 passes: 1 for the instrumentation on the
  function, and 1 for the pass itself which creates an instance of the first
  during it's run. The same is done for AddressSanitizerModule.
- Add new PM AddressSanitizer and AddressSanitizerModule.
- Add legacy and new PM analyses for reading data needed to initialize ASan with.
- Removed DominatorTree dependency from ASan since it was unused.
- Move GlobalsMetadata and ShadowMapping out of anonymous namespace since the
  new PM analysis holds these 2 classes and will need to expose them.

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

llvm-svn: 353985
2019-02-13 22:22:48 +00:00
Robert Widmann 04306d62a0 Restore Check for Unreachable Exit Block in -Winfinite-recursion
Summary:
When this was rewritten in D43737, the logic changed to better explore infinite loops. The check for a reachable exit block was deleted which accidentally introduced false positives in case the exit node was unreachable.

We were testing for cases like this, but @steven_wu provided an additional test case that I've included in the regression tests for this patch.

Reviewers: steven_wu, rtrieu

Reviewed By: steven_wu, rtrieu

Subscribers: cfe-commits, steven_wu

Tags: #clang

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

llvm-svn: 353984
2019-02-13 22:22:23 +00:00
Thomas Lively de7a0a1526 [WebAssembly] Bulk memory intrinsics and builtins
Summary:
implements llvm intrinsics and clang intrinsics for
memory.init and data.drop.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits

Tags: #clang

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

llvm-svn: 353983
2019-02-13 22:11:16 +00:00
Erik Pilkington 81d3f45137 [Sema] Delay checking whether objc_designated_initializer is being applied to an init method
This fixes a regression that was caused by r335084, which reversed
the order that attributes are applied. objc_method_family can change
whether a method is an init method, so the order that these
attributes are applied matters. The commit fixes this by delaying the
init check until after all attributes have been applied.

rdar://47829358

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

llvm-svn: 353976
2019-02-13 20:32:37 +00:00
Hubert Tong 45195c873b [PowerPC] Stop defining _ARCH_PWR6X on POWER7 and up
Summary:
The predefined macro `_ARCH_PWR6X` is associated with GCC's
`-mcpu=power6x` option, which enables generation of P6 "raw mode"
instructions such as `mftgpr`.

Later POWER processors build upon the "architected mode", not the raw
one. `_ARCH_PWR6X` should not be defined for these later processors.

Fixes PR#40236.

Reviewers: echristo, hfinkel, kbarton, nemanjai, wschmidt

Reviewed By: hfinkel

Subscribers: jsji, cfe-commits

Tags: #clang

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

llvm-svn: 353975
2019-02-13 20:17:13 +00:00
Louis Dionne defa9f8f85 [clang] Make sure C99/C11 features in <float.h> are provided in C++11
Summary:
Previously, those #defines were only provided in C or when GNU extensions were
enabled. We need those #defines in C++11 and above, too.

Reviewers: jfb, eli.friedman

Subscribers: jkorous, dexonsmith, cfe-commits

Tags: #clang

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

llvm-svn: 353970
2019-02-13 19:08:01 +00:00
Nico Weber acf81a7c14 Re-enable the test disabled in r353836 and hopefully make it pass in gcc builds
Argument evaluation order is different between gcc and clang, so pull out
the Builder calls to make the generated IR independent of the host compiler's
argument evaluation order.  Thanks to rnk for reminding me of this clang/gcc
difference.

llvm-svn: 353969
2019-02-13 19:04:26 +00:00
Simon Atanasyan 4c22a57414 [Headers][mips] Add `__attribute__((__mode__(__unwind_word__)))` to the _Unwind_Word / _Unwind_SWord definitions
The rationale of this change is to fix _Unwind_Word / _Unwind_SWord
definitions for MIPS N32 ABI. This ABI uses 32-bit pointers,
but _Unwind_Word and _Unwind_SWord types are eight bytes long.

 # The __attribute__((__mode__(__unwind_word__))) is added to the type
   definitions. It makes them equal to the corresponding definitions used
   by GCC and allows to override types using `getUnwindWordWidth` function.
 # The `getUnwindWordWidth` virtual function override in the `MipsTargetInfo`
   class and provides correct type size values.

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

llvm-svn: 353965
2019-02-13 18:27:09 +00:00
Petr Hosek 7a290dfe30 [Driver] Pass +reserve-x25 to backend if -ffixed-x25 is specified
This was accidentally omitted in r353957 breaking the Clang test.

llvm-svn: 353960
2019-02-13 18:01:23 +00:00
Petr Hosek fcbec02ea6 [AArch64] Support reserving arbitrary general purpose registers
This is a follow up to D48580 and D48581 which allows reserving
arbitrary general purpose registers with the exception of registers
with special purpose (X8, X16-X18, X29, X30) and registers used by LLVM
(X0, X19). This change also generalizes some of the existing logic to
rely entirely on values generated from tablegen.

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

llvm-svn: 353957
2019-02-13 17:28:47 +00:00
Aaron Enye Shi 7084b56ee2 [HIP] Handle compile -m options and propagate into LLC
Allow the compile options for -m such as -mxnack/-mno-xnack, -msram-ecc/-mno-sram-ecc, -mcode-object-v3/-mno-code-object-v3 to propagate into LLC args. Fix an issue where -mattr was pushed even when it was empty.

Also add lit tests to verify features are properly passed.

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

Reviewers: yaxunl, kzhuravl
llvm-svn: 353952
2019-02-13 16:12:16 +00:00
Martin Storsjo f81f7f3ef6 [test] Tweak driver test from r353917 and r353922 to pass with a nondefault CLANG_DEFAULT_LINKER
Force -fuse-ld=ld, as some other tests in the same file do.

Loosen the regex matching the linker tool name as well, as this
can end up being <triple>-ld in case such a named tool exists.

llvm-svn: 353946
2019-02-13 13:13:45 +00:00
Adam Balogh 3bd63ae381 [Analyzer] Crash fix for FindLastStoreBRVisitor
FindLastStoreBRVisitor tries to find the first node in the exploded graph where
the current value was assigned to a region. This node is called the "store
site". It is identified by a pair of Pred and Succ nodes where Succ already has
the binding for the value while Pred does not have it. However the visitor
mistakenly identifies a node pair as the store site where the value is a
`LazyCompoundVal` and `Pred` does not have a store yet but `Succ` has it. In
this case the `LazyCompoundVal` is different in the `Pred` node because it also
contains the store which is different in the two nodes. This error may lead to
crashes (a declaration is cast to a parameter declaration without check) or
misleading bug path notes.

In this patch we fix this problem by checking for unequal `LazyCompoundVals`: if
their region is equal, and their store is the same as the store of their nodes
we consider them as equal when looking for the "store site". This is an
approximation because we do not check for differences of the subvalues
(structure members or array elements) in the stores.

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

llvm-svn: 353943
2019-02-13 12:25:47 +00:00
Stephan Bergmann 84dcc8f36f Look through typedefs in getFunctionTypeWithExceptionSpec
Fixes https://bugs.llvm.org/show_bug.cgi?id=40658

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

llvm-svn: 353931
2019-02-13 09:39:17 +00:00
Martin Storsjo 84c0db859f [test] Fix the test from SVN r353917 when running without lld available
These tests still relies on the default linker not to be overridden
via e.g. CLANG_DEFAULT_LINKER in cmake.

llvm-svn: 353922
2019-02-13 07:50:21 +00:00
Martin Storsjo 73ec0034d0 [MinGW] Add the profiling library when necessary
Profiling still doesn't seem to work properly, but this at least
hooks up the library and eases completing whatever is missing.

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

llvm-svn: 353917
2019-02-13 07:26:54 +00:00
Reid Kleckner 29fc59edf1 Revert r353880 "[HIP] Handle compile -m options and propagate into LLC"
This was still causing test failures in the clang test suite.

llvm-svn: 353893
2019-02-12 22:51:54 +00:00
Peter Collingbourne 27aa8b62d3 docs: Update the ShadowCallStack documentation.
- Remove most of the discussion of the x86_64 implementation;
  link to an older version of the documentation for details of
  that implementation.
- Add description of the compatibility and security issues discovered
  during the development of the aarch64 implementation for Android.

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

llvm-svn: 353890
2019-02-12 22:45:23 +00:00
Craig Topper 16a0fba741 [X86] Follow up to r353878, add MSVC compatibility command lines to other intrinsic tests that uses packed structs to control alignment.
r353878 fixed a bug in _mm_loadu_ps and added a command line to catch it. Adding additional command lines to prevent breaking other intrinsics in the future.

llvm-svn: 353887
2019-02-12 22:12:19 +00:00
Aaron Enye Shi a1adb80ae7 [HIP] Fix hip-toolchain-rdc tests
Since we removed changed the way HIP Toolchain will propagate -m options into LLC, we need to remove from these older tests.

This is related to rC353880.

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

llvm-svn: 353885
2019-02-12 22:01:19 +00:00
Jonas Devlieghere 75b44d75f6 Make ModuleDependencyCollector's method virtual (NFC)
For reproducers in LLDB we want to hook up into the existing clang
infrastructure. To make that happen we need to be able to override the
ModuleDependencyCollector's methods.

The alternative was to inherit from the DependencyCollector directly,
but that would mean re-implementing the ModuleDependencyListener and the
ModuleDependencyPPCallbacks and ModuleDependencyMMCallbacks.

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

llvm-svn: 353882
2019-02-12 21:45:14 +00:00
Aaron Enye Shi 41bbc6e04c [HIP] Handle compile -m options and propagate into LLC
Allow the compile options for -m such as -mxnack/-mno-xnack, -msram-ecc/-mno-sram-ecc, -mcode-object-v3/-mno-code-object-v3 to propagate into LLC args.

Also add lit tests to verify features are properly passed.

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

Reviewers: yaxunl, kzhuravl
llvm-svn: 353880
2019-02-12 21:21:06 +00:00
Reid Kleckner 79d7f4114d [X86] Use __m128_u for _mm_loadu_ps after r353555
Add secondary triple to existing SSE test for it.  I audited other uses
of __attribute__((__packed__)) in the intrinsic headers, and this seemed
to be the only missing one.

llvm-svn: 353878
2019-02-12 21:04:21 +00:00
Anton Korobeynikov a39eb26bd3 Disable PIC/PIE for MSP430 target
Relocatable code generation is meaningless on MSP430, as the platform is too small to use shared libraries.

Patch by Dmitry Mikushev!

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

llvm-svn: 353877
2019-02-12 20:46:00 +00:00
JF Bastien 09197775c5 [NFC] typo
llvm-svn: 353875
2019-02-12 20:19:16 +00:00
Scott Linder 80a1ee46d8 [AMDGPU] Require at least protected visibility for certain symbols
This allows the global visibility controls to be restrictive while still
populating the dynamic symbol table where required.

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

llvm-svn: 353870
2019-02-12 18:30:38 +00:00
Petr Hosek f9fe483eb5 [CMake][Fuchsia] Pass -ldl -lpthread LDFLAGS to second stage
We're using static libc++ for the second stage which requires explicitly
linking -ldl and -lpthread.

llvm-svn: 353853
2019-02-12 16:24:46 +00:00
Ilya Biryukov 6597fdd508 [Sema] Fix a crash in access checking for deduction guides
Summary: See the added test for a repro.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 353840
2019-02-12 14:21:44 +00:00
Aaron Ballman ce667f6df9 Renaming yet another diagnostic to not conflict; NFC.
llvm-svn: 353839
2019-02-12 13:19:02 +00:00
Aaron Ballman 76126c01b0 Renaming this diagnostic to not conflict with another; NFC.
Amends r353837 which renamed the diagnostics to conflict.

llvm-svn: 353838
2019-02-12 13:13:35 +00:00
Aaron Ballman 52c9ad2001 Fixing a typo; NFC.
llvm-svn: 353837
2019-02-12 13:04:11 +00:00
Nico Weber 7f17bcdb5b Disable test after r353718, r353725, r353729 while I investigate
llvm-svn: 353836
2019-02-12 12:40:56 +00:00
Craig Topper 4390c721cb [X86] Use the new unaligned vector typedefs for the loadu/storeu intrinsics pointer arguments.
This matches what gcc does and what was suggested by rnk in PR20670.

llvm-svn: 353802
2019-02-12 07:44:40 +00:00
Douglas Yung cfc512ab44 Fix VS2015 build problem introduced by r353370.
llvm-svn: 353791
2019-02-12 02:17:51 +00:00
Erik Pilkington e3cd735ea6 Add a new attribute, fortify_stdlib
This attribute applies to declarations of C stdlib functions
(sprintf, memcpy...) that have known fortified variants
(__sprintf_chk, __memcpy_chk, ...). When applied, clang will emit
calls to the fortified variant functions instead of calls to the
defaults.

In GCC, this is done by adding gnu_inline-style wrapper functions,
but that doesn't work for us for variadic functions because we don't
support __builtin_va_arg_pack (and have no intention to).

This attribute takes two arguments, the first is 'type' argument
passed through to __builtin_object_size, and the second is a flag
argument that gets passed through to the variadic checking variants.

rdar://47905754

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

llvm-svn: 353765
2019-02-11 23:21:39 +00:00
Eli Friedman 88fccbdea7 [Sema] Mark GNU compound literal array init as an rvalue.
Basically the same issue as string init, except it didn't really have
any visible consequences before I removed the implicit lvalue-to-rvalue
conversion from CodeGen.

While I'm here, a couple minor drive-by cleanups: IgnoreParens never
returns a ConstantExpr, and there was a potential crash with string init
involving a ChooseExpr.

The analyzer test change maybe indicates we could simplify the analyzer
code a little with this fix?  Apparently a hack was added to support
lvalues in initializers in r315750, but I'm not really familiar with the
relevant code.

Fixes regression reported in the kernel build at
https://bugs.llvm.org/show_bug.cgi?id=40430#c6 .

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

llvm-svn: 353762
2019-02-11 22:54:27 +00:00
Heejin Ahn 9d5a089bf5 [WebAssembly] Make thread-related options consistent
Summary:
There have been three options related to threads and users had to set
all three of them separately to get the correct compilation results.
This makes sure the relationship between the options makes sense and
sets necessary options for users if only part of the necessary options
are specified. This does:

- Remove `-matomics`; this option alone does not enable anything, so
  removed it to not confuse users.
- `-mthread-model posix` sets `-target-feature +atomics`
- `-pthread` sets both `-target-feature +atomics` and
  `-mthread-model posix`
Also errors out when explicitly given options don't match, such as
`-pthread` is given with `-mthread-model single`.

Reviewers: dschuff, sbc100, tlively, sunfish

Subscribers: jgravelle-google, jfb, cfe-commits

Tags: #clang

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

llvm-svn: 353761
2019-02-11 22:47:50 +00:00
Nico Weber 346f1e97a9 Fix a few tests that were missing ':' on CHECK lines and weren't testing anything.
Found by `git grep '\/\/ CHECK-[^: ]* ' clang/test/ | grep -v RUN:`.

Also tweak CodeGenCXX/arm-swiftcall.cpp to still pass now that it checks more.

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

llvm-svn: 353744
2019-02-11 20:33:22 +00:00
Petr Hosek 7c8952197b [CodeGen] Set construction vtable visibility after creating initializer
We must only set the construction vtable visibility after we create the
vtable initializer, otherwise the global value will be treated as
declaration rather than definition and the visibility won't be set.

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

llvm-svn: 353742
2019-02-11 20:13:42 +00:00
Tom Tan 42b2424e4f [COFF, ARM64] Remove definitions for _byteswap library functions
_byteswap_* functions are are implemented in below file as normal function
from libucrt.lib and declared in stdlib.h. Define them in intrin.h triggers
lld error "conflicting comdat type" and "duplicate symbols" which was just
added to LLD (https://reviews.llvm.org/D57324).

C:\Program Files (x86)\Windows Kits\10\Source\10.0.17763.0\ucrt\stdlib\byteswap.cpp

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

llvm-svn: 353740
2019-02-11 20:04:02 +00:00
Nico Weber 2e12dce406 Attempt to pacify bots more after r353718 and r353725
llvm-svn: 353729
2019-02-11 18:01:27 +00:00
Nico Weber d7cc3b3908 Attempt to pacify bots after r353718
llvm-svn: 353725
2019-02-11 17:30:25 +00:00
Nico Weber 9bbb721eb2 Make test actually test something (colons were missing)
llvm-svn: 353718
2019-02-11 16:37:02 +00:00