Commit Graph

30829 Commits

Author SHA1 Message Date
Eric Christopher b70819e6a2 Add preprocessor defines for a bare powerpc64le triple/cpu.
The le triple didn't exist until power8, so use that as a default (this
also matches what gcc does).

llvm-svn: 298759
2017-03-25 02:29:18 +00:00
Richard Trieu 7583bec0c3 [ODRHash] Add support for array and decayed types.
llvm-svn: 298754
2017-03-25 00:48:52 +00:00
Richard Trieu 73bac6a2f0 [ODRHash] Add error messages for mismatched parameters in methods.
llvm-svn: 298742
2017-03-24 21:17:48 +00:00
Peter Collingbourne cbc69712da Fix a test so that it actually checks the output.
llvm-svn: 298728
2017-03-24 19:32:20 +00:00
Artem Dergachev 356151ff5f [analyzer] Add MisusedMovedObjectChecker for detecting use-after-move errors.
The checker currently warns on copying, moving, or calling methods on an object
that was recently std::move'd from. It understands a set of "state reset"
methods that bring a moved-from object back to a well-specified state.

Patch by Peter Szecsi!

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

llvm-svn: 298698
2017-03-24 09:52:30 +00:00
Chandler Carruth 45bbe0117b Revert r298491 and r298494 which changed Clang's handling of 'nonnull'
attributes.

These patches don't work because we can't currently access the parameter
information in a reliable way when building attributes. I thought this
would be relatively straightforward to fix, but it seems not to be the
case. Fixing this will requrie a substantial re-plumbing of machinery to
allow attributes to be handled in this location, and several other fixes
to the attribute machinery should probably be made at the same time. All
of this will make the patch .... substantially more complicated.

Reverting for now as there are active miscompiles caused by the current
version.

llvm-svn: 298695
2017-03-24 09:11:57 +00:00
Richard Smith 49a6b6e91e Fix handling of initialization from parenthesized initializer list.
This change fixes a crash on initialization of a reference from ({}) during
template instantiation and incidentally improves diagnostics.

This reverts a prior attempt to handle this in r286721. Instead, we teach the
initialization code that initialization cannot be performed if a source type
is required and the initializer is an initializer list (which is not an
expression and does not have a type), and likewise for function-style cast
expressions.

llvm-svn: 298676
2017-03-24 01:14:25 +00:00
Dehao Chen 1240bd31e9 Update the SamplePGO test to verify that unroll/icp is not invoked in thinlto compile phase.
Summary: This is the test added for https://reviews.llvm.org/D31217

Reviewers: tejohnson, mehdi_amini

Reviewed By: tejohnson

Subscribers: cfe-commits, Prazek

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

llvm-svn: 298647
2017-03-23 21:20:17 +00:00
Teresa Johnson 488d1dc0ed [ThinLTO] Clang support for emitting minimized bitcode for thin link
Summary:
Clang companion patch to LLVM patch D31027, which adds support
for emitting minimized bitcode file for use in the thin link step.
Add a cc1 option -fthin-link-bitcode=<file> to trigger this behavior.

Depends on D31027.

Reviewers: mehdi_amini, pcc

Subscribers: cfe-commits, Prazek

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

llvm-svn: 298639
2017-03-23 19:47:49 +00:00
Erich Keane a32910da1a Correct class-template deprecation behavior-REDUX
Correct class-template deprecation behavior

Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case:
template<typename T> [[deprecated]] class Foo{}; Foo<int> f;

This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute.

Previous DiffRev: https://reviews.llvm.org/D27486, was reverted.
This patch fixes the issues brought up here by the reverter: https://reviews.llvm.org/rL298410

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

llvm-svn: 298634
2017-03-23 18:51:54 +00:00
Argyrios Kyrtzidis a9876cafe2 [index] When indexing system headers make sure to report important reference relations
Even if we exclude plain reference occurrences, we should include relation-based references, like the 'base' one.

rdar://31010737

llvm-svn: 298622
2017-03-23 16:34:47 +00:00
Alex Lorenz f937139530 Support attributes for Objective-C categories
rdar://31095315

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

llvm-svn: 298589
2017-03-23 11:44:25 +00:00
Alex Lorenz a8fbef44fe [CodeGen] Emit a CoreFoundation link guard when @available is used
After r297760, __isOSVersionAtLeast in compiler-rt loads the CoreFoundation
symbols at runtime. This means that `@available` will always fail when used in a
binary without a linked CoreFoundation.

This commit forces Clang to emit a reference to a CoreFoundation symbol when
`@available` is used to ensure that linking will fail when CoreFoundation isn't
linked with the build product.

rdar://31039592

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

llvm-svn: 298588
2017-03-23 11:14:27 +00:00
Alex Lorenz 5ffe4e14f1 [ObjC][ARC] Avoid -Warc-performSelector-leaks for performSelector variations
that became supported after r297019

The commit r297019 expanded the performSelector ObjC method family heuristic
to ensure that -Wobjc-unsafe-perform-selector covers all performSelector
variations. However, this made the -Warc-performSelector-leaks too noisy, as
that warning produces mostly false positives since the selector is unknown.
This commit reverts the ObjC method family heuristics introduced in r297019.
This ensures that -Warc-performSelector-leaks isn't too noisy. The commit still
preserves the coverage of -Wobjc-unsafe-perform-selector.

rdar://31124629

llvm-svn: 298587
2017-03-23 10:46:05 +00:00
Eric Fiselier a9fdb346db [coroutines] Implement unhandled_exception changes.
Summary:
This patch adopts the recent changes that renamed `set_exception(exception_pointer)` to `unhandled_exception()`. 

Additionally `unhandled_exception()` is now required, and so an error is emitted when exceptions are enabled but the promise type does not provide the member.
When exceptions are disabled a warning is emitted instead of an error, The warning notes that the `unhandled_exception()` function is required when exceptions are enabled.

Reviewers: rsmith, GorNishanov, aaron.ballman, majnemer

Reviewed By: GorNishanov

Subscribers: mehdi_amini, cfe-commits

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

llvm-svn: 298565
2017-03-23 00:33:33 +00:00
Hans Wennborg 043f402586 [X86] Implement __readgsqword (and the rest) as builtins (PR32373)
It seems MS headers have started using __readgsqword, and since it's
used in a header that doesn't include intrin.h, we can't implement it as
an inline function anymore.

That was already the case for __readfsdword, which Saleem added support
for in r220859. This patch reuses that codegen to implement all of
__read[fg]s{byte,word,dword,qword}.

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

llvm-svn: 298538
2017-03-22 19:13:13 +00:00
Simon Pilgrim 0f3a52b8c9 [X86][MMX] Add tests for _mm_set*_* intrinsics
llvm-svn: 298511
2017-03-22 14:55:43 +00:00
Martin Bohme 926572303e Revert "Correct class-template deprecation behavior"
This reverts commit r298410 (which produces incorrect warnings, see
comments on https://reviews.llvm.org/rL298410).

llvm-svn: 298504
2017-03-22 13:34:37 +00:00
Martin Bohme b41979640f Revert "iFix Test deprecation behavior in C89 mode as a result of r298410"
This reverts commit r298433. (Required to revert r298410, see comments
there.)

llvm-svn: 298503
2017-03-22 13:33:03 +00:00
Chandler Carruth 421fa6c9e2 Remove an overly aggressive assert in r298491 and leave a comment
explaining why we have to ignore errors here even though in other parts
of codegen we can be more strict with builtins.

Also add a test case based on the code in a TSan test that found this
issue.

llvm-svn: 298494
2017-03-22 10:38:07 +00:00
Alex Lorenz 00aee43734 [Serialization] Serialize DependentSizedExtVectorType
rdar://30659700

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

llvm-svn: 298493
2017-03-22 10:04:48 +00:00
Chandler Carruth 9b3607f0a6 [nonnull] Teach Clang to attach the nonnull LLVM attribute to
declarations and calls instead of just definitions, and then teach it to
*not* attach such attributes even if the source code contains them.

This follows the design direction discussed on cfe-dev here:
http://lists.llvm.org/pipermail/cfe-dev/2017-January/052066.html

The idea is that for C standard library builtins, even if the library
vendor chooses to annotate their routines with __attribute__((nonnull)),
we will ignore those attributes which pertain to pointer arguments that
have an associated size. This allows the widespread (and seemingly
reasonable) pattern of calling these routines with a null pointer and
a zero size. I have only done this for the library builtins currently
recognized by Clang, but we can now trivially add to this set. This will
be controllable with -fno-builtin if anyone should care to do so.

Note that this does *not* change the AST. As a consequence, warnings,
static analysis, and source code rewriting are not impacted.

This isn't even a regression on any platform as neither Clang nor LLVM
have ever put 'nonnull' onto these arguments for declarations. All this
patch does is enable it on other declarations while preventing us from
ever accidentally enabling it on these libc functions due to a library
vendor.

It will also allow any other libraries using this annotation to gain
optimizations based on the annotation even when only a declaration is
visible.

llvm-svn: 298491
2017-03-22 09:09:13 +00:00
Richard Smith 7532d3790f Suppress warning on unreachable [[clang::fallthrough]] within a template instantiation.
We don't know whether some other instantiation of the template might be able to
reach the annotation, so warning on it has a high chance of false positives.

Patch by Ahmed Asadi!

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

llvm-svn: 298477
2017-03-22 01:49:19 +00:00
Adam Nemet 5827756e90 Remove -ffp-contract=fast from this test
It does not need it and causes mismatch after -ffp-contract=fast is turned
into an FMF.

llvm-svn: 298469
2017-03-22 00:58:18 +00:00
Adam Nemet 3087c96348 Change -ffp-contract=fast test to run on Aarch64
(I don't have powerpc enabled in my build and I am changing
how -ffp-contract=fast works.)

llvm-svn: 298468
2017-03-22 00:58:15 +00:00
Eric Christopher 758aad76d8 Remove the -faltivec alias option and replace it with -maltivec everywhere.
The alias was only ever used on darwin and had some issues there,
and isn't used in practice much. Also fixes a problem with -mno-altivec
not turning off -maltivec.

Also add a diagnostic for faltivec/fno-altivec that directs users to use
maltivec options and include the altivec.h file explicitly.

llvm-svn: 298449
2017-03-21 22:06:18 +00:00
Dehao Chen ea4b78fcb3 Add support for -fno-auto-profile and -fno-profile-sample-use
Summary: We need to be able to disable samplepgo for specific files by supporting -fno-auto-profile and -fno-profile-sample-use

Reviewers: davidxl, dnovillo, echristo

Reviewed By: echristo

Subscribers: echristo, cfe-commits

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

llvm-svn: 298446
2017-03-21 21:40:53 +00:00
Erich Keane 1248bdaba0 iFix Test deprecation behavior in C89 mode as a result of r298410
llvm-svn: 298433
2017-03-21 20:14:46 +00:00
George Burgess IV a63f91574f Let llvm.objectsize be conservative with null pointers
D28494 adds another parameter to @llvm.objectsize. Clang needs to be
sure to pass that third arg whenever applicable.

llvm-svn: 298431
2017-03-21 20:09:35 +00:00
Dehao Chen ce39fdd6ee Clang change: Do not inline hot callsites for samplepgo in thinlto compile phase.
Summary:
Because SamplePGO passes will be invoked twice in ThinLTO build: once at compile phase, the other at backend. We want to make sure the IR at the 2nd phase matches the hot part in pro
file, thus we do not want to inline hot callsites in the first phase.

Reviewers: tejohnson, eraman

Reviewed By: tejohnson

Subscribers: mehdi_amini, cfe-commits, Prazek

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

llvm-svn: 298429
2017-03-21 19:55:46 +00:00
Coby Tayree 665b89bac5 [X86][MS-compatability][clang] allow MS TYPE/SIZE/LENGTH operators as a part of a compound expression
This patch introduces X86AsmParser with the ability to handle the aforementioned ops within compound "MS" arithmetical expressions.
Currently - only supported as a stand alone Operand, e.g.:
"TYPE X"
now allowed :
"4 + TYPE X * 128"

LLVM side: https://reviews.llvm.org/D31173
Differential Revision: https://reviews.llvm.org/D31174

llvm-svn: 298426
2017-03-21 19:33:32 +00:00
Konstantin Zhuravlyov 9c1e310c16 Fix array sizes where address space is not yet known
For variables in generic address spaces, for example:

```
unsigned char V[6442450944];
...
```

the address space is not yet known when we get into
*getConstantArrayType*, it is 0. AMDGCN target's
address space 0 has 32 bits pointers, so when we
call *getPointerWidth* with 0, the array size is
trimmed to 32 bits, which is not right.

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

llvm-svn: 298420
2017-03-21 18:55:39 +00:00
Erich Keane 8a8f5f0f00 Correct class-template deprecation behavior
Based on the comment in the test, and my reading of the standard, a deprecated warning should be issued in the following case:
template<typename T> [[deprecated]] class Foo{}; Foo<int> f;

This was not the case, because the ClassTemplateSpecializationDecl creation did not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should be copied, so instead I simply copy ONLY the deprecated attribute.

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

llvm-svn: 298410
2017-03-21 17:49:17 +00:00
Argyrios Kyrtzidis 3b25c91a9e [index/AST] Determine if a typedef shares a name and spelling location with its underlying tag type
In such a case, as when using the NS_ENUM macro, for indexing purposes treat the typedef as 'transparent',
meaning we treat its references as symbols of the underlying tag symbol.
Also provide a libclang API to check for such typedefs.

llvm-svn: 298392
2017-03-21 16:56:02 +00:00
Bruno Cardoso Lopes 08ebd61a80 [Modules] Find PrivateHeaders when looking into subframeworks
Fix the current parsing of subframeworks in modulemaps to lookup for
headers based on whether they are frameworks.

rdar://problem/30563982

llvm-svn: 298391
2017-03-21 16:43:51 +00:00
Egor Churaev 392a507103 [OpenCL] Added diagnostic for checking length of vector
Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

llvm-svn: 298369
2017-03-21 13:20:57 +00:00
Egor Churaev c217f37cb6 [OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL
Summary: I added a new rank to ImplicitConversionRank enum to resolve the function overload ambiguity with vector types. Rank of scalar types conversion is lower than vector splat. So, we can choose which function should we call. See test for more details.

Reviewers: Anastasia, cfe-commits

Reviewed By: Anastasia

Subscribers: bader, yaxunl

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

llvm-svn: 298366
2017-03-21 12:55:55 +00:00
Simon Pilgrim 60e924985c [X86][AVX512] Add _mm512_cvtsd_f64 and _mm512_cvtss_f32 intrinsics (PR32305)
Differential Revision: https://reviews.llvm.org/D31155

llvm-svn: 298364
2017-03-21 12:46:13 +00:00
Akira Hatanaka 3c268af42f Add support for attribute enum_extensibility.
This commit adds support for a new attribute that will be used to
distinguish between extensible and inextensible enums. There are three
main purposes of this attribute:

1. Give better control over when enum-related warnings are issued.
For example, in the code below, clang will not issue a -Wassign-enum
warning if the enum is marked "open":

enum __attribute__((enum_extensibility(closed))) EnumClosed {
  B0 = 1, B1 = 10
};

enum __attribute__((enum_extensibility(open))) EnumOpen {
  C0 = 1, C1 = 10
};

enum EnumClosed ec = 100; // warning issued
enum EnumOpen eo = 100; // no warning

2. Enable code-completion and debugging tools to offer better
suggestions.

3. Make it easier for swift's clang importer to determine which swift
type an enum should be mapped to.

For more details, see the discussion I started on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2017-February/052748.html

rdar://problem/12764379
rdar://problem/23145650

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

llvm-svn: 298332
2017-03-21 02:23:00 +00:00
Peter Collingbourne dc205b3db2 IRGen: Do not set dllexport on declarations.
Setting dllexport on a declaration has no effect, as we do not emit export
directives for declarations.

Part of the fix for PR32334.

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

llvm-svn: 298330
2017-03-21 02:02:41 +00:00
Eric Christopher 5ba576ffe6 Fix parsing of htmxlintrin.h in C++ mode
- Fix a variable naming mismatch
 - Fix gcc extension pointer arithmetic on void to cast to char *.
 - Test that the header (and htmintrin.h) parse.

llvm-svn: 298318
2017-03-20 22:31:33 +00:00
Eric Christopher 74fa24ff27 Turn on HTM on power8 and later (including powerpc64le) since it's
available by default on those cpus and configurations.

llvm-svn: 298307
2017-03-20 21:12:53 +00:00
Richard Smith 6043e0f738 Avoid these headers looking like the same file on a content-addressed file system.
llvm-svn: 298300
2017-03-20 20:14:03 +00:00
Richard Smith 4b0cad0bb8 Bump __cplusplus for C++17 to 201703L per the C++17 DIS.
llvm-svn: 298299
2017-03-20 20:12:48 +00:00
Duncan P. N. Exon Smith 030d7d6daa Reapply "Modules: Cache PCMs in memory and avoid a use-after-free"
This reverts commit r298185, effectively reapplying r298165, after fixing the
new unit tests (PR32338).  The memory buffer generator doesn't null-terminate
the MemoryBuffer it creates; this version of the commit informs getMemBuffer
about that to avoid the assert.

Original commit message follows:

----

Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

- The ModuleManager stores PCMs there that it loads from disk, never
touching the disk if the cache is hot.

- When modules fail to validate, they're removed from the cache.

- When a CompilerInstance is spawned to build a new module, each
already-loaded PCM is assumed to be valid, and is frozen to avoid
the use-after-free.

- Any newly-built module is written directly to the cache to avoid the
round-trip to the filesystem, making lock files unnecessary for
correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

llvm-svn: 298278
2017-03-20 17:58:26 +00:00
Igor Breger f050b797ac [X86][AVX512][Clang][Intrinsics] Adding missing intrinsics to Clang .
Summary:
Adding missing intrinsics :
    _mm512_set_epi16,
    _mm512_set_epi8,
    _mm512_permutevar_epi32
    _mm512_mask_permutevar_epi32

Reviewers: zvi, guyblank, eladcohen, craig.topper

Reviewed By: craig.topper

Subscribers: craig.topper, cfe-commits

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

llvm-svn: 298208
2017-03-19 08:27:16 +00:00
Renato Golin f1966cf646 Revert "Modules: Cache PCMs in memory and avoid a use-after-free"
This reverts commit r298165, as it broke the ARM builds.

llvm-svn: 298185
2017-03-18 12:31:32 +00:00
Nirav Dave 8497ef4086 [X86] Add NumRegisterParameters Module Flag.
Reviewers: rnk, mkuper

Subscribers: llvm-commits

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

llvm-svn: 298177
2017-03-18 00:43:39 +00:00
Argyrios Kyrtzidis 573624a9c2 [index] For C++ constructors/destructors, add references to the parent type where its name appears in definitions and declarations
Patch by Nathan Hawes!
https://reviews.llvm.org/D30730

llvm-svn: 298170
2017-03-17 23:41:59 +00:00
Duncan P. N. Exon Smith 079c40e886 Modules: Cache PCMs in memory and avoid a use-after-free
Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

  - The ModuleManager stores PCMs there that it loads from disk, never
    touching the disk if the cache is hot.

  - When modules fail to validate, they're removed from the cache.

  - When a CompilerInstance is spawned to build a new module, each
    already-loaded PCM is assumed to be valid, and is frozen to avoid
    the use-after-free.

  - Any newly-built module is written directly to the cache to avoid the
    round-trip to the filesystem, making lock files unnecessary for
    correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

llvm-svn: 298165
2017-03-17 22:55:13 +00:00