Commit Graph

63411 Commits

Author SHA1 Message Date
Quinn Pham 3b0240e6c8 [PowerPC] Add range check for vec_genpcvm builtins
This patch adds range checking for some Power10 altivec builtins. Range
checking is done in SemaChecking.

Reviewed By: #powerpc, lei, Conanap

Differential Revision: https://reviews.llvm.org/D109780
2021-09-24 11:15:44 -05:00
Denys Petrov 98a95d4844 [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.
Summary: Fix the point that we didn't take into account array's dimension. Retrieve a value of global constant array by iterating through its initializer list.

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

Fixes: https://bugs.llvm.org/show_bug.cgi?id=50604
2021-09-24 12:37:58 +03:00
Dmitri Gribenko efb284c07e [clang-format] Fixed an unused variable warning 2021-09-24 10:37:04 +02:00
Petr Hosek 03142c5f67 [Driver] Correctly handle static C++ standard library
When statically linking C++ standard library, we shouldn't add -Bdynamic
after including the library on the link line because that might override
user settings like -static and -static-pie. Rather, we should surround
the library with --push-state/--pop-state to make sure that -Bstatic
only applies to C++ standard library and nothing else. This has been
supported since GNU ld 2.25 (2014) so backwards compatibility should
no longer be a concern.

Differential Revision: https://reviews.llvm.org/D110128
2021-09-24 00:40:16 -07:00
Albion Fung 840afbde48 [PowerPC] SemaChecking for darn family of builtins
The __darn family of builtins are only available on Pwr9,
and only __darn_32 is available on both 64 and 32 bit, while the rest
are only available on 64 bit. The patch adds sema checking
for these builtins and separate the __darn_32's 32 bit
test cases.

Differential revision: https://reviews.llvm.org/D110282
2021-09-23 23:38:59 -05:00
David Blaikie 8d9ddd4f50 DebugInfo: STN: Handle unreconstitutable types in function types 2021-09-23 21:13:16 -07:00
David Blaikie 25ac0d3c73 DebugInfo: Implement the -gsimple-template-names functionality
This excludes certain names that can't be rebuilt from the available
DWARF:

* Atomic types - no DWARF differentiating int from atomic int.
* Vector types - enough DWARF (an attribute on the array type) to do
  this, but I haven't written the extra code to add the attributes
  required for this
* Lambdas - ambiguous with any other unnamed class
* Unnamed classes/enums - would need column info for the type in
  addition to file/line number
* noexcept function types - not encoded in DWARF
2021-09-23 19:58:32 -07:00
Fangrui Song afab3c488f [Driver] Default Generic_GCC x86 to -fasynchronous-unwind-tables
to match GCC and Clang's own x86-64.
2021-09-23 19:39:50 -07:00
Fangrui Song 7647a8413b Fix -fno-unwind-tables -fasynchronous-unwind-tables to emit unwind tables
This matches GCC.

Change the CC1 option to encode the unwind table level (1: needed by exceptions,
2: asynchronous) so that we can support two modes in the future.
2021-09-23 16:15:40 -07:00
Hongtao Yu e9d1a679a1 [CSSPGO] Do not pass -fpseudo-probe-for-profiling to the linker.
The correponding linker switch has been removed by https://reviews.llvm.org/D110209, so do not pass it in clang.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D110371
2021-09-23 15:50:40 -07:00
mydeveloperday 5fcde57b73 [clang-format] NFC ensure Penality variable is passed back with Fixes
Fix set but not used warning
2021-09-23 22:05:20 +01:00
mydeveloperday a44ab17025 [clang-format] Add Left/Right Const fixer capability
Developers these days seem to argue over east vs west const like they used to argue over tabs vs whitespace or the various bracing style. These previous arguments were mainly eliminated with tools like `clang-format` that allowed those rules to become part of your style guide. Anyone who has been using clang-format in a large team over the last couple of years knows that we don't have those religious arguments any more, and code reviews are more productive.

https://www.youtube.com/watch?v=fv--IKZFVO8
https://mariusbancila.ro/blog/2018/11/23/join-the-east-const-revolution/
https://www.youtube.com/watch?v=z6s6bacI424

The purpose of this revision is to try to do the same for the East/West const discussion. Move the debate into the style guide and leave it there!

In addition to the new `ConstStyle: Right` or `ConstStyle: Left` there is an additional command-line argument `--const-style=left/right` which would allow an individual developer to switch the source back and forth to their own style for editing, and back to the committed style before commit. (you could imagine an IDE might offer such a switch)

The revision works by implementing a separate pass of the Annotated lines much like the SortIncludes and then create replacements for constant type declarations.

Differential Revision: https://reviews.llvm.org/D69764
2021-09-23 20:00:33 +01:00
Yuanfang Chen 59337263ab Revert "Diagnose -Wunused-value based on CFG reachability"
This reverts commit cbbf2e8c8a.
It seems causing diagnoses in SFINAE context.
2021-09-23 11:12:00 -07:00
Thomas Lively 2f519825ba [WebAssembly] Add prototype relaxed SIMD fma/fms instructions
Add experimental clang builtins, LLVM intrinsics, and backend definitions for
the new {f32x4,f64x2}.{fma,fms} instructions in the relaxed SIMD proposal:
https://github.com/WebAssembly/relaxed-simd/blob/main/proposals/relaxed-simd/Overview.md.
Do not allow these instructions to be selected without explicit user opt-in.

Differential Revision: https://reviews.llvm.org/D110295
2021-09-23 11:01:36 -07:00
Quinn Pham f9912fe4ea [PowerPC] Add range checks for P10 Vector Builtins
This patch adds range checking for some Power10 altivec builtins and
changes the signature of a builtin to match documentation. For `vec_cntm`,
range checking is done via SemaChecking. For `vec_splati_ins`, the second
argument is masked to extract the 0th bit so that we always receive either a `0`
or a `1`.

Reviewed By: lei, amyk

Differential Revision: https://reviews.llvm.org/D109710
2021-09-23 11:05:49 -05:00
Haojian Wu 3778c1cd6e [Sema] Fix a null pointer reference crash.
Differential Revision: https://reviews.llvm.org/D110315
2021-09-23 16:37:37 +02:00
Petr Hosek 904ca7d2ed Revert "[Driver] Correctly handle static C++ standard library"
This reverts commit 5e28c892d0 as
the linker on the clang-ppc64le-rhel bot doesn't seem to support
--push-state/--pop-state.
2021-09-23 01:13:10 -07:00
Petr Hosek 5e28c892d0 [Driver] Correctly handle static C++ standard library
When statically linking C++ standard library, we shouldn't add -Bdynamic
after including the library on the link line because that might override
user settings like -static and -static-pie. Rather, we should surround
the library with --push-state/--pop-state to make sure that -Bstatic
only applies to C++ standard library and nothing else. This has been
supported since GNU ld 2.25 (2014) so backwards compatibility should
no longer be a concern.

Differential Revision: https://reviews.llvm.org/D110128
2021-09-23 01:00:11 -07:00
Wang, Pengfei ebec077e07 [X86][FP16] Change the order of the operands in complex FMA intrinsics to allow swap between the mul operands.
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D109658
2021-09-23 11:02:48 +08:00
Shilei Tian 747b1a67a3 [NFC] Remove trailing spaces from some files 2021-09-22 18:17:40 -04:00
Zhi An Ng 1552179ac0 [WebAssembly] Add relaxed-simd feature
This currently only defines a constant, but it the future will be used
to gate builtins for experimenting and prototyping relaxed-simd proposal
(https://github.com/WebAssembly/relaxed-simd/).

Differential Revision: https://reviews.llvm.org/D110111
2021-09-22 14:52:50 -07:00
Yuanfang Chen cbbf2e8c8a Diagnose -Wunused-value based on CFG reachability
While at it, add the diagnosis message "left operand of comma operator has no effect" (used by GCC) for comma operator.

This also makes Clang diagnose in the constant evaluation context which aligns with GCC/MSVC behavior. (https://godbolt.org/z/7zxb8Tx96)

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D103938
2021-09-22 14:38:06 -07:00
Yonghong Song b875343873 [Clang] Ignore BTFTag attr if used as a type attribute
Currently, linux kernel has a __user attribute ([1]) defined as
   __attribute__((noderef, address_space(__user)))
which is used by sparse tool ([2]) to do some
type checking of pointers to user space memory.
During normal compilation, __user will be defined
to nothing so it won't have an impact on compilation.

The btf_tag attribute, which is motivated by
carrying linux kernel annotations into dwarf/BTF,
is introduced in [3]. We intended to define __user as
   __attribute__((btf_tag("user")))
so such information will be encoded in dwarf/BTF
and can be used later by bpf verification or other
tracing tools.

But linux kernel __user attribute is also used during
type conversion which btf_tag doesn't support ([4]) since
such type conversion is only used for compiler analysis
and not encoded in dwarf/btf. Theoretically, it is
possible for clang to understand these tags and
do a sparse-like type checking work. But I would like
to leave that to future work and for now suggest simply
ignore these btf_tag attributes if they are used
as type attributes.

  [1] https://github.com/torvalds/linux/blob/master/include/linux/compiler_types.h#L10
  [2] https://sparse.docs.kernel.org/en/latest/
  [3] https://reviews.llvm.org/D106614
  [4] https://github.com/torvalds/linux/blob/master/fs/binfmt_flat.c#L135

Differential Revision: https://reviews.llvm.org/D110116
2021-09-22 13:48:29 -07:00
David Blaikie 38c09ea2d2 DebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}
This is to build the foundation of a new debug info feature to use only
the base name of template as its debug info name (eg: "t1" instead of
the full "t1<int>"). The intent being that a consumer can still retrieve
all that information from the DW_TAG_template_*_parameters.

So gno-simple-template-names is business as usual/previously ("t1<int>")
   =simple is the simplified name ("t1")
   =mangled is a special mode to communicate the full information, but
   also indicate that the name should be able to be simplified. The data
   is encoded as "_STNt1|<int>" which will be matched with an
   llvm-dwarfdump --verify feature to deconstruct this name, rebuild the
   original name, and then try to rebuild the simple name via the DWARF
   tags - then compare the latter and the former to ensure that all the
   data necessary to fully rebuild the name is present.
2021-09-22 11:11:49 -07:00
Erich Keane 97b2f20a44 Change error for storage-class to mean linkage, fix lang-linkage diag
Allow multiversioning declarations to match when the actual formal
linkage matches, not just when the storage class is identical.
Additionally, change the ambiguous 'linkage' mismatch to be more
specific and say 'language linkage'.
2021-09-22 10:51:05 -07:00
Michael Benfield af99236747 Don't diagnose unused but set when the Cleanup attribute is used.
This applies to -Wunused-but-set-variable and
-Wunused-but-set-parameter.

This addresses bug 51865.

Differential Revision: https://reviews.llvm.org/D109862
2021-09-22 17:48:09 +00:00
Hongtao Yu d9b511d8e8 [CSSPGO] Set PseudoProbeInserter as a default pass.
Currenlty PseudoProbeInserter is a pass conditioned on a target switch. It works well with a single clang invocation. It doesn't work so well when the backend is called separately (i.e, through the linker or llc), where user has always to pass -pseudo-probe-for-profiling explictly. I'm making the pass a default pass that requires no command line arg to trigger, but will be actually run depending on whether the CU comes with `llvm.pseudo_probe_desc` metadata.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D110209
2021-09-22 09:09:48 -07:00
Shilei Tian ca999f7191 [OpenMP][Offloading] Use bitset to indicate execution mode instead of value
The execution mode of a kernel is stored in a global variable, whose value means:
- 0 - SPMD mode
- 1 - indicates generic mode
- 2 - SPMD mode execution with generic mode semantics

We are going to add support for SIMD execution mode. It will be come with another
execution mode, such as SIMD-generic mode. As a result, this value-based indicator
is not flexible.

This patch changes to bitset based solution to encode execution mode. Each
position is:
[0] - generic mode
[1] - SPMD mode
[2] - SIMD mode (will be added later)

In this way, `0x1` is generic mode, `0x2` is SPMD mode, and `0x3` is SPMD mode
execution with generic mode semantics. In the future after we add the support for
SIMD mode, `0b1xx` will be in SIMD mode.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D110029
2021-09-22 11:40:52 -04:00
Florian Hahn ea21d688dc
[Matrix] Emit assumption that matrix indices are valid.
The matrix extension requires the indices for matrix subscript
expression to be valid and it is UB otherwise.

extract/insertelement produce poison if the index is invalid, which
limits the optimizer to not be bale to scalarize load/extract pairs for
example, which causes very suboptimal code to be generated when using
matrix subscript expressions with variable indices for large matrixes.

This patch updates IRGen to emit assumes to for index expression to
convey the information that the index must be valid.

This also adjusts the order in which operations are emitted slightly, so
indices & assumes are added before the load of the matrix value.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D102478
2021-09-22 12:27:37 +01:00
Balázs Kéri 7ce638538b [clang][ASTImporter] Generic attribute import handling (first step).
Import of Attr objects was incomplete in ASTImporter.
This change introduces support for a generic way of importing an attribute.
For an usage example import of the attribute AssertCapability is
added to ASTImporter.
Updating the old attribute import code and adding new attributes or extending
the generic functions (if needed) is future work.

Reviewed By: steakhal, martong

Differential Revision: https://reviews.llvm.org/D109608
2021-09-22 10:14:03 +02:00
David Blaikie 2ff049b12e DebugInfo: Don't use preferred template names in debug info
Using the preferred name creates a mismatch between the textual name of
a type and the DWARF tags describing the parameters as well as possible
inconsistency between DWARF producers (like Clang and GCC, or
older/newer Clang versions, etc).
2021-09-21 20:08:16 -07:00
David Blaikie db6f1e8a88 DebugInfo: Don't suppress inline namespaces when printing template template parameter names 2021-09-21 19:30:13 -07:00
David Blaikie d31dfc3011 DebugInfo: Unify some printing policy adjustments 2021-09-21 19:30:12 -07:00
Arthur Eubanks e1ed02181f [clang] Make -Rpass imply -Rpass=.*
Previously with -Rpass (and friends) we'd have remarks "enabled", but
without an actual regex.

As seen in the test change to line numbers, this can give us better
diagnostics by properly enabling NeedLocTracking with -Rpass.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D110201
2021-09-21 14:35:56 -07:00
Albion Fung b93359ea3f [PowerPC] Support for vector bool int128 on vector comparison builtins
This patch implements support for the type vector bool int128
for arguments on vector comparison builtins listed below,
which would otherwise crash due to ambiguity.

The following builtins are added:

vec_all_eq (vector bool __int128, vector bool __int128)
vec_all_ne (vector bool __int128, vector bool __int128)
vec_any_eq (vector bool __int128, vector bool __int128)
vec_any_ne (vector bool __int128, vector bool __int128)
vec_cmpne(vector bool __int128 a, vector bool __int128 b)
vec_cmpeq(vector bool __int128 a, vector bool __int128 b)

Differential revision: https://reviews.llvm.org/D110084
2021-09-21 16:29:37 -05:00
Giorgis Georgakoudis ac90dfc43a Revert "[OpenMP] Codegen aggregate for outlined function captures"
This reverts commit 1d66649adf.

Revert to fix AMG GPU issue.
2021-09-21 13:20:39 -07:00
Matheus Izvekov d9308aa39b [clang] don't mark as Elidable CXXConstruct expressions used in NRVO
See PR51862.

The consumers of the Elidable flag in CXXConstructExpr assume that
an elidable construction just goes through a single copy/move construction,
so that the source object is immediately passed as an argument and is the same
type as the parameter itself.

With the implementation of P2266 and after some adjustments to the
implementation of P1825, we started (correctly, as per standard)
allowing more cases where the copy initialization goes through
user defined conversions.

With this patch we stop using this flag in NRVO contexts, to preserve code
that relies on that assumption.
This causes no known functional changes, we just stop firing some asserts
in a cople of included test cases.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D109800
2021-09-21 21:41:20 +02:00
David Blaikie 131e878664 Print nullptr_t namespace qualified within std::
This improves diagnostic (& important to me, DWARF) accuracy - otherwise
there could be ambiguities between "std::nullptr_t" and some user-defined
type that's /actually/ "nullptr_t" defined in the global namespace.

Differential Revision: https://reviews.llvm.org/D110044
2021-09-21 11:21:40 -07:00
Giorgis Georgakoudis 1d66649adf [OpenMP] Codegen aggregate for outlined function captures
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3)  forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call.

Reviewed By: jdoerfert, jhuber6

Differential Revision: https://reviews.llvm.org/D102107
2021-09-21 10:50:04 -07:00
Aaron Ballman 73a8bcd789 Revert "Diagnose -Wunused-value based on CFG reachability"
This reverts commit 63e0d038fc.

It causes test failures:

http://lab.llvm.org:8011/#/builders/119/builds/5612
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8835548361443044001/+/u/clang/test/stdout
2021-09-21 12:25:13 -04:00
Andy Wingo 9ae4275557 [clang][NFC] Fix needless double-parenthisation
Strip a layer of parentheses in TreeTransform::RebuildQualifiedType.

Differential Revision: https://reviews.llvm.org/D108359
2021-09-21 17:03:23 +02:00
Chris Bieneman 744ec74b30 [NFC] `goto fail` has failed us in the past...
This patch replaces reliance on `goto failure` pattern with
`llvm::scope_exit`.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D109865
2021-09-21 09:18:37 -05:00
Justas Janickas 32b994bca6 [OpenCL] Defines helper function for OpenCL default address space
Helper function `getDefaultOpenCLPointeeAddrSpace()` introduced to
`ASTContext` class. It returns default OpenCL address space
depending on language version and enabled features. If generic
address space is supported, the helper function returns value
`LangAS::opencl_generic`. Otherwise, value `LangAS::opencl_private`
is returned. Code refactoring changes performed in several suitable
places.

Differential Revision: https://reviews.llvm.org/D109874
2021-09-21 15:12:08 +01:00
Nico Weber 60ab6861ed [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
Nico Weber bde305baf6 [clang] Fix a few comment more typos to cycle bots 2021-09-20 19:42:49 -04:00
Nico Weber f119170579 [clang] Fix a few comment typos to cycle bots 2021-09-20 18:48:34 -04:00
Saleem Abdulrasool 96d3319d6f Sema: relax va_start checking further for Windows AArch64
When building in C mode, the VC runtime assumes that it can use pointer
aliasing through `char *` for the parameter to `__va_start`.  Relax the
checks further.  In theory we could keep the tests strict for non-system
header code, but this takes the less strict approach as the additional
check doesn't particularly end up being too much more helpful for
correctness.  The C++ type system is a bit stricter and requires the
explicit cast which we continue to verify.
2021-09-20 21:23:33 +00:00
Nico Weber 9197834535 Revert "Fix CLANG_ENABLE_STATIC_ANALYZER=OFF building all analyzer source"
This reverts commit 6d7b3d6b3a.
Breaks running cmake with `-DCLANG_ENABLE_STATIC_ANALYZER=OFF`
without turning off CLANG_TIDY_ENABLE_STATIC_ANALYZER.
See comments on https://reviews.llvm.org/D109611 for details.
2021-09-20 16:18:03 -04:00
Yuanfang Chen 63e0d038fc Diagnose -Wunused-value based on CFG reachability
While at it, add the diagnosis message "left operand of comma operator has no effect" (used by GCC) for comma operator.

This also makes Clang diagnose in the constant evaluation context which aligns with GCC/MSVC behavior. (https://godbolt.org/z/7zxb8Tx96)

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D103938
2021-09-20 10:43:34 -07:00
Fangrui Song a07727199d Revert code change of D63497 & D74399 for riscv64-*-linux GCC detection
This partially reverts commits 1fc2a47f0b and 9816e726e7.

See D109727. Replacing config.guess in favor of {gcc,clang} -dumpmachine
can avoid the riscv64-{redhat,suse}-linux GCC detection.

Acked-by: Luís Marques <luismarques@lowrisc.org>
2021-09-20 10:28:32 -07:00