Commit Graph

91400 Commits

Author SHA1 Message Date
David Sherwood 2a48b6993a [IR] In ConstantFoldShuffleVectorInstruction use zeroinitializer for splats of 0
When creating a splat of 0 for scalable vectors we tend to create them
with using a combination of shufflevector and insertelement, i.e.

shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 0, i32 0),
               <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer)

However, for the case of a zero splat we can actually just replace the
above with zeroinitializer instead. This makes the IR a lot simpler and
easier to read. I have changed ConstantFoldShuffleVectorInstruction to
use zeroinitializer when creating a splat of integer 0 or FP +0.0 values.

Differential Revision: https://reviews.llvm.org/D113394
2021-11-10 09:42:58 +00:00
Christian Kandeler f7500a4ef7 [CodeCompletion] Generally consider header files without extension
Real-world use case: The Qt framework's headers have the same name
as the respective class defined in them, and Qt's traditional qmake
build tool uses -I (rather than -isystem) to pull them in.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D112996
2021-11-10 08:22:48 +01:00
Jorge Gorbe Moya 770ddf599d Fix unused variable warning in release build 2021-11-09 19:48:42 -08:00
hsmahesha 3b9a85d10a [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas
at the start of the entry block, which in turn would aid better code transformation/optimization.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D110257
2021-11-10 08:45:21 +05:30
Igor Kudrin 5b7ea8e629 [clang-tblgen] Fix non-determinism in generating AttributeReference.rst
As for now, the categories are printed in an arbitrary order which
depends on the addresses of dynamically allocated objects. The patch
sorts them in an alphabetical order thus making the output stable.

Differential Revision: https://reviews.llvm.org/D113477
2021-11-10 10:08:07 +07:00
Igor Kudrin 7352f42cdc [clang-tblgen] Fix non-determinism in generating AttrSubMatchRulesParserStringSwitches.inc
llvm::MapVector, compared to std::map, guarantees the same iteration
order in different runs.

Differential Revision: https://reviews.llvm.org/D113168
2021-11-10 10:08:06 +07:00
Nathan Sidwell da979f6cf8 [clang] Fix restructured markup 2021-11-09 18:41:22 -05:00
Joseph Huber 4b5c3e591d [OpenMP] Remove doing assumption propagation in the front end.
This patch removes the assumption propagation that was added in D110655
primarily to get assumption informatino on opaque call sites for
optimizations. The analysis done in D111445 allows us to do this more
intelligently in the back-end.

Depends on D111445

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D111463
2021-11-09 17:39:24 -05:00
Kostya Serebryany b7f3a4f4fa [sancov] add tracing for loads and store
add tracing for loads and stores.

The primary goal is to have more options for data-flow-guided fuzzing,
i.e. use data flow insights to perform better mutations or more agressive corpus expansion.
But the feature is general puspose, could be used for other things too.

Pipe the flag though clang and clang driver, same as for the other SanitizerCoverage flags.
While at it, change some plain arrays into std::array.

Tests: clang flags test, LLVM IR test, compiler-rt executable test.

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D113447
2021-11-09 14:35:13 -08:00
Saleem Abdulrasool c17d9b4b12 headers: optionalise some generated resource headers
This splits out the generated headers and conditonalises them upon the
target being enabled.

The motivation here is that the RISCV header alone added 10MB to the
resource directory, which was previously at 10MB, increasing the build
size and time. This header is contributing ~50% of the size of the
resource headers (~10MB).

The ARM generated headers are contributing about ~10% or 1MB.

This could be extended further adding only the static resource headers
for the targets that the LLVM build supports.

The changes to the tests for ARM mirror what the RISCV target already
did and rnk identified as a possible issue.

Testing:
  cmake -G Ninja -D LLVM_TARGETS_TO_BUILD=X86 -D LLVM_ENABLE_PROJECTS="clang;lld" ../clang
  ninja check-clang

Differential Revision: https://reviews.llvm.org/D112890
Reviewed By: craig.topper
2021-11-09 22:30:29 +00:00
James Y Knight 50082e1882 Fix test after aee4925507.
(Apparently no buildbots enable both examples and plugins!)
2021-11-09 16:59:45 -05:00
Itay Bookstein 9efce0baee [clang] Run LLVM Verifier in modes without CodeGen too
Previously, the Backend_Emit{Nothing,BC,LL} modes did
not run the LLVM verifier since it is usually added via
the TargetMachine::addPassesToEmitFile method according
to the DisableVerify parameter. This is called from
EmitAssemblyHelper::AddEmitPasses, which is only relevant
for BackendAction-s that require CodeGen.

Note:
* In these particular situations the verifier is added
  to the optimization pipeline rather than the codegen
  pipeline so that it runs prior to the BC/LL emission
  pass.
* This change applies to both the old and the new PMs.
* Because the clang tests use -emit-llvm ubiquitously,
  this change will enable the verifier for them.
* A small bug is fixed in emitIFuncDefinition so that
  the clang/test/CodeGen/ifunc.c test would pass:
  the emitIFuncDefinition incorrectly passed the
  GlobalDecl of the IFunc itself to the call to
  GetOrCreateLLVMFunction for creating the resolver.

Signed-off-by: Itay Bookstein <ibookstein@gmail.com>

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D113352
2021-11-09 23:57:13 +02:00
Itay Bookstein 3b1fd19357 [CodeGen] Diagnose and reject non-function ifunc resolvers
Signed-off-by: Itay Bookstein <ibookstein@gmail.com>

Reviewed By: MaskRay, erichkeane

Differential Revision: https://reviews.llvm.org/D112868
2021-11-09 23:51:36 +02:00
Itay Bookstein ce91540bee [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen
Signed-off-by: Itay Bookstein <ibookstein@gmail.com>

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D113431
2021-11-09 23:51:29 +02:00
Itay Bookstein 4f04f7d816 [clang][test][NFC] clang-format attr-ifunc.c test
Signed-off-by: Itay Bookstein <ibookstein@gmail.com>

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D113504
2021-11-09 23:51:22 +02:00
Aaron Puchert 63ef0e17e2 Comment AST: Add support for variable templates
We treat them as variables of course, though if they have function
pointer type we treat them as functions, i.e. allow parameter and return
value specifications. Just like VarDecls.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D111266
2021-11-09 22:30:09 +01:00
Aaron Puchert 4d63824300 Comment AST: Declare function pointer variables as functions
We were doing this already for type aliases, and it deduplicates the
code looking through aliases and pointers to find a function type. As
a side effect, this finds two warnings that we apparently missed before.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D111264
2021-11-09 22:30:08 +01:00
Aaron Puchert 3506e42ab6 Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)
Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D111262
2021-11-09 22:30:08 +01:00
Haojian Wu 603c1a62f8 [clang] Don't crash on an incomplete-type base specifier in template context.
Differential Revision: https://reviews.llvm.org/D113474
2021-11-09 22:17:47 +01:00
C. Rayroud 6facafe7da [clang-format] Refactor SpaceBeforeParens to add options
The coding style of some projects requires to have more control on space
before opening parentheses.
The goal is to add the support of clang-format to more projects.
For example adding a space only for function definitions or
declarations.
This revision adds SpaceBeforeParensOptions to configure each option
independently from one another.

Differentiel Revision: https://reviews.llvm.org/D110833
2021-11-09 21:51:45 +01:00
Björn Schäpers 6633605691 [clang-format] Address fixme
Differential Revision: https://reviews.llvm.org/D113320
2021-11-09 21:51:44 +01:00
Atmn Patel 737c4a2673 [clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files
The existing CGOpenMPRuntimeAMDGCN and CGOpenMPRuntimeNVPTX classes are
just code bloat. By removing them, the codebase gets a bit cleaner.

Reviewed By: jdoerfert, JonChesterfield, tianshilei1992

Differential Revision: https://reviews.llvm.org/D113421
2021-11-09 15:11:05 -05:00
Yuanfang Chen 7562c64197 [Sema] Mark virtual method declaration in union as invalid
Currently, this is only diagnosed but the decl is not marked invalid. This may hit assertions down the path.

This also reverts the fix for PR49534 since it is not needed anymore.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D113145
2021-11-09 10:57:38 -08:00
Arthur Eubanks 1d8750c3da [NFC] Rename GVN -> GVNPass and SROA -> SROAPass
To be more consistent with other pass struct names.

There are still more passes that don't end with "Pass", but these are the important ones.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D112935
2021-11-09 10:35:58 -08:00
Aaron Puchert 196554d42d Comment parsing: Complete list of Doxygen commands
These should be all the commands from [1] except those that are marked
obsolete, and "link" / "endlink", as that conflicts with the existing
HeaderDoc pair "link / "/link". For some commands we don't have the
ideal category, but it should work good enough for most cases.

There seems to be no existing test for most commands (except the ones
interpreted by -Wdocumentation), and to some extent such a test wouldn't
look very interesting. But I added a test for the correct parsing of
formulas, as they're a bit special. And I had to adapt
comment-lots-of-unknown-commands.c because typo correction was kicking
in and recognizing some of the commands.

This should fix a couple of reported bugs: PR17437, PR19581, PR24062
(partially, no diagnostic for matching cond/endcond), PR32909, PR37813,
PR44243 (partially, email@domain.com must be addressed separately).

[1] https://www.doxygen.nl/manual/commands.html

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D111190
2021-11-09 18:35:26 +01:00
Ard Biesheuvel 24772720c5 [ARM] reject -mtp=cp15 if target subarch does not support it
Currently, we permit -mtp=cp15 even for targets that don't implement the
TLS register. When building for ARMv6 or earlier, this means we emit
instructions that will UNDEF at runtime. For Thumb1, passing -mtp=cp15
will trigger an assert in the backend.

So let's add some diagnostics to ensure that -mtp=cp15 is only accepted
for ARMv6T2 or newer.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D113026
2021-11-09 18:29:30 +01:00
Ard Biesheuvel a19da876ab [ARM] implement support for TLS register based stack protector
Implement support for loading the stack canary from a memory location held in
the TLS register, with an optional offset applied. This is used by the Linux
kernel to implement per-task stack canaries, which is impossible on SMP systems
when using a global variable for the stack canary.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D112768
2021-11-09 18:19:47 +01:00
Nathan Sidwell ae5c52b933 [clang] [docs] Fix markup
code-block needs a blank line

Differential Revision:  https://reviews.llvm.org/D113425
2021-11-09 07:40:27 -08:00
Nathan Sidwell bf6986d99e [clang] GCC directive extension extension: Hash NNN lines
Some time back I extended GCC's '# NNN' line marker semantics.
Specifically popping to a blank filename will restore the filename to
that of the popped-to include.  Restore to line 5 of including file
(escaped BOL #'s to avoid git eliding them):

\# 5 "" 2

Added documentation for this line control extension.

This was useful in developing modules tests, but turned out to also be
useful with machine-generated source code.  Specifically, a generated
include file that itself includes fragments from elsewhere.  The
ability to pop to the generated include file -- with its full path
prefix -- is useful for diagnostic & debug purposes.  For instance
something like:

// Machine generated -- DO NOT EDIT
Type Var = {
\# 7 "encoded.dsl" 1 // push to snippet-container
{snippet, of, code}
\# 6 " 2 // Restore to machined-generated source
,
};

// user-code
...
\#include "dsl.h"
...

That pop to "" will restore the filename to '..includepath../dsl.h',
which is better than restoring to plain "dsl.h".

Differential Revision: https://reviews.llvm.org/D113425
2021-11-09 07:31:03 -08:00
Kristóf Umann 8cc2de667e [analyzer][docs] Fix the incorrect structure of the checker docs
The alpha.security.cert section came right after alpha.security, making it look
like checkers like alpha.security.MmapWriteExec belonged to that package.

Differential Revision: https://reviews.llvm.org/D113397
2021-11-09 15:26:00 +01:00
David Pagan b0de656bdf Initial parsing/sema for 'align' clause
Added basic parsing/sema/serialization support for 'align' clause for use with
'allocate' directive.
2021-11-09 07:34:18 -05:00
Justas Janickas d85d57e987 Revert "[OpenCL] Allow optional __generic in __remove_address_space utility"
This reverts commit 81081daef0.
2021-11-09 09:42:17 +00:00
Carlos Galvez 7ecec3f0f5 [CUDA] Bump supported CUDA version to 11.5
Differential Revision: https://reviews.llvm.org/D113249
2021-11-09 08:20:53 +00:00
Justas Janickas 81081daef0 [OpenCL] Allow optional __generic in __remove_address_space utility
Clang builtin utility `__remove_address_space` now works if generic
address space is not supported in C++ for OpenCL 2021.

Differential Revision: https://reviews.llvm.org/D110155
2021-11-09 08:13:34 +00:00
Atmn Patel ef717f3852 Revert "[clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files"
This reverts commit 81a7cad2ff.
2021-11-09 02:10:42 -05:00
Atmn Patel 81a7cad2ff [clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files
The existing CGOpenMPRuntimeAMDGCN and CGOpenMPRuntimeNVPTX classes are
just code bloat. By removing them, the codebase gets a bit cleaner.

Reviewed By: jdoerfert, JonChesterfield, tianshilei1992

Differential Revision: https://reviews.llvm.org/D113421
2021-11-09 01:52:52 -05:00
Akira Hatanaka d61eb6c5d9 [ObjC][ARC] Use operand bundle "clang.arc.attachedcall" on x86-64
https://reviews.llvm.org/D92808 made clang use the operand bundle
instead of emitting retainRV/claimRV calls on arm64. This commit makes
changes to clang that are needed to use the operand bundle on x86-64.

Differential Revision: https://reviews.llvm.org/D111331
2021-11-08 18:38:40 -08:00
Volodymyr Sapsai 7ad693a322 [modules] Update visibility for merged ObjCProtocolDecl definitions.
Merge definition visibility the same way we do for other decls. Without
the fix the added test emits `-Wobjc-method-access` as it cannot find a
visible protocol. Make this warning `-Werror` so the test would fail
when protocol visibility regresses.

rdar://83600696

Differential Revision: https://reviews.llvm.org/D111860
2021-11-08 13:54:00 -08:00
Michael Liao bf225939bc [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.
- CUDA cannot associate memory space with pointer types. Even though Clang could add extra attributes to specify the address space explicitly on a pointer type, it breaks the portability between Clang and NVCC.
- This change proposes to assume the address space from a pointer from the assumption built upon target-specific address space predicates, such as `__isGlobal` from CUDA. E.g.,

```
  foo(float *p) {
    __builtin_assume(__isGlobal(p));
    // From there, we could assume p is a global pointer instead of a
    // generic one.
  }
```

This makes the code portable without introducing the implementation-specific features.

Note that NVCC starts to support __builtin_assume from version 11.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D112041
2021-11-08 16:51:57 -05:00
Jon Chesterfield 0fa45d6d80 Revert "[OpenMP] Lower printf to __llvm_omp_vprintf"
This reverts commit db81d8f6c4.
2021-11-08 20:28:57 +00:00
Martin Storsjö 2ca6fc34fc [clang] [DirectoryWatcher] Remove leading \\?\ from GetFinalPathNameByHandleW
This is needed for the paths to work when using forward slashes;
this fixes the DirectoryWatcherTests unit tests.

Also allocate missing space for the null terminator, which seems to
have been missing all along (writing the terminator out of bounds).

Differential Revision: https://reviews.llvm.org/D113264
2021-11-08 22:21:30 +02:00
Benjamin Kramer d398e8f170 [ASTMatcher] Provide a definition for the lambdaCapture matcher
This is an empty object, but depending on your optimizer settings the
compiler may emit a reference to the symbol.
2021-11-08 20:26:37 +01:00
James King c0b298fc21 Add `LambdaCapture`-related matchers.
This provides better support for `LambdaCapture`s by making them first-
class and allowing them to be bindable. In addition, this implements several
`LambdaCapture`-related matchers. This does not update how lambdas are
traversed. As a result, something like trying to match `lambdaCapture()` by
itself will not work - it must be used as an inner matcher.

Reviewed By: aaron.ballman, sammccall

Differential Revision: https://reviews.llvm.org/D112491
2021-11-08 18:50:54 +00:00
Jon Chesterfield db81d8f6c4 [OpenMP] Lower printf to __llvm_omp_vprintf
Extension of D112504. Lower amdgpu printf to `__llvm_omp_vprintf`
which takes the same const char*, void* arguments as cuda vprintf and also
passes the size of the void* alloca which will be needed by a non-stub
implementation of `__llvm_omp_vprintf` for amdgpu.

This removes the amdgpu link error on any printf in a target region in favour
of silently compiling code that doesn't print anything to stdout.

The exact set of changes to check-openmp probably needs revision before commit

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D112680
2021-11-08 18:38:00 +00:00
hyeongyu kim 8d3b28e754 [NFC] Fix lit test failures for clang/CodegenCoroutines 2021-11-09 02:47:16 +09:00
Michael Benfield 2db66f8d48 [clang] Fortify warning for scanf calls with field width too big.
Differential Revision: https://reviews.llvm.org/D111833
2021-11-08 17:43:51 +00:00
hyeongyu kim fd9b099906 Revert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default"
This reverts commit aacfbb953e.

Revert "Fix lit test failures in CodeGenCoroutines"

This reverts commit 63fff0f5bf.
2021-11-09 02:15:55 +09:00
Aaron Ballman 190bde404c Revert "Making the code compliant to the documentation about Floating Point"
This reverts commit 438437cbb6.

There are still broken bots from this:

https://lab.llvm.org/buildbot/#/builders/188/builds/5495
https://lab.llvm.org/buildbot/#/builders/171/builds/5710
2021-11-08 11:43:49 -05:00
Jon Chesterfield 2c37ae6d14 [nfc] Refactor CGGPUBuiltin to help review D112680 2021-11-08 15:00:08 +00:00
Quinn Pham c3b15b71ce [NFC] Inclusive Language: change master to main for .chm files
[NFC] As part of using inclusive language within the llvm project,
this patch replaces master with main when referring to `.chm` files.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D113299
2021-11-08 08:23:04 -06:00