Commit Graph

1634 Commits

Author SHA1 Message Date
David Majnemer c371ff048d MS ABI: Implement driver-level support for thread-safe statics
Decide whether or not to use thread-safe statics depending on whether or
not we have an explicit request from the driver.  If we don't have an
explicit request, infer which behavior to use depending on the
compatibility version we are targeting.

N.B. CodeGen support is still ongoing.

llvm-svn: 232906
2015-03-22 08:39:22 +00:00
Filipe Cabecinhas c473255110 Only add -fno-rtti if KernelOrKext or in C++ mode.
llvm-svn: 232869
2015-03-20 23:51:15 +00:00
Filipe Cabecinhas 3e707d98ee Don't claim exception related arguments when looking at RTTIMode
Summary:
We were claiming the -f*exceptions arguments when looking for the
RTTIMode. This makes us not warn about unused arguments if compiling a C
file with -fcxx-exceptions.

This patch fixes it by not claiming the exception-related arguments at
that point.

Reviewers: rsmith, samsonov

Subscribers: cfe-commits

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

llvm-svn: 232860
2015-03-20 23:33:23 +00:00
Alexey Samsonov ecf380ef3b [UBSan] Don't allow to use UBSan with anything except for ASan.
We are not able to make a reliable solution for using UBSan together
with other sanitizers with runtime support (and sanitizer_common).
Instead, we want to follow the path used for LSan: have a "standalone"
UBSan tool, and plug-in UBSan that would be explicitly embedded into
specific sanitizers (in short term, it will be only ASan).

llvm-svn: 232829
2015-03-20 18:45:06 +00:00
Kostya Serebryany 6fe5fcbcbc Allow -fsanitize-coverage with -fsanitize=dataflow
Summary: Allow -fsanitize-coverage with -fsanitize=dataflow

Test Plan: check-clang

Reviewers: pcc

Reviewed By: pcc

Subscribers: cfe-commits

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

llvm-svn: 232787
2015-03-20 00:06:52 +00:00
Artem Belevich 83a6dcc470 Ensure that we still parse preprocessed CUDA files as CUDA when we use
-save-temps option.

Summary: Fixes PR22926.

Review: http://reviews.llvm.org/D8383
llvm-svn: 232737
2015-03-19 17:32:06 +00:00
Manuel Klimek c68aa16d46 Add option to switch off putting header modules into the dependency file.
llvm-svn: 232721
2015-03-19 12:00:22 +00:00
Michael Zolotukhin d0cf6c852a Imply linker arguments from '-fveclib' option.
Summary: As discussed in D8097, we should provide corresponding linking flags when 'fveclib' is specified.

Reviewers: hfinkel

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

llvm-svn: 232556
2015-03-17 22:13:05 +00:00
Michael Zolotukhin c888dd0cb8 Add fveclib option.
Review: http://reviews.llvm.org/D8097
llvm-svn: 232533
2015-03-17 20:03:11 +00:00
Renato Golin e11531f7ea [ARM] Add support for ARMV6K subtarget (Clang)
ARMv6K is another layer between ARMV6 and ARMV6T2. This is the Clang
side of the changes.

ARMV6 family LLVM implementation.

+-------------------------------------+
| ARMV6                               |
+----------------+--------------------+
| ARMV6M (thumb) | ARMV6K (arm,thumb) | <- From ARMV6K and ARMV6M processors
+----------------+--------------------+    have support for hint instructions
| ARMV6T2 (arm,thumb,thumb2)          |    (SEV/WFE/WFI/NOP/YIELD). They can
+-------------------------------------+    be either real or default to NOP.
| ARMV7 (arm,thumb,thumb2)            |    The two processors also use
+-------------------------------------+    different encoding for them.

Patch by Vinicius Tinti.

llvm-svn: 232469
2015-03-17 11:55:43 +00:00
Peter Collingbourne d2926c91d5 Implement bad cast checks using control flow integrity information.
This scheme checks that pointer and lvalue casts are made to an object of
the correct dynamic type; that is, the dynamic type of the object must be
a derived class of the pointee type of the cast. The checks are currently
only introduced where the class being casted to is a polymorphic class.

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

llvm-svn: 232241
2015-03-14 02:42:25 +00:00
Justin Bogner 0cb14759fc Driver: Keep -isysroot flags in crash scripts if we're dumping a VFS
For crashes with a VFS (ie, with modules), the -isysroot flag is often
necessary to reproduce the crash. This is especially true if some
modules need to be rebuilt, since without the sysroot they'll try to
read headers that are outside of the VFS.

I find it likely that we should keep some of the other -i flags in
this case as well, but I haven't seen that come up in practice yet so
it seems better to be conservative.

llvm-svn: 231997
2015-03-12 00:52:56 +00:00
Justin Bogner 42220ed3da Driver: Print the clang version and original command in crash scripts
When a crash report script doesn't work for a reproduction on your
machine for one reason or another, it can be really tricky to figure
out why not. The compiler version that crashed and the original
command line before stripping flags are very helpful when this comes
up.

llvm-svn: 231989
2015-03-12 00:14:35 +00:00
Alexey Samsonov ce2e77c771 Add deprecation notice for -f(no-)sanitize-recover flags.
These flags should be replaced with corresponding
-f(no-)sanitize-recover=<list> flags.

llvm-svn: 231983
2015-03-11 23:34:25 +00:00
Hal Finkel 0d0a1a53e3 [PowerPC] ABI support for the QPX vector instruction set
Support for the QPX vector instruction set, used on the IBM BG/Q supercomputer,
has recently been added to the LLVM PowerPC backend. This vector instruction
set requires some ABI modifications because the ABI on the BG/Q expects
<4 x double> vectors to be provided with 32-byte stack alignment, and to be
handled as native vector types (similar to how Altivec vectors are handled on
mainline PPC systems). I've named this ABI variant elfv1-qpx, have made this
the default ABI when QPX is supported, and have updated the ABI handling code
to provide QPX vectors with the correct stack alignment and associated
register-assignment logic.

llvm-svn: 231960
2015-03-11 19:14:15 +00:00
Renato Golin 496059c8c9 Allow -target= and --target options
Using clang as a cross-compiler with the 'target' option could be confusing
for those inexperienced in the realm of cross compiling.

This patch would allow the use of all these four variants of the target option:
-target <triple>
--target <triple>
-target=<triple>
--target=<triple>

Patch by Gabor Ballabas.

llvm-svn: 231787
2015-03-10 13:58:33 +00:00
Alexey Samsonov 21d2dda3d2 [UBSan] Split -fsanitize=shift into -fsanitize=shift-base and -fsanitize=shift-exponent.
This is a recommit of r231150, reverted in r231409. Turns out
that -fsanitize=shift-base check implementation only works if the
shift exponent is valid, otherwise it contains undefined behavior
itself.

Make sure we check that exponent is valid before we proceed to
check the base. Make sure that we actually report invalid values
of base or exponent if -fsanitize=shift-base or
-fsanitize=shift-exponent is specified, respectively.

llvm-svn: 231711
2015-03-09 21:50:19 +00:00
Chandler Carruth 7e7dd47fc2 Much like we silence warnings about -flto in many cases to facilitate
simplicity in build systems, silence '-stdlib=libc++' when linking. Even
if we're not linking C++ code per-se, we may be passing this flag so
that when we are linking C++ code we pick up the desired standard
library. While most build systems already provide separate C and C++
compile flags, many conflate link flags. Sadly, CMake is among them
causing this warning in a libc++ selfhost.

llvm-svn: 231559
2015-03-07 10:01:29 +00:00
Alexey Samsonov 48a9db034a Revert "[UBSan] Split -fsanitize=shift into -fsanitize=shift-base and -fsanitize=shift-exponent."
It's not that easy. If we're only checking -fsanitize=shift-base we
still need to verify that exponent has sane value, otherwise
UBSan-inserted checks for base will contain undefined behavior
themselves.

llvm-svn: 231409
2015-03-05 21:57:35 +00:00
Toma Tabacu 18ca267d7a Recommit "[IAS] Teach -cc1as about the 'target-abi' option."
Added a REQUIRES for the Mips target.
Also, switched to using plain CHECKs, at the suggestion of Eric Christopher.

llvm-svn: 231363
2015-03-05 13:39:14 +00:00
Hans Wennborg bb49a5de12 Fix msvc-link.c test for environments with link.exe on PATH
Patch by Michael Edwards!

llvm-svn: 231339
2015-03-05 02:26:58 +00:00
Hans Wennborg e4c47f2e8b Pass -dll to link.exe when building with -shared (PR22697)
And start building a test for non-clang-cl link.exe invocations.

llvm-svn: 231312
2015-03-04 23:16:21 +00:00
Daniel Jasper cbdf3b79d4 Revert "[IAS] Teach -cc1as about the 'target-abi' option."
This reverts commit 0e41c8faeff75614cf4627533331d780ba3db030.

This is breaking buildbots:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/4668/

llvm-svn: 231248
2015-03-04 15:02:22 +00:00
Toma Tabacu 71f5be1ed0 [IAS] Teach -cc1as about the 'target-abi' option.
Summary:
When using the IAS from clang, the 'target-abi' option gets passed to cc1as, but cc1as doesn't know about it and gives an "unknown argument" error.

This is fixed by adding the 'CC1AsOption' flag to the 'target-abi' option in CC1Options.td.

Reviewers: atanasyan, echristo, dsanders

Reviewed By: dsanders

Subscribers: cfe-commits

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

llvm-svn: 231244
2015-03-04 14:24:25 +00:00
Alexey Samsonov 783b8174ad [UBSan] Split -fsanitize=shift into -fsanitize=shift-base and -fsanitize=shift-exponent.
-fsanitize=shift is now a group that includes both these checks, so
exisiting users should not be affected.

This change introduces two new UBSan kinds that sanitize only left-hand
side and right-hand side of shift operation. In practice, invalid
exponent value (negative or too large) tends to cause more portability
problems, including inconsistencies between different compilers, crashes
and inadequeate results on non-x86 architectures etc. That is,
-fsanitize=shift-exponent failures should generally be addressed first.

As a bonus, this change simplifies CodeGen implementation for emitting left
shift (separate checks for base and exponent are now merged by the
existing generic logic in EmitCheck()), and LLVM IR for these checks
(the number of basic blocks is reduced).

llvm-svn: 231150
2015-03-03 22:15:35 +00:00
Dan Albert 77214a4498 Don't force -pie for Android.
Summary:
There is no -no-pie flag that can override this, so making it default
to being on for Android means it is no longer possible to create
non-PIE executables on Android. While current versions of Android
support (and the most recent requires) PIE, ICS and earlier versions
of Android cannot run PIE executables, so this needs to be optional.

Reviewers: srhines

Reviewed By: srhines

Subscribers: thakis, volkalexey, cfe-commits

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

llvm-svn: 231091
2015-03-03 18:24:57 +00:00
Duncan P. N. Exon Smith f04be1fb3a DebugInfo: Move new hierarchy into place (clang)
Update testcases for LLVM change in r231082 to use the new debug info
hierarchy.

llvm-svn: 231083
2015-03-03 17:25:55 +00:00
Fariborz Jahanian 773fa2cb03 [SDK modernizer]. Patch fixes driver's lack of
recognition of mernizer's -objcmt-migrate-property-dot-syntax
option with a new test in test/Driver. rdar://19994452

llvm-svn: 231080
2015-03-03 17:15:38 +00:00
Reid Kleckner acbd23adf1 Remove shell requirements from tests that use 'cd'
Modules and Tooling tests in particular tend to want to change the cwd,
so we were missing test coverage in this area on Windows. It should now
be easier to write such portable tests.

llvm-svn: 231029
2015-03-02 22:42:58 +00:00
Hans Wennborg e215594013 clang-cl: Correctly ignore /openmp- (PR22748)
llvm-svn: 231026
2015-03-02 22:09:05 +00:00
Filipe Cabecinhas 1f72a0006c Add -fexceptions for targets where it isn't the default.
It still tests that objc++-cpp-output turns on -fcxx-exceptions and
-fobjc-exceptions by being a c++ and objc(++) file.

llvm-svn: 230992
2015-03-02 19:11:53 +00:00
Evgeniy Stepanov 6e09bca0ef [msan] Change track-origins default mode from 1 to 2.
Change -fsanitize-memory-track-origins to be equivalent to
-fsanitize-memory-track-origins=2.

Track-origins=2 provides a lot more detailed reports at the cost of
some additional slowdown (ranging from none to, sometimes, 3x; ~3% average on
SPEC2006).

llvm-svn: 230644
2015-02-26 15:59:30 +00:00
Simon Atanasyan 59b25cbeaa [Mips] Handle -mips32r[3|5] / -mips64r[3|5] options while selecting lib/headers paths
There is no supported toolchain which provides headers / libs / object
files specific to the mips32r[3|5] and mips64r[3|5] ISA. So select "r2"
specific folders when they are available.

http://reviews.llvm.org/D7879

llvm-svn: 230611
2015-02-26 04:45:57 +00:00
Reid Kleckner c00927cd20 clang-cl: Ignore /Fd silently
While it's true that we don't create the PDB as requested on the command
line, this is a well-documented limitation. Warning about it doesn't
help people using legacy build systems with clang-cl, and it makes the
clang-cl self-host very noisy.

llvm-svn: 230527
2015-02-25 19:17:50 +00:00
Simon Atanasyan 3f02403b3a [Mips] Support mips-r6 path suffix for Adnroid MIPS toolchain
This path suffix is used if user provides the -mips32r6 command line
options.

llvm-svn: 230469
2015-02-25 07:31:12 +00:00
Reid Kleckner c4da9c8e50 -fms-extensions: Bump the default _MSC_VER from 1700 to 1800, aka VS2013
VS 2013 is the minimum supported version, so it's reasonable for Clang
to simulate this by default. This also simplifies the clang-cl
self-host, since we have the 18.00 version check.

llvm-svn: 230243
2015-02-23 19:25:48 +00:00
Simon Atanasyan 162feb5f8e [Mips] Support mips32r3, mips32r5, mips64r3, mips64r5 MIPS ISA names
The patch teaches the clang's driver to understand new MIPS ISA names,
pass appropriate options to the assembler, defines corresponding macros etc

http://reviews.llvm.org/D7737

llvm-svn: 230092
2015-02-20 23:37:40 +00:00
Peter Collingbourne a4ccff3281 Implement Control Flow Integrity for virtual calls.
This patch introduces the -fsanitize=cfi-vptr flag, which enables a control
flow integrity scheme that checks that virtual calls take place using a vptr of
the correct dynamic type. More details in the new docs/ControlFlowIntegrity.rst
file.

It also introduces the -fsanitize=cfi flag, which is currently a synonym for
-fsanitize=cfi-vptr, but will eventually cover all CFI checks implemented
in Clang.

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

llvm-svn: 230055
2015-02-20 20:30:56 +00:00
Rafael Espindola 6b07a1c6ee Add -funique-section-names and -fno-unique-section-names options.
For now -funique-section-names is the default, so no change in default behavior.

The total .o size in a build of llvm and clang goes from 241687775 to 230649031
bytes if -fno-unique-section-names is used.

llvm-svn: 230031
2015-02-20 18:08:57 +00:00
Filipe Cabecinhas ec5d0e6423 Improve our handling of rtti/sanitize=vptr/sanitize=undefined
This patch removes the huge blob of code that is dealing with
rtti/exceptions/sanitizers and replaces it with:

A ToolChain function which, for a given set of Args, figures out if rtti
should be:
  - enabled
  - disabled implicitly
  - disabled explicitly

A change in the way SanitizerArgs figures out what sanitizers to enable
(or if it should error out, or warn);

And a check for exceptions/rtti interaction inside addExceptionArgs.

The RTTIMode algorithm is:
  - If -mkernel, -fapple-kext, or -fno-rtti are passed, rtti was disabled explicitly;
  - If -frtti was passed or we're not targetting the PS4, rtti is enabled;
  - If -fexceptions or -fcxx-exceptions was passed and we're targetting
    the PS4, rtti was enabled implicitly;
  - If we're targetting the PS4, rtti is disabled implicitly;
  - Otherwise, rtti is enabled;

Since the only flag needed to pass to -cc1 is -fno-rtti if we want to
disable it, there's no problem in saying rtti is enabled if we're
compiling C code, so we don't look at the input file type.

addExceptionArgs now looks at the RTTIMode and warns that rtti is being
enabled implicitly if targetting the PS4 and exceptions are on. It also
errors out if, targetting the PS4, -fno-rtti was passed, and exceptions
were turned on.

SanitizerArgs now errors out if rtti was disabled explicitly and the vptr
sanitizer was enabled implicitly, but just turns off vptr if rtti is
disabled but -fsanitize=undefined was passed.

Also fixed tests, removed duplicate name from addExceptionArgs comment,
and added one or two surrounding lines when running clang-format.
This changes test/Driver/fsanitize.c to make it not expect a warning when
passed -fsanitize=undefined -fno-rtti, but expect vptr to not be on.

Removed all users and definition of SanitizerArgs::sanitizesVptr().

Reviewers: samsonov

Subscribers: llvm-commits, samsonov, rsmith

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

llvm-svn: 229801
2015-02-19 01:04:49 +00:00
Bradley Smith d86d670e85 [ARM] Add missing M/R class CPUs
Add some of the missing M and R class Cortex CPUs, namely:

Cortex-M0+ (called Cortex-M0plus for GCC compatibility)
Cortex-M1
SC000
SC300
Cortex-R5

llvm-svn: 229661
2015-02-18 10:34:48 +00:00
Reid Kleckner 469b6bce61 clang-cl: Map /wd4996 to -Wno-deprecated-declarations
This is typically used to suppress warnings about calling snprintf and
other "deprecated" POSIX functions. Accepting this flag helps avoid tons
of useless warnings when trying out clang-cl on a new project.

Patch by Scott Graham!

llvm-svn: 229583
2015-02-17 23:28:19 +00:00
Sergey Matveev 2ba8778157 Append -fno-assume-sane-operator-new in ASan builds.
This should help LSan detect leaks where operator new would otherwise be
optimized out.

llvm-svn: 229498
2015-02-17 15:09:33 +00:00
David Majnemer a5b195a1dc Revert "Revert r229082 for a bit, it caused PR22577."
This reverts commit r229123.  It was a red herring, the bug was present
without r229082.

llvm-svn: 229205
2015-02-14 01:35:12 +00:00
Nico Weber 7ce96b853d Revert r229082 for a bit, it caused PR22577.
llvm-svn: 229123
2015-02-13 16:27:00 +00:00
David Majnemer abc482effc MS ABI: Implement /volatile:ms
The /volatile:ms semantics turn volatile loads and stores into atomic
acquire and release operations.  This distinction is important because
volatile memory operations do not form a happens-before relationship
with non-atomic memory.  This means that a volatile store is not
sufficient for implementing a mutex unlock routine.

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

llvm-svn: 229082
2015-02-13 07:55:47 +00:00
Filipe Cabecinhas d0c6468a2b Fix tests so they work when the linker is gcc
If the linker is gcc (the default for Generic_ELF toolchains), we end up
passing most of the arguments to the linker.

Some tests were failing to account for this in their usage of *-NOT: lines
and would fail if compiled with
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-unknown

llvm-svn: 228902
2015-02-12 03:37:55 +00:00
Bill Schmidt 911b7b1de6 [PowerPC] Remove the --no-tls-optimize workaround from the clang driver
llvm-svn: 228739
2015-02-10 20:36:08 +00:00
Bradley Smith 1a178c5663 [ARM] Add tests for armv6s[-]m being an alias to armv6[-]m
llvm-svn: 228697
2015-02-10 15:16:49 +00:00
Bob Wilson 14ebd851d9 Do not force "-static" for aarch64 iOS kernel/kext assembly code.
Somehow a check for aarch64 was added to the Darwin toolchain's
isKernelStatic function as part of the initial commit for Apple's
arm64 target (r205100). That check was not in any of Apple's internal
code and no one here knows where it came from. It has been harmless
because "-static" does not change much, if anything, for arm64 iOS code,
but it makes no sense to keep this check.

llvm-svn: 228673
2015-02-10 06:33:04 +00:00