2135 Commits

Author SHA1 Message Date
Corentin Jabot
28ed57eda8
[Clang] Initial support for P2841 (Variable template and concept template parameters) (#150823)
This is a first pass at implementing
[P2841R7](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2841r7.pdf).

The implementation is far from complete; however, I'm aiming to do that
in chunks, to make our lives easier.

In particular, this does not implement
 - Subsumption
 - Mangling
- Satisfaction checking is minimal as we should focus on #141776 first
(note that I'm currently very stuck)

FTM, release notes, status page, etc, will be updated once the feature
is more mature. Given the state of the feature, it is not yet allowed in
older language modes.

Of note: 
- Mismatches between template template arguments and template template
parameters are a bit wonky. This is addressed by #130603
- We use `UnresolvedLookupExpr` to model template-id. While this is
pre-existing, I have been wondering if we want to introduce a different
OverloadExpr subclass for that. I did not make the change in this patch.
2025-08-04 08:51:22 +02:00
Amina Chabane
62744f3681
[AArch64][NEON] NEON intrinsic compilation error with -fno-lax-vector-conversion flag fix (#149329)
Issue originally raised in
https://github.com/llvm/llvm-project/issues/71362#issuecomment-3028515618.
Certain NEON intrinsics that operate on poly types (e.g. poly8x8_t)
failed to compile with the -fno-lax-vector-conversions flag. This patch
updates NeonEmitter.cpp to insert an explicit __builtin_bit_cast from
poly types to the required signed integer vector types when generating
lane-related intrinsics. A test 'neon-bitcast-poly.ll' is included.
2025-07-30 10:56:14 +01:00
Jon Roelofs
a0fcb50bf9
[ARM] Improve arm_neon.h header diagnostic when included on unsupported targets (#147817)
The footgun here was that the preprocessor diagnostic that looks for
__ARM_FP would fire when included on targets like x86_64, but the
suggestion it gives in that case is totally bogus. Avoid giving bad
advice, by first checking whether we're being built for an appropriate
target, and only then do the soft-fp check.

rdar://155449666
2025-07-11 10:21:13 -07:00
Paul Walker
e4d00683c3
[Clang][SME] Refactor checkArmStreamingBuiltin. (#145941)
Rather than filtering the calling function's features the PR splits the
builtin guard into distinct non-streaming and streaming guards that are
compared to the active features in full.
2025-07-08 13:55:22 +01:00
Kazu Hirata
f4b938b7c0
[TableGen] Use range-based for loops (NFC) (#146626) 2025-07-01 22:50:11 -07:00
Kazu Hirata
31122446c9
[clang] Use llvm::is_contained instead of llvm::all_of (NFC) (#145843)
llvm::is_contained is shorter than llvm::all_of plus a lambda.
2025-06-26 08:41:10 -07:00
Kazu Hirata
dc058a3d84
[TableGen] Use ListSeparator (NFC) (#144936)
Note that an instance of ListSeparator evaluates to the empty string
for the first time and then ", " for subsequent references.
2025-06-19 13:17:23 -07:00
Aaron Ballman
4f7b5e6d83 Fix a tablegen pattern that results in a warning; NFC
We were generating `1 || 1` which caused some issues for -Werror builds
2025-06-16 07:51:25 -04:00
Kazu Hirata
fef5df9d84
[TableGen] Use range-based for loops (NFC) (#144250) 2025-06-15 10:32:37 -07:00
Shafik Yaghmour
f39f53e569
[Clang][NFC] Move HeadingAndSpellings to avoid copying (#143611)
Static analysis flagged that we could move HeadingAndSpellings and avoid
a copy of a large object.
2025-06-11 14:11:19 -07:00
Brandon Wu
9312d5beb3
[llvm][RISCV] Handle required features of intrinsic correctly (#143062)
Current approach generates intrinsic records when users specify
corresponding required features by using command line option.
However it's not able to handle features passed by using target
attributes correctly where each function might have different
features.
This patch resolves this by generating all of intrinsic records which
carry the required features in their function declaration using
attribute and check the required extensions in CheckBuiltinFunctionCall.

This should fix
[56592](https://github.com/llvm/llvm-project/issues/56592),
[134962](https://github.com/llvm/llvm-project/issues/134962) and
[121603](https://github.com/llvm/llvm-project/issues/121603)
2025-06-10 15:59:15 +08:00
Nick Sarnie
339797d75b
[clang][analyzer] Update python dependency versions (#143433)
We need to make sure we aren't vulnerable to
[PYSEC-2020-73](https://osv.dev/vulnerability/PYSEC-2020-73) and
[PYSEC-2019-41](https://osv.dev/vulnerability/PYSEC-2019-41).

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-06-09 21:25:58 +00:00
Konrad Kleine
7db847df55
Filter out configuration file from compile commands (#131099)
The commands to run the compilation when printed with `-###` contain
various irrelevant lines for the perf-training. Most of them are
filtered out already but when configured with
`CLANG_CONFIG_FILE_SYSTEM_DIR` a new line like the following is
added and needs to be filtered out:

`Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg`
2025-06-06 21:08:56 +02:00
Jim Lin
dfbb9a0e30
[RISCV] Implement intrinsics for XAndesVDot (#141441)
This patch implements clang intrinsic support for XAndesVDot.

The document for the intrinsics can be found at:

https://github.com/andestech/andes-vector-intrinsic-doc/blob/ast-v5_4_0-release-v5/auto-generated/andes-v5/intrinsic_funcs.adoc#andes-vector-dot-product-extensionxandesvdot
and with policy variants
https://github.com/andestech/andes-vector-intrinsic-doc/blob/ast-v5_4_0-release-v5/auto-generated/andes-v5/policy_funcs/intrinsic_funcs.adoc#andes-vector-dot-product-extensionxandesvdot

Co-authored-by: Tony Chuan-Yue Yuan <yuan593@andestech.com>
2025-05-31 14:12:01 +08:00
Kazu Hirata
f3b404be97 [TableGen] Fix a warning
This patch fixes:

  clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp:25:8: error:
  'llvm::StringSet' may not intend to support class template argument
  deduction [-Werror,-Wctad-maybe-unsupported]
2025-05-27 09:08:45 -07:00
Cassandra Beckley
5a4571133a
[HLSL] Implement SpirvType and SpirvOpaqueType (#134034)
This implements the design proposed by [Representing SpirvType in
Clang's Type System](https://github.com/llvm/wg-hlsl/pull/181). It
creates `HLSLInlineSpirvType` as a new `Type` subclass, and
`__hlsl_spirv_type` as a new builtin type template to create such a
type.

This new type is lowered to the `spirv.Type` target extension type, as
described in [Target Extension Types for Inline SPIR-V and Decorated
Types](https://github.com/llvm/wg-hlsl/blob/main/proposals/0017-inline-spirv-and-decorated-types.md).
2025-05-27 11:40:54 -04:00
Kazu Hirata
f4b311b527
[TableGen] Use StringRef::contains (NFC) (#141413) 2025-05-25 10:55:14 -07:00
Oleksandr T.
00f40e3c1a
[Clang] Add missing macro undefs in AttributeSpellingList emitter (#141090)
Fixes
https://github.com/llvm/llvm-project/pull/140629#issuecomment-2901568992

---

This patch adds `#undef ATTR_NAME` and `#undef ATTR_SCOPE_NAME` to the
end of the generated `AttributeSpellingList.inc` file to prevent macro
redefinition warnings
2025-05-22 11:24:12 -07:00
Oleksandr T.
50127ac054
[Clang] add typo correction for unknown attribute names (#140629)
This patch enhances Clang's diagnosis for unknown attributes by
providing typo correction suggestions for known attributes.

```cpp
[[gmu::deprected]] // expected-warning {{unknown attribute 'gmu::deprected' ignored; did you mean 'gnu::deprecated'?}}
int f1(void) {
  return 0;
}

[[deprected]] // expected-warning {{unknown attribute 'deprected' ignored; did you mean 'deprecated'?}}
int f2(void) {
  return 0;
}
```
2025-05-22 17:03:32 +03:00
Vincent
385752c9b5
[clang][TableGen] Fix Duplicate Entries in TableGen (#140828)
Fixed TableGen duplicate issues that causes the wrong interrupt
attribute from being selected.

resolves #140701
2025-05-21 12:27:48 -04:00
Jim Lin
d561d595c4
[RISCV] Implement intrinsics for XAndesVPackFPH (#140007)
This patch implements clang intrinsic support for XAndesVPackFPH.

The document for the intrinsics can be found at:

https://github.com/andestech/andes-vector-intrinsic-doc/blob/ast-v5_4_0-release-v5/auto-generated/andes-v5/intrinsic_funcs.adoc#andes-vector-packed-fp16-extensionxandesvpackfph
and with policy variants

https://github.com/andestech/andes-vector-intrinsic-doc/blob/ast-v5_4_0-release-v5/auto-generated/andes-v5/policy_funcs/intrinsic_funcs.adoc#andes-vector-packed-fp16-extensionxandesvpackfph

Co-authored-by: Tony Chuan-Yue Yuan <yuan593@andestech.com>
2025-05-20 13:16:51 +08:00
Rahul Joshi
3932360b14
[LLVM][TableGen] Rename ListInit::getValues() to getElements() (#140289)
Rename `ListInit::getValues()` to `getElements()` to better match with
other `ListInit` members like `getElement`. Keep `getValues()` for
existing downstream code but mark it deprecated.
2025-05-19 12:16:33 -07:00
Kazu Hirata
4388f38fbd
[clang] Use llvm::max_element (NFC) (#140435) 2025-05-18 07:33:35 -07:00
Kazu Hirata
6290cc33e9
[clang] Use llvm::stable_sort (NFC) (#140413) 2025-05-17 17:02:45 -07:00
Lukacma
6fc0312919
[Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (#128019)
This patch adds fp8 variants to existing intrinsics, whose operation
doesn't depend on arguments being a specific type.

It also changes mfloat8 type representation in memory from `i8` to
`<1xi8>`
2025-05-15 14:01:41 +01:00
Kazu Hirata
918cdaef52
[TableGen] Use StringRef::substr instead of StringRef::slice (NFC) (#139485)
StringRef::substr is shorter here because we can rely on its default
second parameter.
2025-05-11 19:09:25 -07:00
Kazu Hirata
a4385555f8
[TableGen] Use StringRef::take_while (NFC) (#139461) 2025-05-11 11:38:38 -07:00
Kazu Hirata
8e2a9fa9a5
[TableGen] Use std::tie to implement operator< (NFC) (#139405) 2025-05-10 16:04:26 -07:00
Kazu Hirata
4c587f549c
[clang] Use *(Set|Map)::contains (NFC) (#138464) 2025-05-04 11:56:31 -07:00
Kazu Hirata
f002f300c5
[clang] Remove unused local variables (NFC) (#138453) 2025-05-04 10:51:40 -07:00
Aaron Puchert
228b330988
Support pack expansion for Clang Thread Safety attributes (#137477)
Support for attribute parameter packs was added some time ago in commit
ead1690d31f815c00fdd2bc23db4766191bbeabc. But template substitution
didn't expand the packs yet. For now expansion can only happen within a
`VariadicExprArgument`: i.e. in `try_acquire_capability`, which takes a
regular and a variadic argument, the template can't have a single pack
that then expands to cover both arguments.

This is a prerequisite for #42000.
2025-04-30 22:21:06 +02:00
Shafik Yaghmour
a6f4a54891
[Clang][NFC] Const correctness fix for range based for loop (#137431)
Static analysis flagged that we did not make const a item declaration
b/c we did not modify it all during the loop.
2025-04-28 08:27:19 -07:00
Vlad Serebrennikov
ee29afe1e5 [clang][NFC] Convert LookupResultKind to scoped enum 2025-04-28 08:42:02 +03:00
Jay Foad
2bc6f9d4b6
[TableGen] Only store direct superclasses in Record (#123072)
In Record only store the direct superclasses instead of all
superclasses. getSuperClasses recurses to find all superclasses when
necessary.

This gives a small reduction in memory usage. On lib/Target/X86/X86.td I
measured about 2.0% reduction in total bytes allocated (measured by
valgrind) and 1.3% reduction in peak memory usage (measured by
/usr/bin/time -v).

---------

Co-authored-by: Min-Yih Hsu <min@myhsu.dev>
2025-04-24 18:57:51 +01:00
Kazu Hirata
f2ec5e40d9
[clang] Use llvm::unique (NFC) (#136469) 2025-04-19 20:33:53 -07:00
Kazu Hirata
0ed1c9862d
[clang] llvm::append_range (NFC) (#136440) 2025-04-19 10:37:25 -07:00
Matheus Izvekov
fceb9cecdf
[clang] consistently quote expressions in diagnostics (#134769) 2025-04-15 04:18:23 -03:00
Pengcheng Wang
e57f4e8969 [RISCV][NFC] Make generated intrinsic records more human-readable (#133710)
We add comment markers and print enum names instead of numbers.

For required extensions, we print the feature list instead of raw
bits.

This recommits d0cf5cd which was reverted by 21ff45d.
2025-04-14 13:00:57 +08:00
Wang Pengcheng
21ff45dea1 Revert "[RISCV][NFC] Make generated intrinsic records more human-readable (#133710)"
This reverts commit d0cf5cd5f9790dc21396936d076389c3be1a9599.

Error: "declaration of ‘clang::RISCV::RequiredExtensions
{anonymous}::SemaRecord::RequiredExtensions’ changes meaning of
‘RequiredExtensions’ [-fpermissive]"
2025-04-14 12:56:33 +08:00
Pengcheng Wang
d0cf5cd5f9
[RISCV][NFC] Make generated intrinsic records more human-readable (#133710)
We add comment markers and print enum names instead of numbers.

For required extensions, we print the feature list instead of raw
bits.
2025-04-14 12:17:26 +08:00
Timm Baeder
578ca5e469
[clang][bytecode] Print jump lines in Function::dump() (#135482)
E.g. for
```c++
constexpr int foo(int b) {
  int a = 1+1;

  for (int i = 0; i < b; ++i) {
    ++a;
  }
  return a;
}
```

we now print:
```
foo 0x7cc8d4bf0580
frame size: 128
arg size:   8
rvo:        0
this arg:   0
0      InitScope         0
16     ConstSint32       1
32     ConstSint32       1
48     AddSint32
56     SetLocalSint32    40
72     ConstSint32       0
88     SetLocalSint32    104
104    GetPtrLocal       104         <-+
120    LoadPopSint32                   |
128    GetPtrParam       0             |
144    LoadPopSint32                   |
152    LTSint32                        |
160    Jf                80     --+    |
176    GetPtrLocal       40       |    |
192    IncPopSint32      1        |    |
208    GetPtrLocal       104      |    |
224    IncPopSint32      1        |    |
240    Jmp               -152     |  --+
256    GetPtrLocal       40     <-+
272    LoadPopSint32
280    Destroy           0
296    RetSint32
304    Destroy           0
320    NoRet
```
2025-04-13 15:46:01 +02:00
Sirraide
6c74fe9087
[Clang] [NFC] Tablegen component diags headers (#134777)
The component diagnostic headers (i.e. `DiagnosticAST.h` and friends)
all follow the same format, and there’s enough of them (and in them) to
where updating all of them has become rather tedious (at least it was
for me while working on #132348), so this patch instead generates all of
them (or rather their contents) via Tablegen.

Also, it seems that `%enum_select` currently wouldn’t work in
`DiagnosticCommonKinds.td` because the infrastructure for that was
missing from `DiagnosticIDs.h`; this patch should fix that as well.
2025-04-08 17:21:45 +02:00
YLChenZ
529e9127f0
[clang][doc]: Merge entries with duplicate content. (#134089)
Before the patch:

![docb4](https://github.com/user-attachments/assets/6db1000f-d555-48b8-8a19-85c41b043fd8)
after the patch:

![doc-after](https://github.com/user-attachments/assets/1cff64b6-db2e-48d8-b0a9-a403fd61f8af)

Fixes #133706
2025-04-07 14:42:57 -04:00
Sirraide
10c6ebc427
Reapply "[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (#132348)" (#134043)
This reapplies #132348 with a fix to the python bindings tests, reverting
076397ff32.
2025-04-02 10:40:05 +02:00
Sirraide
076397ff32
Revert "[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics" (#134036)
Reverts llvm/llvm-project#132348

Some tests are failing and I still need to figure out what is going on
here.
2025-04-02 08:29:05 +02:00
Sirraide
9d06e0879b
[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (#132348)
This is a follow-up to #132129.

Currently, only `Parser` and `SemaBase` get a `DiagCompat()` helper; I’m
planning to keep refactoring compatibility warnings and add more helpers
to other classes as needed. I also refactored a single parser compat
warning just to make sure everything works properly when diagnostics
across multiple components (i.e. Sema and Parser in this case) are
involved.
2025-04-02 08:06:29 +02:00
Virginia Cangelosi
e92ff64bad
[Clang][LLVM] Implement single-multi vectors MOP4{A/S} (#128854)
Implement all single-multi {BF/F/S/U/SU/US}MOP4{A/S} instructions in
clang and llvm following the acle in
https://github.com/ARM-software/acle/pull/381/files.

This PR depends on https://github.com/llvm/llvm-project/pull/127797

This patch updates the semantics of template arguments in intrinsic
names for clarity and ease of use. Previously, template argument numbers
indicated which character in the prototype string determined the final
type suffix, which was confusing—especially for intrinsics using
multiple prototype modifiers per operand (e.g., intrinsics operating on
arrays of vectors). The number had to reference the correct character in
the prototype (e.g., the ‘u’ in “2.u”), making the system cumbersome and
error-prone.
With this patch, template argument numbers now refer to the operand
number that determines the final type suffix, providing a more intuitive
and consistent approach.
2025-04-01 15:05:30 +01:00
Lukacma
6c3adaafe3
[AARCH64][Neon] switch to using bitcasts in arm_neon.h where appropriate (#127043)
Currently arm_neon.h emits C-style casts to do vector type casts. This
relies on implicit conversion between vector types to be enabled, which
is currently deprecated behaviour and soon will disappear. To ensure
NEON code will keep working afterwards, this patch changes all this
vector type casts into bitcasts.


Co-authored-by: Momchil Velikov <momchil.velikov@arm.com>
2025-04-01 09:45:16 +01:00
Kazu Hirata
cb80b26e37
[clang] Use *Set::insert_range (NFC) (#133357)
We can use *Set::insert_range to collapse:

  for (auto Elem : Range)
    Set.insert(E);

down to:

  Set.insert_range(Range);

In some cases, we can further fold that into the set declaration.
2025-03-27 20:14:25 -07:00
Craig Topper
1752d5292c
[RISCV] Make RequiredExtensions for intrinsics scalable to more than 32 extensions. NFC (#132895)
We have more than 32 extensions in our downstream and had to change this
type from uint32_t to uint64_t.

To simplify our downstream and make the code more flexible, I propose to
make it an array of uint32_t that we can size based on the number of
extensions. I really wanted to use std::bitset, but we have to print the
bits to a .inc file which can't easily be done with std::bitset.
2025-03-25 20:46:01 -07:00