Commit Graph

67583 Commits

Author SHA1 Message Date
Daniel Marjamaki dc53b680cb [analyzer] Revert 295545. There are buildbot failures.
llvm-svn: 295548
2017-02-18 16:31:35 +00:00
Daniel Marjamaki 1149166bb9 [analyzer] Fix crash in CastToStruct when there is no record definition
This crash was reported in https://bugs.llvm.org//show_bug.cgi?id=31173

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

llvm-svn: 295545
2017-02-18 11:18:57 +00:00
Serge Pavlov 947719bed1 Process attributes 'ifunc' and 'alias' when checking for redefinition
These attributes effectively turn a non-defining declaration into a
definition, so the case when the declaration already has a body must
be diagnosed properly.

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

llvm-svn: 295541
2017-02-18 06:04:15 +00:00
Dylan McKay bd4cd0c063 [AVR] Move definition of IsIntegratedAssemblerDefault
llvm-svn: 295536
2017-02-18 02:42:36 +00:00
Richard Trieu b6adf54204 Part of adding an improved ODR checker.
Reserve a spot for ODR hash in CXXRecordDecl and in its modules storage.
Default the hash value to 0 for all classes.

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

llvm-svn: 295533
2017-02-18 02:09:28 +00:00
Vedant Kumar 54e06823d2 [profiling] Make a test more explicit. NFC.
The cxx-structors.cpp test checks that some instrumentation doesn't
appear, but it should be more explicit about which instrumentation it
actually expects to appear.

llvm-svn: 295532
2017-02-18 02:02:55 +00:00
Vedant Kumar a32c08d304 [profiling] Tighten test cases which refer to "profn" vars. NFC.
The frontend can't see "__profn" profile name variables after IRGen
because llvm throws these away now. Tighten up some test cases which
checked for the non-existence of those variables.

llvm-svn: 295528
2017-02-18 01:50:14 +00:00
Vedant Kumar cab432d97d Reuse a local variable. NFC.
llvm-svn: 295527
2017-02-18 01:50:11 +00:00
Richard Smith 0aef305f35 Cleanup: use range-based for rather than separate calls to begin and end.
llvm-svn: 295524
2017-02-18 01:14:43 +00:00
Richard Smith 057ec50830 Handle deduction guides better in -ast-print.
llvm-svn: 295521
2017-02-18 01:01:48 +00:00
Richard Smith 37a93df3d5 [modules] Load the ModuleOffsetMap from the module header lazily.
If we never need to map any ID within the module to its global ID, we don't
need the module offset map. If a compilation transitively depends on lots of
unused module files, this can result in a modest performance improvement.

llvm-svn: 295517
2017-02-18 00:32:02 +00:00
Vedant Kumar 34b1fd6aaa Retry^2: [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

I also compiled X86FastISel.cpp with -fsanitize=null using
patched/unpatched clangs based on r293572. Here are the number of null
checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

Changes since the initial commit:
- Don't introduce any unintentional object-size or alignment checks.
- Don't rely on IRGen of C labels in the test.

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

llvm-svn: 295515
2017-02-17 23:22:59 +00:00
Vedant Kumar 18348ea9b9 [ubsan] Pass a set of checks to skip to EmitTypeCheck() (NFC)
CodeGenFunction::EmitTypeCheck accepts a bool flag which controls
whether or not null checks are emitted. Make this a bit more flexible by
changing the bool to a SanitizerSet.

Needed for an upcoming change which deals with a scenario in which we
only want to emit null checks.

llvm-svn: 295514
2017-02-17 23:22:55 +00:00
Carlo Bertolli 8429d81202 [OpenMP] Prepare Sema for initial implementation for pragma 'distribute parallel for'
https://reviews.llvm.org/D29922

This patch adds two fields for use in the implementation of 'distribute parallel for':

The increment expression for the distribute loop. As the chunk assigned to a team is executed by multiple threads within the 'parallel for' region, the increment expression has to correspond to the value returned by the related runtime call (for_static_init).
The upper bound of the innermost loop ('for' in 'distribute parallel for') is not the globalUB expression normally used for pragma 'for' when found in isolation. It is instead the upper bound of the chunk assigned to the team ('distribute' loop). In this way, we prevent teams from executing chunks assigned to other teams.
The use of these two fields can be see in a related explanatory patch:
https://reviews.llvm.org/D29508

llvm-svn: 295497
2017-02-17 21:29:13 +00:00
Vedant Kumar 29ba8d9bfe Revert "Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)"
This reverts commit r295401. It breaks the ubsan self-host. It inserts
object size checks once per C++ method which fire when the structure is
empty.

llvm-svn: 295494
2017-02-17 20:59:40 +00:00
Richard Smith bc491203c7 Add an explicit derived class of FunctionDecl to model deduction guides rather
than just treating them as FunctionDecls with a funny name.

No functionality change intended.

llvm-svn: 295491
2017-02-17 20:05:37 +00:00
Charles Li 0ee7c63fd7 [Test] Make Lit tests C++11 compatible - misc
Updated 5 tests.

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

llvm-svn: 295484
2017-02-17 19:36:19 +00:00
Petr Hosek 367ad73aff [CMake] Add Fuchsia toolchain CMake cache files
These cache files can be used to build Fuchsia toolchain. They also
demonstrate the use of multi-target builtins build.

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

llvm-svn: 295480
2017-02-17 19:28:54 +00:00
Jonas Hahnfeld b07931f01d [OpenMP] Fix cancellation point in task with no cancel
With tasks, the cancel may happen in another task. This has a different
region info which means that we can't find it here.

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

llvm-svn: 295474
2017-02-17 18:32:58 +00:00
Jonas Hahnfeld 20fce72f1b [OpenMP] Remove barriers at cancel and cancellation point
This resolves a deadlock with the cancel directive when there is no explicit
cancellation point. In that case, the implicit barrier acts as cancellation
point. After removing the barrier after cancel, the now unmatched barrier for
the explicit cancellation point has to go as well.

This has probably worked before rL255992: With the calls for the explicit
barrier, it was sure that all threads passed a barrier before exiting.

Reported by Simon Convent and Joachim Protze!

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

llvm-svn: 295473
2017-02-17 18:32:51 +00:00
Justin Bogner e91e9dd7bb Rename DiagnosticInfoWithDebugLoc to WithLocation to match LLVM
Updates for llvm r295465.

llvm-svn: 295466
2017-02-17 17:34:49 +00:00
Daniel Jasper 23c2b5ae7e clang-format: Don't remove existing spaces between identifier and ::.
This can lead to bad behavior with macros that are used to annotate
functions (e.g. ALWAYS_INLINE).

Before, this:
  ALWAYS_INLINE ::std::string getName() ...

was turned into:
  ALWAYS_INLINE::std::string getName() ...

If it turns out that clang-format is failing to clean up a lot of the
existing spaces now, we can add more analyses of the identifier. It
should not currently. Cases where clang-format breaks nested name
specifiers should be fine as clang-format wraps after the "::". Thus, a
line getting longer and then shorter again should lead to the same
original code.

llvm-svn: 295437
2017-02-17 10:44:07 +00:00
Ismail Donmez cb17fbb00b Update Bugzilla URLs in docs
llvm-svn: 295433
2017-02-17 08:26:54 +00:00
Richard Trieu dc4cb02470 Revert r295421, new ODR checker for modules, to fix build bot.
llvm-svn: 295427
2017-02-17 07:19:24 +00:00
Richard Trieu cb6b72628e Add better ODR checking for modules.
A slightly weaker form of ODR checking than previous attempts, but hopefully
won't break the modules build bot.  Future work will be needed to catch all
cases.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 295421
2017-02-17 05:54:30 +00:00
Argyrios Kyrtzidis 74790484b5 [index] Improvde how we handle synthesized ObjC properties and the associated ivars.
Related synthesized properties with the ivar they use with the 'accessor' relation, and make sure
we mark them 'implicit' when appropriate.

Patch by Nathan Hawes!
https://reviews.llvm.org/D30012

llvm-svn: 295416
2017-02-17 04:49:41 +00:00
Ekaterina Romanova ff266f5236 Added doxygen comments to smmintrin.h's intrinsics.
Note: The doxygen comments are automatically generated based on Sony's intrinsic
s document.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

llvm-svn: 295404
2017-02-17 02:49:50 +00:00
Vedant Kumar 55875b9955 Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

Changes since the initial commit: don't rely on IRGen of C labels in the
test.

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

llvm-svn: 295401
2017-02-17 02:03:51 +00:00
Vedant Kumar 4f94a94bea Revert "[ubsan] Reduce null checking of C++ object pointers (PR27581)"
This reverts commit r295391. It breaks this bot:

http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/1898

I need to not rely on labels in the IR test.

llvm-svn: 295396
2017-02-17 01:42:36 +00:00
Vedant Kumar 3e5a9a6be8 [ubsan] Reduce null checking of C++ object pointers (PR27581)
This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '&this->x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -------------------------------------
  | Setup          | # of null checks |
  -------------------------------------
  | unpatched, -O0 |            21767 |
  | patched, -O0   |            10758 |
  -------------------------------------

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

llvm-svn: 295391
2017-02-17 01:05:42 +00:00
Alex Lorenz 55aaa844cb Use correct fix-it location for -Wblock-capture-autoreleasing
The '__autoreleasing' keyword should be inserted after the Objective-C pointer
type.

rdar://30123548

llvm-svn: 295381
2017-02-16 23:15:36 +00:00
Richard Smith efa919ab07 Properly set up the DeclContext for parameters of implicit deduction guides;
this is needed for deferred instantiation of default arguments.

llvm-svn: 295379
2017-02-16 21:29:21 +00:00
Arpith Chacko Jacob fc711b1f47 [OpenMP] Teams reduction on the NVPTX device.
This patch implements codegen for the reduction clause on
any teams construct for elementary data types.  It builds
on parallel reductions on the GPU.  Subsequently,
the team master writes to a unique location in a global
memory scratchpad.  The last team to do so loads and
reduces this array to calculate the final result.

This patch emits two helper functions that are used by
the OpenMP runtime on the GPU to perform reductions across
teams.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29879

llvm-svn: 295335
2017-02-16 16:48:49 +00:00
Arpith Chacko Jacob 101e8fb1f3 [OpenMP] Parallel reduction on the NVPTX device.
This patch implements codegen for the reduction clause on
any parallel construct for elementary data types.  An efficient
implementation requires hierarchical reduction within a
warp and a threadblock.  It is complicated by the fact that
variables declared in the stack of a CUDA thread cannot be
shared with other threads.

The patch creates a struct to hold reduction variables and
a number of helper functions.  The OpenMP runtime on the GPU
implements reduction algorithms that uses these helper
functions to perform reductions within a team.  Variables are
shared between CUDA threads using shuffle intrinsics.

An implementation of reductions on the NVPTX device is
substantially different to that of CPUs.  However, this patch
is written so that there are minimal changes to the rest of
OpenMP codegen.

The implemented design allows the compiler and runtime to be
decoupled, i.e., the runtime does not need to know of the
reduction operation(s), the type of the reduction variable(s),
or the number of reductions.  The design also allows reuse of
host codegen, with appropriate specialization for the NVPTX
device.

While the patch does introduce a number of abstractions, the
expected use case calls for inlining of the GPU OpenMP runtime.
After inlining and optimizations in LLVM, these abstractions
are unwound and performance of OpenMP reductions is comparable
to CUDA-canonical code.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29758

llvm-svn: 295333
2017-02-16 16:20:16 +00:00
Arpith Chacko Jacob bd6344c0be Revert r295319 while investigating buildbot failure.
llvm-svn: 295323
2017-02-16 14:25:35 +00:00
Benjamin Kramer aad1bdc863 Silence sign compare warning. NFC.
ExprConstant.cpp:6344:20: warning: comparison of integers of different
signs: 'const size_t' (aka 'const unsigned long') and 'typename
iterator_traits<Expr *const *>::difference_type' (aka 'long')
[-Wsign-compare]

llvm-svn: 295320
2017-02-16 14:08:41 +00:00
Arpith Chacko Jacob 8e170fc857 [OpenMP] Parallel reduction on the NVPTX device.
This patch implements codegen for the reduction clause on
any parallel construct for elementary data types.  An efficient
implementation requires hierarchical reduction within a
warp and a threadblock.  It is complicated by the fact that
variables declared in the stack of a CUDA thread cannot be
shared with other threads.

The patch creates a struct to hold reduction variables and
a number of helper functions.  The OpenMP runtime on the GPU
implements reduction algorithms that uses these helper
functions to perform reductions within a team.  Variables are
shared between CUDA threads using shuffle intrinsics.

An implementation of reductions on the NVPTX device is
substantially different to that of CPUs.  However, this patch
is written so that there are minimal changes to the rest of
OpenMP codegen.

The implemented design allows the compiler and runtime to be
decoupled, i.e., the runtime does not need to know of the
reduction operation(s), the type of the reduction variable(s),
or the number of reductions.  The design also allows reuse of
host codegen, with appropriate specialization for the NVPTX
device.

While the patch does introduce a number of abstractions, the
expected use case calls for inlining of the GPU OpenMP runtime.
After inlining and optimizations in LLVM, these abstractions
are unwound and performance of OpenMP reductions is comparable
to CUDA-canonical code.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29758

llvm-svn: 295319
2017-02-16 14:03:36 +00:00
Anastasia Stulova b376bee642 [OpenCL][Doc] Added OpenCL vendor extension description to user manual doc
Added description of a new feature that allows to specify
vendor extension in flexible way using compiler pragma instead
of modifying source code directly (committed in clang@r289979).

Review: D29829
llvm-svn: 295313
2017-02-16 12:49:29 +00:00
Krasimir Georgiev bb99a36dc0 [clang-format] Align block comment decorations
Summary:
This patch implements block comment decoration alignment.

source:
```
/* line 1
* line 2
*/
```

result before:
```
/* line 1
* line 2
*/
```

result after:
```
/* line 1
 * line 2
 */
```

Reviewers: djasper, bkramer, klimek

Reviewed By: klimek

Subscribers: mprobst, cfe-commits, klimek

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

llvm-svn: 295312
2017-02-16 12:39:31 +00:00
Anastasia Stulova 58984e7087 [OpenCL] Correct ndrange_t implementation
Removed ndrange_t as Clang builtin type and added
as a struct type in the OpenCL header.

Use type name to do the Sema checking in enqueue_kernel
and modify IR generation accordingly.

Review: D28058

Patch by Dmitry Borisenkov!  
 

llvm-svn: 295311
2017-02-16 12:27:47 +00:00
Anastasia Stulova 9d98a316c5 [OpenCL] Disallow blocks capture other blocks (v2.0, s6.12.5)
llvm-svn: 295307
2017-02-16 11:13:30 +00:00
Erik Verbruggen 2c7c38d9bb Cache FileID when translating diagnostics in PCH files
Modules/preambles/PCH files can contain diagnostics, which, when used,
are added to the current ASTUnit. For that to work, they are translated
to use the current FileManager's FileIDs. When the entry is not the
main file, all local source locations will be checked by a linear
search. Now this is a problem, when there are lots of diagnostics (say,
25000) and lots of local source locations (say, 440000), and end up
taking seconds when using such a preamble.

The fix is to cache the last FileID, because many subsequent diagnostics
refer to the same file. This reduces the time spent in
ASTUnit::TranslateStoredDiagnostics from seconds to a few milliseconds
for files with many slocs/diagnostics.

This fixes PR31353.
Differential Revision: https://reviews.llvm.org/D29755

llvm-svn: 295301
2017-02-16 09:49:30 +00:00
Richard Trieu e55fb7f6f1 Revert r295284: Add better ODR checking for modules.
Fix modules build bot.

llvm-svn: 295293
2017-02-16 07:09:18 +00:00
Craig Topper f0d1147fae [AVX-512] Replace 512-bit masked packss/packus builtins and replace with new unmasked builtins.
These new unmasked builtins will enable us to easily support optimizing these builtins in InstCombine in the backend.

llvm-svn: 295291
2017-02-16 06:32:07 +00:00
Richard Trieu 2700dc1302 Loosen a Type check ODR checking to try to fix the build bot.
llvm-svn: 295286
2017-02-16 05:48:25 +00:00
Richard Trieu f351ac8987 Add better ODR checking for modules.
Recommit r293585 that was reverted in r293611 with new fixes.  The previous
issue was determined to be an overly aggressive AST visitor from forward
declared objects.  The visitor will now only deeply visit certain Decl's and
only do a shallow information extraction from all other Decl's.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

llvm-svn: 295284
2017-02-16 04:53:40 +00:00
Richard Smith f0393bf0a5 Revert r295277 to fix buildbot.
llvm-svn: 295281
2017-02-16 04:22:56 +00:00
Faisal Vali 051e3a2b7d [cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.
Enable evaluation of captures within constexpr lambdas by using a strategy similar to that used in CodeGen:
  - when starting evaluation of a lambda's call operator, create a map from VarDecl's to a closure's FieldDecls
  - every time a VarDecl (or '*this) that represents a capture is encountered while evaluating the expression via the expression evaluator (specifically the LValueEvaluator) in ExprConstant.cpp - it is replaced by the corresponding FieldDecl LValue (an Lvalue-to-Rvalue conversion on this LValue representation then determines the right rvalue when needed).

Thanks to Richard Smith and Hubert Tong for their review and feedback!

https://reviews.llvm.org/D29748

llvm-svn: 295279
2017-02-16 04:12:21 +00:00
Richard Smith 86a1b135f0 Add missing "deduced A == A" check for function template partial ordering.
This appears to be the only template argument deduction context where we were
missing this check. Surprisingly, other implementations also appear to miss
the check in this case; it may turn out that important code is relying on
the widespread non-conformance here, in which case we'll need to reconsider.

llvm-svn: 295277
2017-02-16 03:49:44 +00:00
Evgeniy Stepanov 287b04b000 Add missing regexp quantifiers in a test.
llvm-svn: 295267
2017-02-16 01:35:23 +00:00