10051 Commits

Author SHA1 Message Date
Florian Mayer
0f09f2cf00
[Sanitize] fix crash in -fsanitize-annotate-debug-info (#149237) 2025-07-16 21:28:41 -07:00
Cristian Assaiante
81eb7defa2
[OptBisect][IR] Adding a new OptPassGate for disabling passes via name (#145059)
This commit adds a new pass gate that allows selective disabling
of one or more passes via the clang command line using the
`-opt-disable` option. Passes to be disabled should be specified as a
comma-separated list of their names.
The implementation resides in the same file as the bisection tool. The
`getGlobalPassGate()` function returns the currently enabled gate.

Example: `-opt-disable="PassA,PassB"`

Pass names are matched using case-insensitive comparisons. However, note
that special characters, including spaces, must be included exactly as
they appear in the pass names.

Additionally, a `-opt-disable-enable-verbosity` flag has been introduced to
enable verbose output when this functionality is in use. When enabled,
it prints the status of all passes (either running or NOT running),
similar to the default behavior of `-opt-bisect-limit`. This flag is
disabled by default, which is the opposite of the `-opt-bisect-verbose`
flag (which defaults to enabled).

To validate this functionality, a test file has also been provided. It reuses
the same infrastructure as the opt-bisect test, but disables three
specific passes and checks the output to ensure the expected behavior.

---------

Co-authored-by: Nikita Popov <github@npopov.com>
2025-07-16 16:51:58 -07:00
Guy David
cb6d1bbfcd
[PowerPC] Test SPE incompatibility with VSX (#147184)
PPCSubtarget is not always initialized, depending on which passes are
running, and in our downstream fork, -enable-matrix is the default
configuration (regardless of whether matrix intrinsics are present in
the IR), which triggers a fatal error in builtins-ppc-fpconstrained.c.
2025-07-17 00:29:38 +03:00
Jim Lin
3e4153c97b
[RISCV] Implement Builtins for XAndesBFHCvt extension. (#148804)
XAndesBFHCvt provides two builtins functions for converting between
float and bf16. Users can use them to convert bf16 values loaded from
memory to float, perform arithmetic operations, then convert them back
to bf16 and store them to memory.

The load/store and move operations for bf16 will be handled in a later
patch.
2025-07-16 16:13:31 +08:00
RolandF77
d9e21a92a7
[PowerPC] Add DMF basic builtins (#145372)
Add support for PPC Dense Math basic builtins dmsetdmrz, dmmr, dmxor.
2025-07-15 13:46:07 -04:00
Brad Smith
0d2e11f3e8
Remove Native Client support (#133661)
Remove the Native Client support now that it has finally reached end of life.
2025-07-15 13:22:33 -04:00
Jim Lin
7ba0c98265 [RISCV] Rename the vector crypto intrinsic test vcpopv.c to vcpop.c. NFC.
To be consistent with https://github.com/riscv-non-isa/rvv-intrinsic-doc/tree/post-1.0-dev/auto-generated/vector-crypto/llvm-api-tests
2025-07-15 09:00:35 +08:00
Jeremy Morse
641ff6db38
[DebugInfo] Add option for producing no source-file hash (#148657)
Clang can chose which sort of source-file hash is attached to a DIFile
metadata node. However, whenever hashing is possible, we /always/ attach
a hash. This patch permits users who want DWARF5 but don't want the file
hashes to opt out, by adding a "none" option to the -gsrc-hash option
that skips hash computation.
2025-07-14 20:48:41 +01:00
Jim Lin
d64938b2ba [RISCV] Split the intrinsic test for vector crypto to seperate directory. NFC. 2025-07-14 16:03:09 +08:00
Jim Lin
03c540e360 [RISCV] Move intrinsic tests for Xsfvcp to sifive-intrinsics sub-directory. NFC. 2025-07-14 13:08:40 +08:00
Paul Walker
b152611cbe [NFC][Clang] Merge SVE bfloat specific acle tests with non-bfloat tests. 2025-07-11 14:40:12 +00:00
Paul Walker
584ef94762
[Clang][AArch64] Relax SVE bf16 requirement for opaque builtins. (#147795)
Feature flags protect instructions not datatypes. This means only
builtins associated with +bf16 protected instructions must be guarded.
Those that treat the data as opaque 16-bit values (e.g. loads, store and
shuffles) should be freely available with the underlying SVE feature.
2025-07-11 15:18:21 +01:00
Aaron Ballman
a2246eebca
[C23] Accept an _Atomic underlying type (#147802)
The underlying type of an enumeration is the non-atomic, unqualified
version of the specified type. Clang was rejecting such enumerations,
with a hard error, but now has the ability to downgrade the error into a
warning. Additionally, we diagnose (as a warning) dropping other
qualifiers. _Atomic is special given that an atomic type need not have
the same size as its non-atomic counterpart, and that the C++ version
of <stdatomic.h> defines _Atomic to std::atomic for easing cross-
language atomic use and std::atomic is an invalid enum base in C++.
(Note: we expose _Atomic in C++ even without including
<stdatomic,h>.)

Fixes #147736
2025-07-11 07:28:03 -04:00
Jim Lin
799270a807
[RISCV] Add missing indexed load/store intrinsic tests for zvfbfmin (#148097)
d6d33a0e60
adds missing indexed load/store which with other index size.
2025-07-11 13:43:04 +08:00
Himadhith
f9292c25cf
[NFC][PowerPC] Add test case for lockdown of vector compare greater than support for Zero vector comparisons (#147246)
NFC patch to add testcase for locking down the support of Zero vector
comparisons using the `vcmpgtuh (vector compare greater than unsigned
halfword)` instruction.
Currently `vcmpequh (vector compare equal unsigned halfword)` is in use.

---------

Co-authored-by: himadhith <himadhith.v@ibm.com>
Co-authored-by: Tony Varghese <tonypalampalliyil@gmail.com>
2025-07-11 11:10:22 +05:30
Craig Topper
9b81db7b32
[RISCV] Use source element type for the zero constant in IR for vwcvt intrinsic. (#148023)
The vwcvt intrinsic produces a vwadd with a scalar 0 for the RHS. We
should be using the element type of the source so that the 0 needs to be
widened.

The i32->i64 vwcvt previously failed on RV32 because the legalization
code doesn't expect to see an i64 type.
2025-07-10 22:39:43 -07:00
Jim Lin
60c14ac582 [RISCV] +zve64x is sufficient for the zvfbfmin and zvfbfwma intrinsic tests. NFC. 2025-07-10 15:41:59 +08:00
Jim Lin
69ff853729 [RISCV] Move the intrinsic tests for vfwmaccbf16 to zvfbfwma directory. NFC.
A follow-up commit for #147644.
2025-07-10 13:04:27 +08:00
Jim Lin
2eab6f9bb2 [RISCV] Move the intrinsic tests for vfwcvtbf16 and vfncvtbf16 to zvfbfmin directory. NFC.
A follow-up commit for #147644.
2025-07-10 09:13:22 +08:00
Jim Lin
84eeb23484
[RISCV] Implement intrinsics for XAndesVSIntLoad (#147767)
This patch implements clang intrinsic support for XAndesVSIntLoad.

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/04_andes_vector_int4_load_extension.adoc

Co-authored-by: Lino Hsing-Yu Peng <linopeng@andestech.com>
2025-07-10 09:11:29 +08:00
Paul Walker
a4d95c2717
[Clang][AArch64] Add missing builtins for __ARM_FEATURE_SME2p1. (#147362)
The quadword vector instructions introduced by SVE2p1/SME2p1 but the
builtins were not available to streaming mode.
    
RAX1 is available in streaming mode when SME2p1 is available.
2025-07-09 12:40:02 +01:00
Paul Walker
f676014955
[Clang][AArch64] Fix feature guards for SVE2p1 builtins available in SME{2}. (#147086)
Builtins that are enabled via +sve2p1 in non-streaming mode and +sme{2}
in streaming mode should also be enabled via +sve+sme{2} in
non-streaming mode and +sme+sve2p1 in streaming mode.
2025-07-09 11:05:51 +01:00
Jim Lin
356dcf2526
[RISCV] Split out the intrinsic tests for bfloat16 into a separate directory named zvfbfmin. NFC. (#147644)
To improve organization and maintainability, I'd like to split out the
intrinsic tests for zvfh, zvfhmin, zvfbfmin and zvfbfwma into separate
directories.
2025-07-09 14:25:09 +08:00
Brandon Wu
6ee375147b
[RISCV] Correct type lowering of struct of fixed-vector array in VLS (#147173)
Currently, struct of fixed-vector array is flattened and lowered to
scalable vector. However only struct of 1-element-fixed-vector array
should be lowered that way, struct of fixed-vector array of length >1
should be lowered to vector tuple type.

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/418/files#diff-3a934f00cffdb3e509722753126a2cf6082a7648ab3b9ca8cbb0e84f8a6a12edR555-R558
2025-07-08 21:14:40 -07:00
Ivan Kosarev
a7a7e95720
[AMDGPU][Clang] Support bfloat16 arithmetic. (#147541)
Co-authored-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2025-07-08 17:30:06 +01:00
Elvina Yakubova
bd6e9047dd
[LLVM][AArch64] Relax SVE codegen predicates for sm4 instructions (#147524)
Adds sve-sm4 to reference FEAT_SVE_SM4 without specifically enabling
SVE2.
2025-07-08 17:04:21 +01:00
Oleksandr T.
2e8e254d18
[Clang] include attribute scope in diagnostics (#144619)
This patch updates diagnostics to print fully qualified attribute names,
including scope when present.
2025-07-08 11:36:52 +03:00
Jim Lin
49683eefb2
[RISCV] Add missing intrinsicis vrgatherei16/vslideup/vslidedown support for Zvfbfmin (#146309)
LLVM IR intrinsicis for vrgatherei16/vslideup/vslidedown have been
supported in https://github.com/llvm/llvm-project/pull/146312.
2025-07-08 13:25:46 +08:00
Jim Lin
862c2fc26e [RISCV] Run mem2reg for riscv-xcvalu-c-api.c and riscv-xcvalu.c. NFC. 2025-07-08 11:04:10 +08:00
David Green
9fcea2e465 [ARM] Add neon vector support for roundeven
As per #142559, this marks froundeven as legal for Neon and upgrades the
existing arm.neon.vrintn intrinsics.
2025-07-04 15:27:33 +01:00
Adrian Vogelsgesang
de3c8410d8
[debuginfo][coro] Emit debug info labels for coroutine resume points (#141937)
RFC on discourse:
https://discourse.llvm.org/t/rfc-debug-info-for-coroutine-suspension-locations-take-2/86606

With this commit, we add `DILabel` debug infos to the resume points of a
coroutine. Those labels can be used by debugging scripts to figure out
the exact line and column at which a coroutine was suspended by looking
up current `__coro_index` value inside the coroutines frame, and then
searching for the corresponding label inside the coroutine's resume
function.

The DWARF information generated for such a label looks like:

```
0x00000f71:     DW_TAG_label
                  DW_AT_name    ("__coro_resume_1")
                  DW_AT_decl_file       ("generator-example.cpp")
                  DW_AT_decl_line       (5)
                  DW_AT_decl_column     (3)
                  DW_AT_artificial      (true)
                  DW_AT_LLVM_coro_suspend_idx   (0x01)
                  DW_AT_low_pc  (0x00000000000019be)
```

The labels can be mapped to their corresponding `__coro_idx` values
either via their naming convention `__coro_resume_<N>` or using the new
`DW_AT_LLVM_coro_suspend_idx` attribute. In gdb, those line numebrs can
be looked up using `info line -function my_coroutine -label
__coro_resume_1`. LLDB unfortunately does not understand DW_TAG_label
debug information, yet.

Given this is an artificial compiler-generated label, I did apply the
DW_AT_artificial tag to it. The DWARFv5 standard only allows that tag on
type and variable definitions, but this is a natural extension and was
also blessed in the RFC on discourse.

Also, this commit adds `DW_AT_decl_column` to labels, not only for
coroutines but also for normal C and C++ labels. While not strictly
necessary, I am doing so now because it would be harder to do so later
without breaking the binary LLVM-IR format

Drive-by fixes: While reading the existing test cases to understand how
to write my own test case, I did a couple of small typo fixes and
comment improvements
2025-07-04 10:44:35 +02:00
CarolineConcatto
7ee2c72a8e
[AArch64] Mark aarch64_set_fpmr as IntrWriteMem (#146353)
llvm.aarch64.set.fpmr only writes to inaccessible memory. Tag it with
the IntrWriteMem and IntrInaccessibleMemOnly properties so the optimiser
can treat it as a pure write.

The original patch did not add this property, causing the intrinsic to
be conservatively treated as readwrite. This commit fixes that.
2025-07-04 08:52:36 +01:00
Jim Lin
872eac7af0
[RISCV] Move vendor clang intrinsics tests to seperate directory. NFC. (#146862)
I'd like to ensure that the tests under
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/ 
only come from
https://github.com/riscv-non-isa/rvv-intrinsic-doc/tree/main/auto-generated
2025-07-04 13:27:51 +08:00
Jim Lin
61529d9e36
[RISCV] Remove implied extension Zvfhmin for XAndesVPackFPH (#146861)
XAndesVPackFPH can actually be used independently without requiring
Zvfhmin. Therefore, we remove the implicitly required Zvfhmin extension
from XAndesVPackFPH and imply that the f extension is sufficient.
2025-07-04 10:16:20 +08:00
Eli Friedman
2aa0f0a3bd
[AArch64] Add option -msve-streaming-vector-bits= . (#144611)
This is similar to -msve-vector-bits, but for streaming mode: it
constrains the legal values of "vscale", allowing optimizations based on
that constraint.

This also fixes conversions between SVE vectors and fixed-width vectors
in streaming functions with -msve-vector-bits and
-msve-streaming-vector-bits.

This rejects any use of arm_sve_vector_bits types in streaming
functions; if it becomes relevant, we could add
arm_sve_streaming_vector_bits types in the future.

This doesn't touch the __ARM_FEATURE_SVE_BITS define.
2025-07-03 13:44:38 -07:00
David Green
ec35065789 [ARM] Add neon vector support for rint
As per #142559, this marks frint as legal for Neon and upgrades the existing
arm.neon.vrintx intrinsics.
2025-07-03 21:27:48 +01:00
David Green
1f8f477bd0 [ARM] Add neon vector support for trunc
As per #142559, this marks ftrunc as legal for Neon and upgrades the existing
arm.neon.vrintz intrinsics.
2025-07-03 07:41:13 +01:00
Matt Arsenault
6ab7e52dd8
WebAssembly: Move validation of EH flags to TargetMachine construct time (#146634) 2025-07-03 07:25:38 +09:00
Adam Glass
ed27f18e32
__sys builtin support for AArch64 (#146456)
Adds support for __sys Clang builtin for AArch64

__sys is a long existing MSVC intrinsic used to manage caches, tlbs, etc
by writing to system registers:
* It takes a macro-generated constant and uses it to form the AArch64 SYS instruction which is MSR with op0=1. The macro drops op0 and expects the implementation to hardcode it to 1 in the encoding.
* Volume use is in systems code (kernels, hypervisors, boot environments, firmware)
* Has an unused return value due to MSVC cut/paste error

Implementation:
* Clang builtin, sharing code with Read/WriteStatusReg
* Hardcodes the op0=1
* Explicitly returns 0
* Code-format change from clang-format
* Unittests included
* Not limited to MSVC-environment as its generally useful and neutral
2025-07-02 10:17:01 -07:00
Matt Arsenault
7502af89fc
clang: Forward exception_model flag for bitcode inputs (#146342)
This will enable removal of a hack from the wasm backend
in a future change.

This feels unnecessarily clunky. I would assume something was
automatically parsing this and propagating it in the C++ case,
but I can't seem to find it. In particular it feels wrong that
I need to parse out the individual values, given they are listed
in the options.td file. We should also be parsing and forwarding
every flag that corresponds to something else in TargetOptions,
which requires auditing.
2025-07-02 09:39:46 +09:00
David Green
5332534b9c [ARM] Add neon vector support for ceil
As per #142559, this marks fceil as legal for Neon and upgrades the existing
arm.neon.vrintp intrinsics.
2025-07-01 15:41:10 +01:00
Nikita Popov
7e830f7671
[Clang] Partially fix m68k alignments (#144740)
As the data layout a few lines further up specifies, the int, long and
pointer alignment should be 16 instead of the default of 32.

The long long alignment is also incorrect, but that would require a
change to the data layout as well.

Comparison with GCC, which consistently uses 2 byte alignment:
https://gcc.godbolt.org/z/K3x6a7dEf At least based on some spot checks,
the changes to bit field layout also make use match GCC now.

This was found by https://github.com/llvm/llvm-project/pull/144720.
2025-07-01 09:06:41 +02:00
Ami-zhang
8d9cdb65f0
[Clang][LoongArch] Fixed incorrect _BitInt(N>64) alignment (#145297)
This patch makes determining alignment and width of BitInt to be target
ABI specific and makes it consistent with [Procedure Call Standard for
the LoongArch™ Architecture] for LoongArch target
(https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc).
2025-07-01 08:42:16 +08:00
David Green
6bd9ff04af [ARM] Add neon vector support for round
As per #142559, this marks fround as legal for Neon and upgrades the existing
arm.neon.vrinta intrinsics.
2025-06-30 17:15:26 +01:00
Kerry McLaughlin
33c8d5c686
[Clang][AArch64] Add FP8 variants of Neon store intrinsics (#145346)
Adds FP8 variants for existing VST1, VST2, VST3 & VST4 intrinsics.
2025-06-30 11:30:46 +01:00
amilendra
a72a0f415d
[Clang][AArch64] Add mfloat8_t variants of Neon load intrinsics (#145666)
Add mfloat8_t support for the following Neon load intrinsics.

- VLD1
- VLD1_X2
- VLD1_X3
- VLD1_X4
- VLD1_LANE
- VLD1_DUP
- VLD2
- VLD3
- VLD4
- VLD2_DUP
- VLD3_DUP
- VLD4_DUP
- VLD2_LANE
- VLD3_LANE
- VLD4_LANE
2025-06-30 11:19:14 +01:00
amilendra
5e732c09b2
[CLANG][AArch64] Add mfloat8_t support for more SVE load intrinsics (#145383)
Add mfloat8_t support for the following SVE load intrinsics.

- SVLD1RO
- SVLD1RQ
- SVLDFF1
- SVLDFF1_VNUM
- SVLDNF1
- SVLDNF1_VNUM
2025-06-30 11:18:50 +01:00
Ami-zhang
57f7e14b57 [LoongArch] Pre-commit test for _BitInt(N) 2025-06-30 15:37:33 +08:00
David Green
dcc9e36b18
[ARM] Add neon vector support for floor (#142559)
This marks ffloor as legal providing that armv8 and neon is present (or
fullfp16 for the fp16 instructions). The existing arm_neon_vrintm
intrinsics are auto-upgraded to llvm.floor.

If this is OK I will update the other vrint intrinsics.
2025-06-29 11:37:16 +01:00
Yao Zi
0ba456fcc6
[Clang][LoongArch] Match GCC behaviour when parsing FPRs in asm clobbers (#138391)
There're four possible formats to refer a register in inline assembly,

1. Numeric name without dollar sign ("f0")
2. Numeric name with dollar sign ("$f0")
3. ABI name without dollar sign ("fa0")
4. ABI name with dollar sign ("$fa0")

LoongArch GCC accepts 1 and 2 for FPRs before r15-8284[1] and all these
formats after the chagne. But Clang supports only 2 and 4 for FPRs. The
inconsistency has caused compatibility issues, such as QEMU's case[2].

This patch follows 0bbf3ddf5fea ("[Clang][LoongArch] Add GPR alias
handling without `$` prefix") and accepts FPRs without dollar sign
prefixes as well to keep aligned with GCC, avoiding future compatibility
problems.

Link:
https://gcc.gnu.org/cgit/gcc/commit/?id=d0110185eb78f14a8e485f410bee237c9c71548d
[1]
Link:
https://lore.kernel.org/qemu-devel/20250314033150.53268-3-ziyao@disroot.org/
[2]
2025-06-28 16:47:05 +08:00