Commit Graph

33067 Commits

Author SHA1 Message Date
Fangrui Song
dd85c6cce4 [Sema] Add -Wc++11-narrowing-const-reference (#76094)
https://github.com/llvm/llvm-project/pull/75332 diagnosed narrowing
involving const reference. Our depot has hundreds if not thousands of
breakages

(https://github.com/llvm/llvm-project/pull/75332#issuecomment-1864757240).
Add a subgroup of -Wc++11-narrowing to help users gradually fix their
issues without regressing the existing -Wc++11-narrowing diagnostics.
2023-12-22 11:28:07 -05:00
Abhina Sree
d430c145ba [CMake] Move check for dlfcn.h and dladdr to clang (#76163)
This patch checks for the presence of dlfcn.h and dladdr in clang to be used in clang/tools/libclang/CIndexer.cpp
2023-12-22 08:12:19 -05:00
Dinar Temirbulatov
809f2f3d7d [AArch64][SME2] Add builtins for FDOT, BFDOT, SUDOT, USDOT, SDOT, UDOT. (#75737)
Add SME2 DOT builtins.
2023-12-21 19:41:24 +00:00
Tomas Matheson
7bd17212ef Re-land "[AArch64] Codegen support for FEAT_PAuthLR" (#75947)
This reverts commit 9f0f558742.

Fix expensive checks failure by properly marking register def for ADR.
2023-12-21 18:32:55 +00:00
Dinar Temirbulatov
77c5c44b01 [AArch64][SME2] Add SME2 MLA/MLS builtins. (#75584)
Add SME2 MLA/MLS builtins.
2023-12-21 16:42:24 +00:00
Tomas Matheson
9f0f558742 Revert "[AArch64] Codegen support for FEAT_PAuthLR"
This reverts commit 5992ce90b8.

Builtbot failures with expensive checks enabled.
2023-12-21 16:25:55 +00:00
Kerry McLaughlin
35111695dd [Clang][SME2] Enable multi-vector loads & stores for SME2 (#75821)
This patch enables the following builtins for SME2:
 - svld1, svld1_vnum
 - svldnt1, svldnt1_vnum
 - svst1, svst1_vnum
 - svstnt1, svstnt1_vnum
2023-12-21 15:25:23 +00:00
Radu Salavat
3107f313f1 [Flang, Clang] Enable and test 'rdynamic' flag (#75598)
Enable and test 'rdynamic' flag
2023-12-21 14:37:51 +00:00
Tomas Matheson
5992ce90b8 [AArch64] Codegen support for FEAT_PAuthLR
- Adds a new +pc option to -mbranch-protection that will enable
  the use of PC as a diversifier in PAC branch protection code.

- When +pauth-lr is enabled (-march=armv9.5a+pauth-lr) in combination
  with -mbranch-protection=pac-ret+pc, the new 9.5-a instructions
  (pacibsppc, retaasppc, etc) are used.

Documentation for the relevant instructions can be found here:
https://developer.arm.com/documentation/ddi0602/2023-09/Base-Instructions/

Co-authored-by: Lucas Prates <lucas.prates@arm.com>
2023-12-21 14:18:33 +00:00
Kerry McLaughlin
a047675bbf [Clang][SME2] Add builtins for multi-vector fp round to integral value (#75941)
Adds the following SME2 builtins:
 - svrinta, svrintm, svrintn, svrintp (x2 & x4)
2023-12-21 12:08:47 +00:00
martinboehme
469374e5c4 [clang][dataflow] Disallow setting properties on RecordValues. (#76042)
Instead, synthetic fields should now be used for the same purpose. These
have a
number of advantages, as described in
https://github.com/llvm/llvm-project/pull/73860, and longer-term, we
want to
eliminate `RecordValue` entirely.

As `RecordValue`s cannot have properties any more, I have replaced the
`OptionalIntAnalysis` with an equivalent analysis that tracks nullness
of
pointers (instead of whether an optional has a value). This serves the
same
purpose, namely to check whether the framework applies a custom
`merge()`
operation to widen properties.
2023-12-21 09:21:24 +01:00
martinboehme
2ee396b0b1 [clang][dataflow] Add Environment::get<>(). (#76027)
This template function casts the result of `getValue()` or
`getStorageLocation()` to a given subclass of `Value` or
`StorageLocation` (using `cast_or_null`).

It's a common pattern to do something like this:

```cxx
auto *Val = cast_or_null<PointerValue>(Env.getValue(E));
```

This can now be expressed more concisely like this:

```cxx
auto *Val = Env.get<PointerValue>(E);
```

Instead of adding a new method `get()`, I had originally considered
simply adding a template parameter to `getValue()` and
`getStorageLocation()` (with a default argument of `Value` or
`StorageLocation`), but this results in an undesirable repetition at the
callsite, e.g. `getStorageLocation<RecordStorageLocation>(...)`. The
`Value` and `StorageLocation` in the method name adds nothing of value
when the template argument already contains this information, so it
seemed best to shorten the method name to simply `get()`.
2023-12-21 09:02:20 +01:00
Chuanqi Xu
565e5e861f Recommit [NFC] [Serialization] Packing more bits and refactor AbbrevToUse
This patch tries to pack more bits into a value to reduce the size of
.pcm files. Also, after we introduced BitsPackers, it may slightly
better to adjust the way we use Abbrev.

After this patch, the size of the BMI for std module reduce from 28.94MB
to 28.1 MB.

This was reverted due to it broke the build of lldb. The reason that we
skip the serialization of a source location incorrectly. And this patch
now fixes that.
2023-12-21 10:30:12 +08:00
Dimitry Andric
2c27013fa9 [clang] Add getClangVendor() and use it in CodeGenModule.cpp (#75935)
In 9a38a72f1d `ProductId` was assigned from the stringified value of
`CLANG_VENDOR`, if that macro was defined. However, `CLANG_VENDOR` is
supposed to be a string, as it is defined (optionally) as such in the
top-level clang `CMakeLists.txt`.

Furthermore, `CLANG_VENDOR` is only passed as a build-time define when
compiling `Version.cpp`, so add a `getClangVendor()` function to
`Version.h`, and use it in `CodegGenModule.cpp`, instead of relying on
the macro.

Fixes: 9a38a72f1d
2023-12-20 20:09:39 +01:00
Dimitry Andric
5c1a41f8ad Revert "[clang] Add getClangVendor() and use it in CodeGenModule.cpp (#75935)"
This reverts commit 9055519103, due to an
incorrectly chosen commit message.
2023-12-20 20:07:22 +01:00
Dimitry Andric
9055519103 [clang] Add getClangVendor() and use it in CodeGenModule.cpp (#75935)
In 9a38a72f1d `ProductId` was assigned from the stringified value of
`CLANG_VENDOR`, if that macro was defined. However, `CLANG_VENDOR` is
supposed to be a string, as it is defined (optionally) as such in the
top-level clang `CMakeLists.txt`.

Move the addition of `-DCLANG_VENDOR` to the compiler flags from
`clang/lib/Basic/CMakeLists.txt` to the top-level `CMakeLists.txt`, so
it is consistent across the whole clang codebase. Then remove the
stringification from `CodeGenModule.cpp`, to make it work correctly.

Fixes:		9a38a72f1d
2023-12-20 20:03:19 +01:00
Momchil Velikov
52820bdd68 [AArch64] Update target feature requirements of SVE bfloat instructions (#75596)
According to the latest update of the ISA
https://developer.arm.com/documentation/ddi0602/2023-09/?lang=en all of
the affected instruction encodings now require

    (FEAT_SVE2 or FEAT_SME2) and FEAT_SVE_B16B16
2023-12-20 10:16:40 +00:00
Haojian Wu
3b1f06e527 [AST] RecursiveASTVisitor: traverse the require clause for partial template specializations. (#75795)
This fixes tooling (clangd, include-cleaner) bugs where we miss
functionalities on concept AST nodes.
2023-12-20 10:08:43 +01:00
Fred Fu
35b366ace7 [ClangRepl] Reland Semanic Code Completion (#75556)
This patch contains changes from
002d471a4a, in
addition to a bug fix that added a virtual destructor to
`CompletionContextHandler`

The original changes in the orginal commit piggybacks on clang's
semantic modules to enable semantic completion.  In particular, we use
`CodeCompletionContext` to differentiate two types of code completion.
We also
extract the relevant type information from it.
2023-12-19 22:53:02 +02:00
Kerry McLaughlin
e9af57dfea [Clang][SME2] Add builtins for moving multi-vectors to/from ZA (#71191)
Adds the following SME2 builtins:
 - svread_hor/ver,
 - svwrite_hor/ver,
 - svread_za64,
 - svwrite_za64

See https://github.com/ARM-software/acle/pull/217
2023-12-19 13:51:10 +00:00
Haojian Wu
32aa7d823c [clang] Fix CTAD not work for C++ explicit type conversion (functional annotation). (#75779)
This fixes https://github.com/llvm/llvm-project/issues/64347.

The CTAD for an aggregate class is missing to handle the explicit type
conversion case, e.g. `TemplateFooClass(1, 2);`. Per C++ expr.type.conv
p1, the deduced type is the return type of the deduction guide selected
by the CTAD for the reminder.

In the deduction implementation
`DeduceTemplateSpecializationFromInitializer`, the parenthesized
express-list case relies on the `ParenListExpr` parameter (default is
nullptr), the AST `ParenListExpr` node is not built for all variant
initializer cases (`BuildCXXTypeConstructorExpr`, `BuildCXXNew` etc),
thus the deduction doesn't perform for these cases. This patch fixes it
by removing the `ParenListExpr` and using the `Inits` instead (which
also simplifies the interface and implementation).
2023-12-19 14:35:37 +01:00
Timm Bäder
17fa04e32f [clang][AST][NFC] Make declarationReplaces()'s first parameter const
And const qualify some local variables
2023-12-19 10:19:52 +01:00
Eric Biggers
09058654f6 [RISCV] Remove experimental from Vector Crypto extensions (#74213)
The RISC-V vector crypto extensions have been ratified. This patch
updates the Clang and LLVM support for these extensions to be
non-experimental, while leaving the C intrinsics as experimental since
the C intrinsics are not yet standardized.

Co-authored-by: Brandon Wu <brandon.wu@sifive.com>
2023-12-18 22:04:22 -08:00
Erich Keane
fdee0a35d9 [OpenACC] Add 'clause' parsing infrastructure plus a few clauses (#75052)
As we've now finished parsing the constructs, we're moving onto
implementing 'clause' parsing. While some are complicated and require
their own patch, the handful added here are simple to parse (that is,
    they are a single identifier).

This patch adds the infrastructure to parse these and a clause-list in
its entirety. This adds some complication to how we are diagnosing
parsing errors elsewhere, so a few changes were made to better recover
from errors.
2023-12-18 18:53:37 -08:00
Bill Wendling
cca4d6cfd2 Revert counted_by attribute feature (#75857)
There are many issues that popped up with the counted_by feature. The
patch #73730 has grown too large and approval is blocking Linux testing.

Includes reverts of:
commit 769bc11f68 ("[Clang] Implement the 'counted_by' attribute
(#68750)")
commit bc09ec6962 ("[CodeGen] Revamp counted_by calculations
(#70606)")
commit 1a09cfb2f3 ("[Clang] counted_by attr can apply only to C99
flexible array members (#72347)")
commit a76adfb992 ("[NFC][Clang] Refactor code to calculate flexible
array member size (#72790)")
commit d8447c78ab ("[Clang] Correct handling of negative and
out-of-bounds indices (#71877)")
Partial commit b31cd07de5 ("[Clang] Regenerate test checks (NFC)")

Closes #73168
Closes #75173
2023-12-18 15:16:09 -08:00
Ziqing Luo
4123b95949 [-Wunsafe-buffer-usage] Add a subgroup -Wunsafe-buffer-usage-in-container (#75665)
Add a sub diagnostic group under `-Wunsafe-buffer-usage` controlled by
`-Wunsafe-buffer-usage-in-container`. The subgroup will include warnings
on misuses of `std::span`, `std::vector`, and `std::array`.
2023-12-18 10:39:15 -08:00
Sam Tebbs
fade67565e [AArch64][SME2] Enable bfm builtins for sme2 (#71927)
This patch enables the following builtins for SME2
    svbfmlslb_f32
    svbfmlslb_lane_f32
    svbfmlslt_f32
    svbfmlslt_lane_f32

Patch by: Kerry McLaughlin <kerry.mclaughlin@arm.com>

---------

Co-authored-by: Matthew Devereau <matthew.devereau@arm.com>
2023-12-18 16:51:10 +00:00
Momchil Velikov
35a77fc13c [Clang][SVE2.1] Update names of the svwhileXX builtins with predicate-as-counter (#75200)
The `_s64`/`_u64` part can be omitted now and the name variants do not
include unsigned comparison mnemonics. Both are inferred from
the argument types.
2023-12-18 16:49:59 +00:00
Kerry McLaughlin
f888e739d3 [Clang][SME2] Add multi-vector zip & unzip builtins (#74841)
Adds the following SME2 builtins:
 - svzip (x2 & x4)
 - svzipq (x2 & x4)
 - svuzp (x2 & x4)
 - svuzpq (x2 & x4)

See https://github.com/ARM-software/acle/pull/217/files

Patch by David Sherwood <david.sherwood@arm.com>
2023-12-18 16:38:36 +00:00
Sam Tebbs
a0a3c793d2 [Clang][SME] Warn when a function doesn't have ZA state (#75805)
This patch adds a warning that's emitted when a builtin call uses ZA
state but the calling function doesn't provide any.

Patch by David Sherwood <david.sherwood@arm.com>.
2023-12-18 16:14:25 +00:00
Momchil Velikov
fd527def7e [Clang][SVE2.1] Add floating-point variants of svrevd_XX (#75117) 2023-12-18 15:52:28 +00:00
Shilei Tian
0f5eef1fb3 [OpenMP][Clang] Force use of num_teams and thread_limit for bare kernel (#68373)
This patch makes `num_teams` and `thread_limit` mandatory for bare
kernels,
similar to a reguar kernel language that when launching a kernel, the
grid size
has to be set explicitly.
2023-12-18 10:29:26 -05:00
Momchil Velikov
1faa1cd02d [Clang][SVE2.1] Add intrinsics for WHILEcc resulting in predicate pair (#75107)
Add intrinsics of the form:

    svboolx2_t svwhile<cond>_b{8,16,32,64}_[{s,u}64]_x2([u]int64_t, [u]int64_t);

and their overloaded variants as specified in
https://github.com/ARM-software/acle/pull/257
2023-12-18 11:03:39 +00:00
Sam Tebbs
945c645acb [AArch64][SME] Warn when using a streaming builtin from a non-streaming function (#75487)
This PR adds a warning that's emitted when a non-streaming or
non-streaming-compatible builtin is called in an unsuitable function.

Uses work by Kerry McLaughlin.

This is a re-upload of #74064 and fixes a compile time increase.
2023-12-18 09:32:34 +00:00
martinboehme
ca1034341c [clang][dataflow] Fix an issue with Environment::getResultObjectLocation(). (#75483)
So far, if there was a chain of record type prvalues,
`getResultObjectLocation()` would assign a different result object
location to
each one. This makes no sense, of course, as all of these prvalues end
up
initializing the same result object.

This patch fixes this by propagating storage locations up through the
entire
chain of prvalues.

The new implementation also has the desirable effect of making it
possible to
make `getResultObjectLocation()` const, which seems appropriate given
that,
logically, it is just an accessor.
2023-12-18 09:10:03 +01:00
Dinar Temirbulatov
50f5b5a80b [AArch64][SME2] Add FCLAMP, CNTP builtins for SME2 (#72487)
This change enables FCLAMP, CNTP builtins for SME2 target.
2023-12-16 12:03:54 +00:00
smanna12
7a0fd97ac1 [NFC][CLANG] Rename duplicate loop attributes diagnostic functions (#75657)
This patch renames CheckForDuplicateCodeAlignAttrs() to
CheckForDuplicateLoopAttrs() and corresponding other functions that call
it to be used for other statement attributes in future.
2023-12-15 22:09:19 -06:00
Fangrui Song
9950bb9944 [ASTReader] Fix readability-inconsistent-declaration-parameter-name. NFC 2023-12-15 17:11:21 -08:00
Augusto Noronha
eccc1cca71 Revert "[NFC] [Serialization] Packing more bits and refactor AbbrevToUse"
This reverts commit 9cdb825a4f.
2023-12-15 14:43:25 -08:00
Augusto Noronha
87bd71efd0 Revert "[NFC] Fix the warning Wcovered-switch-default"
This reverts commit e55bda06dc.
2023-12-15 14:43:25 -08:00
Phoebe Wang
f5e48fed04 [X86][AVX10] Allow 64-bit mask register used without EVEX512 (#75571)
This is to reflect new document change that 64-bit mask is support by
AVX10 256-bit targets.

Latest documents can be found in:
https://cdrdv2.intel.com/v1/dl/getContent/784267
https://cdrdv2.intel.com/v1/dl/getContent/784343
2023-12-15 20:41:42 +08:00
Ulrich Weigand
a65ccc1b9f [SystemZ] Support i128 as legal type in VRs (#74625)
On processors supporting vector registers and SIMD instructions, enable
i128 as legal type in VRs. This allows many operations to be implemented
via native instructions directly in VRs (including add, subtract,
logical operations and shifts). For a few other operations (e.g.
multiply and divide, as well as atomic operations), we need to move the
i128 value back to a GPR pair to use the corresponding instruction
there. Overall, this is still beneficial.

The patch includes the following LLVM changes:
- Enable i128 as legal type
- Set up legal operations (in SystemZInstrVector.td)
- Custom expansion for i128 add/subtract with carry
- Custom expansion for i128 comparisons and selects
- Support for moving i128 to/from GPR pairs when required
- Handle 128-bit integer constant values everywhere
- Use i128 as intrinsic operand type where appropriate
- Updated and new test cases

In addition, clang builtins are updated to reflect the intrinsic operand
type changes (which also improves compatibility with GCC).
2023-12-15 12:55:15 +01:00
CarolineConcatto
77c40ea3d2 [Clang][AArch64]Add QCVTN builtin to SVE2.1 (#75454)
``` c
   // All the intrinsics below are [SVE2.1 or SME2]
   // Variants are also available for _u16[_s32]_x2 and _u16[_u32]_x2
   svint16_t svqcvtn_s16[_s32_x2](svint32x2_t zn);
   ```

According to PR#257[1]

[1]https://github.com/ARM-software/acle/pull/257
2023-12-15 11:42:00 +00:00
Mariusz Sikora
966416b9e8 [AMDGPU][GFX12] Add new v_permlane16 variants (#75475) 2023-12-15 10:14:38 +01:00
Chuanqi Xu
e55bda06dc [NFC] Fix the warning Wcovered-switch-default
There is a warning saying:

ASTWriter.h:766:5: error: default label in switch which covers all
enumeration values [-Werror,-Wcovered-switch-default]
  766 |     default:
      |     ^
1 error generated.

And this patch tries to fix this.
2023-12-15 11:39:20 +08:00
Chuanqi Xu
9cdb825a4f [NFC] [Serialization] Packing more bits and refactor AbbrevToUse
This patch tries to pack more bits into a value to reduce the size of
.pcm files. Also, after we introduced BitsPackers, it may slightly
better to adjust the way we use Abbrev.

After this patch, the size of the BMI for std module reduce from 28.94MB
to 28.1 MB.
2023-12-15 11:12:52 +08:00
Fangrui Song
57f42a8765 Revert "[clang] Substitute alias templates from correct context (#75069)"
This reverts commit dbf67ea1d3.

It caused spurious "out-of-line definition of 'operator=' does not match
any declaration in" error.
https://github.com/llvm/llvm-project/pull/75069#issuecomment-1856581259
2023-12-14 14:57:15 -08:00
Michael Spencer
a171d248ca [clang][modules] Deprecate module.map in favor of module.modulemap (#75142)
This patch deprecates `module.map` in favor of `module.modulemap`, which
has been the preferred form since 2014. The eventual goal is to remove
support for `module.map` to reduce the number of stats Clang needs to do
while searching for module map files.

This patch touches a lot of files, but the majority of them are just
renaming tests or references to the file in comments or documentation.

The relevant files are:
* lib/Lex/HeaderSearch.cpp
* include/clang/Basic/DiagnosticGroups.td
* include/clang/Basic/DiagnosticLexKinds.td
2023-12-14 14:03:57 -08:00
Jon Roelofs
6c12fd9154 [clang] Function Multi Versioning supports IFunc lowerings on Darwin platforms (#73688) 2023-12-14 14:57:00 -07:00
Jon Roelofs
acf9aa3c22 [clang] Support __attribute__((ifunc(...))) on Darwin platforms
Unlike ELF targets, MachO does not support the same kind of dynamic symbol
resolution at load time.  Instead, the corresponding MachO feature resolves
symbols lazily on first call.

Reviewers:
JDevlieghere, dmpolukhin, ahmedbougacha, tahonermann, echristo, MaskRay, erichkeane

Reviewed By: MaskRay, echristo, ahmedbougacha

Pull Request: https://github.com/llvm/llvm-project/pull/73687
2023-12-14 14:52:35 -07:00