2049 Commits

Author SHA1 Message Date
Viktoriia Bakalova
c3ba6f378e
[Modules] Delay deserialization of preferred_name attribute at r… (#122726)
…ecord level.

This fixes the incorrect diagnostic emitted when compiling the following
snippet

```
// string_view.h
template<class _CharT>
class basic_string_view;

typedef basic_string_view<char> string_view;

template<class _CharT>
class
__attribute__((__preferred_name__(string_view)))
basic_string_view {
public:
    basic_string_view() 
    {
    }
};

inline basic_string_view<char> foo()
{
  return basic_string_view<char>();
}
// A.cppm
module;
#include "string_view.h"
export module A;

// Use.cppm
module;
#include "string_view.h"
export module Use;
import A;
```

The diagnostic is 
```
string_view.h:11:5: error: 'basic_string_view<char>::basic_string_view' from module 'A.<global>' is not present in definition of 'string_view' provided earlier
```

The underlying issue is that deserialization of the `preferred_name`
attribute triggers deserialization of `basic_string_view<char>`, which
triggers the deserialization of the `preferred_name` attribute again
(since it's attached to the `basic_string_view` template).
The deserialization logic is implemented in a way that prevents it from
going on a loop in a literal sense (it detects early on that it has
already seen the `string_view` typedef when trying to start its
deserialization for the second time), but leaves the typedef
deserialization in an unfinished state. Subsequently, the `string_view`
typedef from the deserialized module cannot be merged with the same
typedef from `string_view.h`, resulting in the above diagnostic.

This PR resolves the problem by delaying the deserialization of the
`preferred_name` attribute until the deserialization of the
`basic_string_view` template is completed. As a result of deferring, the
deserialization of the `preferred_name` attribute doesn't need to go on
a loop since the type of the `string_view` typedef is already known when
it's deserialized.
2025-01-17 09:10:58 +01:00
Erich Keane
bf17016a92
Add 'enum_select' diagnostic selection to clang. (#122505)
This causes us to generate an enum to go along with the select
diagnostic, which allows for clearer diagnostic error emit lines.

The syntax for this is:

%enum_select<EnumerationName>{%OptionalEnumeratorName{Text}|{Text2}}0

Where the curley brackets around the select-text are only required if an
Enumerator name is provided.

The TableGen here emits this as a normal 'select' to the frontend, which
permits us to reuse all of the existing 'select' infrastructure.
Documentation is the same as well.

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2025-01-15 12:59:08 -08:00
Chandler Carruth
6d25345465
Remove the CustomEntry escape hatch from builtin TableGen (#120861)
This was an especially challenging escape hatch because it directly
forced the use of a specific X-macro structure and prevented any other
form of TableGen emission.

The problematic feature that motivated this is a case where a builtin's
prototype can't be represented in the mini-language used by TableGen.
Instead of adding a complete custom entry for this, this PR just teaches
the prototype handling to do the same thing the X-macros did in this
case: emit an empty string and let the Clang builtin handling respond
appropriately.

This should produce identical results while preserving all the rest of
the structured representation in the builtin TableGen code.
2025-01-14 01:10:42 -08:00
Momchil Velikov
16e45b8fac
[AArch64] Implement FP8 SVE/SME reinterpret intrinsics (#121063) 2025-01-13 18:53:07 +00:00
Nicholas Guy
21b531ead1
[clang][llvm][aarch64] Add aarch64_sme_in_streaming_mode intrinsic (#120265)
Replacing the extant streaming mode function call with an intrinsic
allows us to make further optimisations around it. For example, if it's
called within a function that has a known streaming mode, we can remove
the dead code, and avoid the redundant conditional branch.
2025-01-07 09:02:26 +00:00
Chandler Carruth
2529a8df53
Mechanically port bulk of x86 builtins to TableGen (#120831)
The goal is to make incremental (if small) progress towards fully
TableGen'ed builtins, and to unblock #120534 by gaining access to more
powerful TableGen-based representations.

The bulk `.td` file addition was generated with the help of a very rough
Python script. That script made no attempt to be robust or reusable, it
specifically handled only the cases in the X86 `.def` file.

Four entries from the `.def` file were not handled automatically as they
used `BUILTIN` rather than `TARGET_BUILTIN`. These were ported by hand
to an empty-feature `TargetBuiltin` entry, which seems like a better
match.

For all the automatically ported entries, the results were compared by
sorting and diffing the `.def` file and the generated `.inc` file. The
only differences were:

- Different horizontal whitespace

- Additional entries that had already been ported to the `.td` file.

- More systematically using `Oi` instead of `LLi` for the type `long
  long int` in the fully general `__builtin_ia32_...` builtins for OpenCL
  support. The `.def` file was only partially moved to this it seems, and
  the systematic migration has updated a few missed builtins.
2025-01-04 02:23:54 -08:00
SpencerAbson
db84ae3a68
[Clang][AArch64] Add signed index/offset variants of sve2p1 qword stores (#120549)
This patch adds signed offset/index variants to the SVE2p1 quadword
store intrinsics, in accordance with
https://github.com/ARM-software/acle/pull/359.
2024-12-19 13:27:07 +00:00
Momchil Velikov
c2172431c7
[AArch64] Implements FP8 SVE intrinsics for dot-product (#118125)
This patch adds the following intrinsics:

* 8-bit floating-point dot product to single-precision.

// Only if (__ARM_FEATURE_SVE2 && __ARM_FEATURE_FP8DOT4) ||
__ARM_FEATURE_SSVE_FP8DOT4
svfloat32_t svdot[_f32_mf8]_fpm(svfloat32_t zda, svmfloat8_t zn,
svmfloat8_t zm, fpm_t fpm);
svfloat32_t svdot[_n_f32_mf8]_fpm(svfloat32_t zda, svmfloat8_t zn,
mfloat8_t zm, fpm_t fpm);

* 8-bit floating-point indexed dot product to single-precision.

// Only if (__ARM_FEATURE_SVE2 && __ARM_FEATURE_FP8DOT4) ||
__ARM_FEATURE_SSVE_FP8DOT4
svfloat32_t svdot_lane[_f32_mf8]_fpm(svfloat32_t zda, svmfloat8_t zn,
svmfloat8_t zm,
                                       uint64_t imm0_3, fpm_t fpm);

* 8-bit floating-point dot product to half-precision.

// Only if (__ARM_FEATURE_SVE2 && __ARM_FEATURE_FP8DOT2) ||
__ARM_FEATURE_SSVE_FP8DOT2
svfloat16_t svdot[_f16_mf8]_fpm(svfloat16_t zda, svmfloat8_t zn,
svmfloat8_t zm, fpm_t fpm);
svfloat16_t svdot[_n_f16_mf8]_fpm(svfloat16_t zda, svmfloat8_t zn,
mfloat8_t zm, fpm_t fpm);

* 8-bit floating-point indexed dot product to half-precision.

// Only if (__ARM_FEATURE_SVE2 && __ARM_FEATURE_FP8DOT2) ||
__ARM_FEATURE_SSVE_FP8DOT2
svfloat16_t svdot_lane[_f16_mf8]_fpm(svfloat16_t zda, svmfloat8_t zn,
svmfloat8_t zm,
                                       uint64_t imm0_7, fpm_t fpm);
2024-12-13 14:06:54 +00:00
Tom Stellard
ea6e13586c
[clang][perf-training] Fix profiling with -DCLANG_BOLT=perf (#119117)
This fixes the llvm-support build that generates the profile data, and
wraps the whole `cmake --build` command with perf instead of wrapping
each individual clang invocation. This limits the number of profile
files generated and reduces the time spent running perf2bolt.
2024-12-12 15:50:33 -08:00
Kazu Hirata
02dd73a5d5
[clang] Migrate away from PointerUnion::{is,get} (NFC) (#119654)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

I'm not touching PointerUnion::dyn_cast for now because it's a bit
complicated; we could blindly migrate it to dyn_cast_if_present, but
we should probably use dyn_cast when the operand is known to be
non-null.
2024-12-11 21:13:13 -08:00
Qiongsi Wu
f33e236905
[clang][Modules] Fixing Build Breaks When -DLLVM_ENABLE_MODULES=ON (#119473)
A few recent changes are causing build breaks when
`-DLLVM_ENABLE_MODULES=ON` (such as
834dfd23155351c9885eddf7b9664f7697326946 and
7dfdca1961aadc75ca397818bfb9bd32f1879248).

This PR makes the required updates so that clang/llvm builds when
`-DLLVM_ENABLE_MODULES=ON`.

rdar://140803058
2024-12-11 17:33:25 -08:00
Haojian Wu
8f434bb9b2
[clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (#119197)
`DiagsInGroup` is a `map<llvm::StringRef, ...>`, we store a dangling
string_view in the key.
2024-12-10 09:05:28 +01:00
Tom Stellard
18af3fc1bf
[Clang][perf-training] Fix clean command in perf-helper.py (#118978)
The first path argument was always being ignored, and since most calls
to this command only passed one path, it wasn't actually doing anything
in most cases.

This bug was introduced by dd0356d741aefa25ece973d6cc4b55dcb73b84b4.
2024-12-06 18:34:59 -08:00
Oliver Hunt
fe4bba6578
Add support for referencable labels for attribute documentation (#118428)
The existing mechanism being used is to manually add a reference in the
documentation. These references link to the beginning of the text rather
than the heading for the attribute which is what this PR allows.

---------

Co-authored-by: Sirraide <aeternalmail@gmail.com>
2024-12-04 12:58:20 -05:00
SpencerAbson
ac7fe42616
[Clang][AArch64]Refactor typespec handling in SveEmitter.cpp (#117717)
- Switch to an enumerated type approach, which is less error-prone as we
continue to add new types. This is similar to NeonEmitter.
- Fix existing faulty typespec modifiers
2024-12-02 16:34:57 +00:00
Timm Baeder
82ed9c0319
[clang][bytecode][NFC] Remove APValue Result argument where unnecessary (#118199)
This is unneeded in almost all circumstances. We only return an APValue
back to clang when the evaluation is finished, and that is always done
by an EvalEmitter - which has its own implementation of the Ret
instructions.
2024-12-01 17:36:19 +01:00
SpencerAbson
e4ee970c4b
[AArch64] Implement intrinsics for F1CVTL/F2CVTL and BF1CVTL/BF2CVTL (#116959)
This patch implements the following intrinsics:

8-bit floating-point convert to deinterleaved half-precision or
BFloat16.
``` c
  // Variant is also available for: _bf16[_mf8]_x2
  svfloat16x2_t svcvtl1_f16[_mf8]_x2_fpm(svmfloat8_t zn, fpm_t fpm) __arm_streaming;
  svfloat16x2_t svcvtl2_f16[_mf8]_x2_fpm(svmfloat8_t zn, fpm_t fpm) __arm_streaming;
```

Defined in https://github.com/ARM-software/acle/pull/323

Co-authored-by: Caroline Concatto caroline.concatto@arm.com
Co-authored-by: Marian Lukac marian.lukac@arm.com
2024-11-28 12:37:02 +00:00
Congcong Cai
3c344f92e6
[clang][tablegen][NFC]add static for internal linkage function (#117479)
Detected by misc-use-internal-linkage
2024-11-25 06:48:09 +08:00
Brandon Wu
05b3d26181
[clang][RISCV] Bump RVV intrinsic to version 1.0 (#116597)
The spec:
https://github.com/riscv-non-isa/rvv-intrinsic-doc/releases/tag/v1.0.0-rc4
Also remove __riscv_v_intrinsic_overloading since it's no longer in
spec, the overloading intrinsics should be also enabled when RVV
intrinsics are defined.
2024-11-23 01:41:12 +08:00
Balazs Benics
20cb4ec845
[analyzer] Print the PostInitializer target in exploded-graph-rewriter (#116034)
This aids debugging PostInitializer program points by knowing what is
the location being initialized.

![Screenshot from 2024-11-11
09-50-51](https://github.com/user-attachments/assets/481f79f2-5cc5-4d0c-ac7d-ac24b4b23bc5)
2024-11-22 16:40:13 +01:00
CarolineConcatto
aaba8406c5
[NFC][Clang][AArch64]Refactor implementation of Neon vectors MFloat8… (#114804)
…x8 and MFloat8x16

This patch adds MFloat8 as a TypeFlag and Kind on Neon to generate the
typedefs using emitNeonTypeDefs.
It does not need any change in Clang, because SEMA and CodeGen use the
Builtins defined in AArch64SVEACLETypes.def
2024-11-21 10:29:28 +00:00
Rahul Joshi
63aa8cf6be
[NFC][Clang][TableGen] Fix file header comments (#116491) 2024-11-17 07:54:10 -08:00
Julian Schmidt
ec0a27f658
Revert "Reland: [clang][test] add testing for the AST matcher reference" (#116477)
Reverts llvm/llvm-project#112168
2024-11-16 07:34:20 +01:00
Balazs Benics
9cbf2dd6f3
[analyzer] Print the callee name in CallEnter in exploded-graph-rewriter (#116225)
![image](https://github.com/user-attachments/assets/22a82950-d6e1-4e1f-8f82-2f33240b382a)
2024-11-15 14:21:35 +01:00
Julian Schmidt
53e92e48d0
Reland: [clang][test] add testing for the AST matcher reference (#112168)
## Problem Statement
Previously, the examples in the AST matcher reference, which gets
generated by the Doxygen comments in `ASTMatchers.h`, were untested and
best effort.
Some of the matchers had no or wrong examples of how to use the matcher.

## Solution
This patch introduces a simple DSL around Doxygen commands to enable
testing the AST matcher documentation in a way that should be relatively
easy to use.
In `ASTMatchers.h`, most matchers are documented with a Doxygen comment.
Most of these also have a code example that aims to show what the
matcher will match, given a matcher somewhere in the documentation text.
The way that the documentation is tested, is by using Doxygen's alias
feature to declare custom aliases. These aliases forward to
`<tt>text</tt>` (which is what Doxygen's `\c` does, but for multiple
words). Using the Doxygen aliases is the obvious choice, because there
are (now) four consumers:
 - people reading the header/using signature help
 - the Doxygen generated documentation
 - the generated HTML AST matcher reference
 - (new) the generated matcher tests

This patch rewrites/extends the documentation such that all matchers
have a documented example.
The new `generate_ast_matcher_doc_tests.py` script will warn on any
undocumented matchers (but not on matchers without a Doxygen comment)
and provides diagnostics and statistics about the matchers.

The current statistics emitted by the parser are:

```text
Statistics:
        doxygen_blocks                :   519
        missing_tests                 :    10
        skipped_objc                  :    42
        code_snippets                 :   503
        matches                       :   820
        matchers                      :   580
        tested_matchers               :   574
        none_type_matchers            :     6
```

The tests are generated during building, and the script will only print
something if it found an issue with the specified tests (e.g., missing
tests).

## Description

DSL for generating the tests from documentation.

TLDR:
```
  \header{a.h}
  \endheader     <- zero or more header

  \code
    int a = 42;
  \endcode
  \compile_args{-std=c++,c23-or-later} <- optional, the std flag supports std ranges and
                                          whole languages

  \matcher{expr()} <- one or more matchers in succession
  \match{42}   <- one or more matches in succession

  \matcher{varDecl()} <- new matcher resets the context, the above
                         \match will not count for this new
                         matcher(-group)
  \match{int a  = 42} <- only applies to the previous matcher (not to the
                         previous case)
```

The above block can be repeated inside a Doxygen command for multiple
code examples for a single matcher.
The test generation script will only look for these annotations and
ignore anything else like `\c` or the sentences where these annotations
are embedded into: `The matcher \matcher{expr()} matches the number
\match{42}.`.

### Language Grammar
  [] denotes an optional, and <> denotes user-input

```
  compile_args j:= \compile_args{[<compile_arg>;]<compile_arg>}
  matcher_tag_key ::= type
  match_tag_key ::= type || std || count || sub
  matcher_tags ::= [matcher_tag_key=<value>;]matcher_tag_key=<value>
  match_tags ::= [match_tag_key=<value>;]match_tag_key=<value>
  matcher ::= \matcher{[matcher_tags$]<matcher>}
  matchers ::= [matcher] matcher
  match ::= \match{[match_tags$]<match>}
  matches ::= [match] match
  case ::= matchers matches
  cases ::= [case] case
  header-block ::= \header{<name>} <code> \endheader
  code-block ::= \code <code> \endcode
  testcase ::= code-block [compile_args] cases
```

### Language Standard Versions

The 'std' tag and '\compile_args' support specifying a specific language
version, a whole language and all of its versions, and thresholds
(implies ranges). Multiple arguments are passed with a ',' separator.
For a language and version to execute a tested matcher, it has to match
the specified '\compile_args' for the code, and the 'std' tag for the
matcher. Predicates for the 'std' compiler flag are used with
disjunction between languages (e.g. 'c || c++') and conjunction for all
predicates specific to each language (e.g. 'c++11-or-later &&
c++23-or-earlier').

Examples:
 - `c`                                    all available versions of C
 - `c++11`                                only C++11
 - `c++11-or-later`                       C++11 or later
 - `c++11-or-earlier`                     C++11 or earlier
- `c++11-or-later,c++23-or-earlier,c` all of C and C++ between 11 and
                                          23 (inclusive)
 - `c++11-23,c`                             same as above

### Tags

#### `type`:
**Match types** are used to select where the string that is used to
check if a node matches comes from.
Available: `code`, `name`, `typestr`, `typeofstr`. The default is
`code`.

- `code`: Forwards to `tooling::fixit::getText(...)` and should be the
preferred way to show what matches.
- `name`: Casts the match to a `NamedDecl` and returns the result of
`getNameAsString`. Useful when the matched AST node is not easy to spell
out (`code` type), e.g., namespaces or classes with many members.
- `typestr`: Returns the result of `QualType::getAsString` for the type
derived from `Type` (otherwise, if it is derived from `Decl`, recurses
with `Node->getTypeForDecl()`)

**Matcher types** are used to mark matchers as sub-matcher with 'sub' or
as deactivated using 'none'. Testing sub-matcher is not implemented.

#### `count`:
Specifying a 'count=n' on a match will result in a test that requires
that the specified match will be matched n times. Default is 1.

#### `std`:
A match allows specifying if it matches only in specific language
versions. This may be needed when the AST differs between language
versions.

#### `sub`:
The `sub` tag on a `\match` will indicate that the match is for a node
of a bound sub-matcher.
E.g., `\matcher{expr(expr().bind("inner"))}` has a sub-matcher that
binds to `inner`, which is the value for the `sub` tag of the expected
match for the sub-matcher `\match{sub=inner$...}`. Currently,
sub-matchers are not tested in any way.

### What if ...?

#### ... I want to add a matcher?

Add a Doxygen comment to the matcher with a code example, corresponding
matchers and matches, that shows what the matcher is supposed to do.
Specify the compile arguments/supported languages if required, and run
`ninja check-clang-unit` to test the documentation.

#### ... the example I wrote is wrong?

The test-failure output of the generated test file will provide
information about
 - where the generated test file is located
 - which line in `ASTMatcher.h` the example is from
 - which matches were: found, not-(yet)-found, expected
- in case of an unexpected match: what the node looks like using the
different `type`s
- the language version and if the test ran with a windows `-target` flag
(also in failure summary)

#### ... I don't adhere to the required order of the syntax?

The script will diagnose any found issues, such as `matcher is missing
an example` with a `file:line:` prefix,
which should provide enough information about the issue.

#### ... the script diagnoses a false-positive issue with a Doxygen
comment?

It hopefully shouldn't, but if you, e.g., added some non-matcher code
and documented it with Doxygen, then the script will consider that as a
matcher documentation. As a result, the script will print that it
detected a mismatch between the actual and the expected number of
failures. If the diagnostic truly is a false-positive, change the
`expected_failure_statistics` at the top of the
`generate_ast_matcher_doc_tests.py` file.

Fixes #57607
Fixes #63748
2024-11-15 10:51:15 +01:00
CarolineConcatto
91aad9bfb2
[Clang][AArch64]Fix Name and Mangle name for scalar fp8 (#114983)
The scalar __mfp8 type has the wrong name and mangle name in
AArch64SVEACLETypes.def

According to the ACLE[1] the name should be __mfp8

This patch fixes this problem by replacing
the Name __MFloat8_t by __mfp8
and
the Mangle Name __MFloat8_t by u6__mfp8

And we revert the incorrect typedef in NeonEmitter.

[1]https://github.com/ARM-software/acle
2024-11-15 09:19:39 +00:00
Kazu Hirata
a8a1e9033a
[TableGen] Remove unused includes (NFC) (#116168)
Identified with misc-include-cleaner.
2024-11-14 07:55:34 -08:00
Rahul Joshi
17c6ec6db1
[NFC][Clang] Use StringRef instead of string in ClangDiagnosticEmitter (#115959)
Use StringRef instead of std::string in ClangDiagnosticEmitter.
2024-11-13 13:01:45 -08:00
Rahul Joshi
4f1fe6d5f1
[NFC][lang][TableGen] Simplify EmitClangDiagsIndexName (#115962)
Simplify `EmitClangDiagsIndexName` to directly sort records instead of
creating an array of `RecordIndexElement` containing record name and
sorting it.

---------

Co-authored-by: Kazu Hirata <kazu@google.com>
2024-11-13 07:08:58 -08:00
Rahul Joshi
46b275716a
[NFC][Clang] Use StringRef and range for loops in SA/Syntax Emitters (#115972)
Use StringRef and range for loops in Clang SACheckers and Syntax
emitters.
2024-11-13 07:07:58 -08:00
Kazu Hirata
1884ffc41c
[TableGen] Use heterogenous lookups with std::map (NFC) (#115994)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
2024-11-13 06:41:33 -08:00
Boaz Brickner
9a365bc9a0
[Clang] [NFC] Add "human" diagnostic argument format (#115835)
This allows formatting large integers in a human friendly way. Example:
"5321584" -> "5.32M".
Use it where such human numbers are generated manually today.
2024-11-13 07:58:11 +01:00
Rahul Joshi
7b5e285d16
[NFC][Clang] Use range for loops in ClangDiagnosticsEmitter (#115573)
Use range based for loops in Clang diagnostics emitter.
2024-11-12 14:39:02 -08:00
Kazu Hirata
dfb864a735
[TableGen] Use heterogenous lookups with std::map (NFC) (#115810)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.

This patch introduces alias:

  using DiagsInGroup = std::map<std::string, GroupInfo, std::less<>>;

because the raw type is a bit mouthful.
2024-11-12 10:08:59 -08:00
Kazu Hirata
173529104d
[TableGen] Use heterogenous lookups with std::map (NFC) (#115682)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
2024-11-11 07:34:42 -08:00
Kazu Hirata
a44ee8ec1c
[TableGen] Use heterogenous lookups with std::map (NFC) (#115633)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
2024-11-10 07:24:27 -08:00
Tom Stellard
738250989c
[Clang][perf-training] Do build of libLLVMSupport for perf training (#111625)
This adds a build of the libLLVMSupport to the lit suite that is used
for generating profile data. This helps to improve both PGO and BOLT
optimization of clang over the existing hello world training program.

I considered building all of LLVM instead of just libLLVMSupport, but
there is only a marginal increase in performance for PGO only builds
when training with a build of all of LLVM, and I didn't think it was
enough to justify the increased build times given that it is the default
configuration.

The benchmark[1] I did showed that using libLLVMSupport for training
gives a 1.35 +- 0.02 speed up for clang optimized with PGO + BOLT vs
just 1.05 +- 0.01 speed up when training with hello world.

For comparison, training with a full LLVM build gave a speed up of 1.35
+- 0.1.

Raw data:

| PGO Training | BOLT Training | Speed Up | Error Range |
| ------------ | ------------- | -------- | ----------- |
| LLVM Support | LLVM Support  | 1.35     | 0.02        |
| LLVM All     | LLVM All      | 1.34     | 0.01        |
| LLVM Support | Hello World   | 1.29     | 0.02        |
| LLVM All     | PGO-ONLY      | 1.27     | 0.02        |
| LLVM Support | PGO-ONLY      | 1.22     | 0.02        |
| Hello World  | Hello World   | 1.05     | 0.01        |
| Hello World  | PGO-ONLY      | 1.03     | 0.01        |

Time it takes to generate profile data (on a 64-core system):

| Training Data | PGO   | BOLT  |
| ------------- | ----- | ----- |
| LLVM All      | 1090s | 3239s |
| LLVM Support  |   91s |  655s |
| Hello World  |    2s |    9s |

[1] Benchmark was compiling SemaDecl.cpp
2024-11-08 15:23:23 -08:00
Kazu Hirata
dd1c99bac4 [TableGen] Fix a warning
This patch fixes:

  clang/utils/TableGen/ClangAttrEmitter.cpp:3869:51: error: captured
  structured bindings are a C++20 extension
  [-Werror,-Wc++20-extensions]
2024-11-07 13:12:40 -08:00
Chinmay Deshpande
15d1560ea4
[Clang] Improve EmitClangAttrSpellingListIndex (#114899)
`EmitClangAttrSpellingListIndex()` performs a lot of unnecessary string
comparisons which is wasteful in time and stack space. This commit
attempts to refactor this method to be more performant.
2024-11-07 13:01:58 -08:00
Thomas Fransham
d7979c111e
[Clang][TableGen] Add explicit symbol visibility macros to code generated (#109362)
Update ClangAttrEmitter TableGen to add explicit symbol visibility
macros to attribute class declarations it creates.
Both AnnotateFunctions and Attribute example plugins require
clang::AnnotateAttr TableGen created functions to be exported from the
Clang shared library.
This depends on macros to be added in
https://github.com/llvm/llvm-project/pull/108276
2024-11-05 16:32:52 +02:00
Nikolas Klauser
508263824f
[Clang] Start moving X86Builtins.def to X86Builtins.td (#106005)
This starts moving `X86Builtins.def` to be a tablegen file. It's quite
large, so I think it'd be good to move things in multiple steps to avoid
a bunch of merge conflicts due to the amount of time this takes to
complete.
2024-10-30 14:23:35 +01:00
Rahul Joshi
8e6856e278
[Clang][TableGen] Use StringRef::str() instead of std::string() cast (#113645)
Use `StringRef::str()` instead of std::string(StringRef) to cast from
StringRef to std::string.
2024-10-28 16:15:39 -07:00
Rahul Joshi
e0a02fdb45
[NFC][Clang][TableGen] Use StringRef in FlattenedSpelling (#113809)
- Change FlattenedSpelling to use StringRef instead of std::String.
- Use range for loops and enumerate().
- Use ArrayRef<> instead of std::vector reference as function arguments.
- Use {} for all if/else branch bodies if one of them uses it.
2024-10-28 11:43:28 -07:00
Momchil Velikov
1df5c94343
[AArch64] Implement FP8 floating-point mode helper intrinsics (#100608)
Implement FP8 mode helper intrinsics (as inline functions) as
specified in ACLE 2024Q3 "14.2 Helper intrinsics"

https://github.com/ARM-software/acle/releases/download/r2024Q3/acle-2024Q3.pdf
2024-10-28 11:22:38 +00:00
CarolineConcatto
49940514e2
[CLANG][AArch64] Add the modal 8 bit floating-point scalar type (#97277)
ARM ACLE PR#323[1] adds new modal types for 8-bit floating point
intrinsic.

From the PR#323:
```
ACLE defines the `__mfp8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.
````

The type should be an opaque type and its format in undefined in Clang.
Only defined in the backend by a status/format register, for AArch64 the
FPMR.

This patch is an attempt to the add the mfloat8_t scalar type. It has a
parser and codegen for the new scalar type.

The patch it is lowering to and 8bit unsigned as it has no format. But
maybe we should add another opaque type.

[1]  https://github.com/ARM-software/acle/pull/323
2024-10-25 13:59:46 +01:00
Jay Foad
4dd55c567a
[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)
Follow up to #109133.
2024-10-24 10:23:40 +01:00
CarolineConcatto
6dad29aebc
[CLANG][AArch64]Add Neon vectors for mfloat8_t (#99865)
This patch adds these new vector sizes for neon:
   mfloat8x16_t and mfloat8x8_t

    According to the ARM ACLE PR#323[1].

    [1] ARM-software/acle#323
2024-10-23 13:23:18 +01:00
Luke Drummond
b55c52c047 Revert "Renormalize line endings whitespace only after dccebddb3b80"
This reverts commit 9d98acb196a40fee5229afeb08f95fd36d41c10a.
2024-10-18 21:16:50 +01:00
Jay Foad
922992a22f
Fix typo "instrinsic" (#112899) 2024-10-18 15:58:33 +01:00
Rahul Joshi
62e2c7fb2d
[LLVM][TableGen] Change all Init pointers to const (#112705)
This is a part of effort to have better const correctness in TableGen
backends:


https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
2024-10-18 07:50:22 -07:00