531321 Commits

Author SHA1 Message Date
Matthias Springer
a810141281
[mlir][memref] Add runtime verification for memref.assume_alignment (#130412)
Implement runtime verification for `memref.assume_alignment`.
2025-03-19 21:23:40 +01:00
Justin Cady
0827e3aae6
[Coverage] Fix region termination for GNU statement expressions (#130976)
Calls to __noreturn__ functions result in region termination for
coverage mapping. But this creates incorrect coverage results when
__noreturn__ functions (or other constructs that result in region
termination) occur within [GNU statement expressions][1].

In this scenario an extra gap region is introduced within VisitStmt,
such that if the following line does not introduce a new region it
is unconditionally counted as uncovered.

This change adjusts the mapping such that terminate statements
within statement expressions do not propagate that termination
state after the statement expression is processed.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

Fixes #124296
2025-03-19 16:22:26 -04:00
Vlad Serebrennikov
bdca412681
[clang] Auto-detect which newline style to use for cxx_dr_status.html (#132045)
Aaron reported that `make_cxx_dr_status` replaces all newlines in
`cxx_dr_status.html`, which makes for a huge diff. On Windows, we can't
be compatible with all `autocrlf` modes at once, so this patch adds
autodetection of newline style using the existing file, if one is
present (which should be the case for all reasonable use cases).
2025-03-20 00:11:38 +04:00
David Olsen
4e3440d9dd
[CIR] Upstream a basic version of class LexicalScope (#131945)
Upstream the parts of class `CIRGenFunction::LexicalScope` that
implement function return values. There is a bit of other functionality
in here, such as the implicit `cir.yield` at the end of a non-function
scope, but this is mostly about function returns.

The parts of `LexicalScope` that handle calling destructors, switch
statements, ternary expressions, and exception handling still need to be
upstreamed.

There is a change in the generated ClangIR (which is why many of the
tests needed updating). Return values are stored in the
compiler-generated variable `__retval` rather than being passed to the
`cir.return` op directly. But there should be no change in the behavior
of the generated code.
2025-03-19 12:56:41 -07:00
Peter Klausler
a0ae88bffe
[flang] Disable 3 x86-64 tests on non-x86-64 (#132088)
Now that COMPLEX(KIND=10) is properly disabled where 80-bit
floating-point types are not available, three tests that were not
peculiar to x86-64 are failing on other targets. Make them specific to
x86-64.
2025-03-19 12:52:59 -07:00
Augusto Noronha
7cabcdb2d2
[debuginfo-tests] Use built lldb for testing if available (#131681)
The cross-project-tests's debuginfo-tests don't rely on lldb being built
to run. While this is a good, a bug in the system lldb can cause a test
to fail with no way of fixing it. This patch makes it so the tests use
the built lldb instead if it's available.
2025-03-19 12:42:47 -07:00
Ayokunle Amodu
02744c5010
[clang][diagnostics] Update note_constexpr_invalid_cast to use enum_select and adjust its uses (#130868)
Handles #123121

This patch updates `note_constexpr_invalid_cast` diagnostic to use
`enum_select` instead of `select,` improving readability and reducing
reliance on magic numbers in caller sites.
2025-03-19 12:36:08 -07:00
David Green
b0876994eb
[AArch64][GlobalISel] Clean up CTLZ vector type legalization. (#131514)
Similar to other operations, s8, s16 and s32 vector elements are clamped
to legal vector sizes, but in this case s64 are scalarized to use the
gpr instructions. This allows vector types to split as opposed to
scalarizing.
2025-03-19 19:28:36 +00:00
Joseph Huber
b37be0e734
[Offload] Handle BoundArchitecture for non-GPU targets (#132037)
Summary:
Offloading tends to have a bound architecture that directly correponds
to the `-mcpu` argument for that embedded job. This is currently handled
by the GPU offloading toolchains, but is ignored by the CPU ones. This
is problematic for languages like SYCL or OpenMP which permit
'offloading' to non-GPU targets. This patch handles this by putting
generic handling in the GCC toolchain for those languages.

I would've made this fully generic but it regressed some HIP sanitizer
tests because their use-case is really weird. This also only goes for
the languages that inherit from 'generic_gcc`. I could've made it in the
base class, but I felt like it wasn't necessary as we only support
offloading based off of this toolchain. In the future if we need it we
can move it around.

---------

Co-authored-by: Nick Sarnie <nick.sarnie@intel.com>
2025-03-19 14:16:25 -05:00
Peter Klausler
6b9716b7f4
[flang] Catch bad usage case of whole assumed-size array (#132052)
Whole assumed-size arrays are generally not allowed outside specific
contexts, where expression analysis notes that they can appear. But
contexts can nest, and in the case of an actual argument that turns out
to be an array constructor, the permission to use a whole assumed-size
array must be rescinded.

Fixes https://github.com/llvm/llvm-project/issues/131909.
2025-03-19 12:02:34 -07:00
Eric Astor
3c657ceef9
[ms] [llvm-ml] Add llvm-ml64 alias (#131854)
Rather than requiring users to pass `-m64` to the `llvm-ml` driver to
get 64-bit behavior, we add the `llvm-ml64` alias, matching the behavior
of `ML.EXE` and `ML64.EXE`.

The original flavor/bitness flags still work, but the alias should make
some workflows easier.

NOTE: The logic for this already existed in the code; we're just finally
adding the build/install instructions to match.
2025-03-19 15:02:17 -04:00
Peter Klausler
7f7d7d552b
[flang] Use local name for structure constructor (#132047)
When reinterpreting an ambiguously parsed function reference as a
structure constructor, use the original symbol of the type in the
representation of the derived type spec of the structure constructor,
not its ultimate resolution. The distinction turns out to matter when
generating module files containing derived type constants as
initializers when the derived types' names have undergone USE
association renaming.

Fixes https://github.com/llvm/llvm-project/issues/131579.
2025-03-19 12:02:03 -07:00
Peter Klausler
b99dab2587
[flang] Exempt construct entities from SAVE check for PURE (#131383)
A PURE subprogram can't have a local variable with the SAVE attribute.
An ASSOCIATE or SELECT TYPE construct entity whose selector is a
variable will return true from IsSave(); exclude them from the local
variable check.

Fixes https://github.com/llvm/llvm-project/issues/131356.
2025-03-19 12:01:18 -07:00
Peter Klausler
9f284e1784
[flang] Disabling REAL kinds must also disable their COMPLEX (#131353)
When disabling kinds of REAL in the TargetCharacteristics, one must also
disable the corresponding kinds of COMPLEX.

Fixes https://github.com/llvm/llvm-project/issues/131088.
2025-03-19 12:00:51 -07:00
Peter Klausler
329bfa91b0
[flang] Fix crash in CO_REDUCE semantics (#131211)
A std::optional<> value was being accessed without first ensuring its
presence.
2025-03-19 12:00:23 -07:00
Peter Klausler
3f04fb42aa
[flang] Complete semantic checks for FORM TEAM (#131022)
Add remaining checking for the FORM TEAM statement, complete and enable
a test.
2025-03-19 11:59:59 -07:00
Peter Klausler
1dc397deed
[flang] Enforce control flow restrictions on CHANGE TEAM (#131013)
Like DO CONCURRENT and CRITICAL constructs, control flow into and out of
a CHANGE TEAM construct is disallowed.
2025-03-19 11:59:39 -07:00
Peter Klausler
abebac5b86
[flang] Dig deeper to find more EVENT_TYPE/LOCK_TYPE misuse (#130687)
Only objects may have these types, or have potential subobject
components with these types.
2025-03-19 11:59:18 -07:00
Peter Klausler
587f997db7
[flang] Catch C15104(4) violations when coindexing is present (#130677)
The value of a structure constructor component can't have a pointer
ultimate component if it is a coindexed designator.
2025-03-19 11:58:59 -07:00
Andreas Jonson
2d1e64669e
[InstCombine] Reuse common code between foldSelectICmpAndBinOp and foldSelectICmpAnd. (#131902)
The commit that was removed from
https://github.com/llvm/llvm-project/pull/127905 due to the conflict
with https://github.com/llvm/llvm-project/pull/128741.

The use of common code results in that the foldSelectICmpAndBinOp also
use knownbits in the same way as was added for foldSelectICmpAnd in
https://github.com/llvm/llvm-project/pull/128741.

proof for the use of knowbits in foldSelectICmpAndBinOp:
https://alive2.llvm.org/ce/z/RYXr_k
2025-03-19 19:57:48 +01:00
Jan Svoboda
da1c19af7e [clang][deps] Add missing include
Discovered by https://green.lab.llvm.org/job/llvm.org/job/clang-stage2-Rthinlto/588.
2025-03-19 11:31:54 -07:00
Philip Reames
ca0fe95a54 [RISCV] Add tests for a case mentioned in review of pr130430 2025-03-19 11:21:28 -07:00
Michael Spencer
e1f4daf836
[clang][modules] Correctly set module map systemness (#131940)
This uses the systemness of the module map instead of of the Module
instance, as doing otherwise could incorrectly parse the other modules
in that module map as system.

This is still correct as the only ways to get a system module are by the
module map being in a system path, or the module having the [system]
attribute, both of which are handled here.

This makes it so that the systemness of a module is deterministic
instead of depending on the path taken to build it.
2025-03-19 11:19:25 -07:00
Michael Maitland
15c96d6874 [RISCV] Update unrelated bad code from test case
In #131684, we found that the code generated a bnez zero, which is always
false. Since this is unrelated to the regression the test case was added for,
we change the IR here to avoid this test case from having this silly branching
pattern. This will help this test case avoid any changes as we do work to
optimize branches in the RISC-V backend.
2025-03-19 11:09:49 -07:00
Louis Dionne
44744301e9 [libc++][docs] Minor update to the benchmark documentation 2025-03-19 14:02:34 -04:00
A. Jiang
053a714add
[libc++] Implement part of P2562R1: constexpr ranges::inplace_merge (#131947)
Drive-by changes:
- Consistently mark `std::__inplace_merge::__inplace_merge_impl`
`_LIBCPP_CONSTEXPR_SINCE_CXX26`.
- This function template is only called by other functions that becomes
constexpr since C++26, and it itself calls `std::__inplace_merge` that
is constexpr since C++26.
- Unblock related test coverage in constant evaluation for
`stable_partition`, `ranges::stable_sort`, `std::stable_sort`,
`std::stable_partition`, and `std::inplace_merge`.
2025-03-20 01:59:32 +08:00
Igor Kudrin
825460a772
[lldb/gdb-remote] Do not crash on an invalid server response (#131979)
An invalid RLE sequence in the received packet could result in an
out-of-bounds reading that could cause a crash.
2025-03-19 10:51:27 -07:00
Krishna Pandey
bda87e0a09
[libc][sched] Implement CPU_ZERO, CPU_ISSET, CPU_SET macros (#131524)
This PR implements the following macros for `sched.h`:
- `CPU_ZERO`
- `CPU_ISSET`
- `CPU_SET`

Fixes #124642

---------

Signed-off-by: krishna2803 <kpandey81930@gmail.com>
2025-03-19 13:44:41 -04:00
Joel Wee
0260bcb5f4 Fix after f3dcc0f 2025-03-19 17:37:51 +00:00
Joel Wee
f84bc1ca43 Fix after 2b8f88791502 2025-03-19 17:32:36 +00:00
Sergio Afonso
ac9e4e9b33
[Flang][OpenMP] Simplify entry block creation for BlockArgOpenMPOpInterface ops, NFC (#132036)
This patch adds the `OpWithBodyGenInfo::blockArgs` field and updates
`createBodyOfOp()` to prevent the need for `BlockArgOpenMPOpInterface`
operations to pass the same callback, minimizing chances of introducing
inconsistent behavior.
2025-03-19 17:29:40 +00:00
Donát Nagy
03adb0ec7d
[analyzer] Remove deprecated option VirtualCall:PureOnly (#131823)
VirtualCallChecker.cpp implements two related checkers:
- `optin.cplusplus.VirtualCall` which reports situations when
constructors or destructors call virtual methods (which is bugprone
because it does not trigger virtual dispatch, but can be legitmate).
- `cplusplus.PureVirtualCall` reports situations when constructors or
destructors call _pure_ virtual methods, which is an error.

Six years ago these two bug types were both reported by the same checker
(called `optin.cplusplus.VirtualCall`) and it had an option called
`PureOnly` which limited its output to the pure case.

When (in 2019) the two checker parts were separated by the commit
d3971fe97b64785c079d64bf4c8c3e2b5e1f85a1, the option `PureOnly` was
preserved for the sake of compatibility, but it is no longer useful
(when it is set to true, it just suppresses all reports from
`optin.cplusplus.VirtualCall`) so it was marked as deprecated.

I'm removing this deprecated option now because it is no longer relevant
and its presence caused minor complications when I was porting
`VirtualCallChecker.cpp` to the new multipart checker framework
(introduced in 27099982da2f5a6c2d282d6b385e79d080669546).
2025-03-19 18:22:00 +01:00
Mark de Wever
566916131e
[libc++][CI] Use latest Docker image. (#130497)
This image was updated in #130433.
2025-03-19 18:16:46 +01:00
Alexander Shaposhnikov
297f0b3f4c
[CudaSPIRV] Allow using integral non-type template parameters as attribute args (#131546)
Allow using integral non-type template parameters as attribute arguments
of
reqd_work_group_size and work_group_size_hint.

Test plan:
ninja check-all
2025-03-19 10:11:18 -07:00
Kerry McLaughlin
d09ecb07c2
[AArch64][CodeGen] Add +lsfe atomicrmw tests where the result is unused. (#132022)
Following the discussion on #131174, update generate-tests.py script to
emit atomicrmw tests where the result is unused and add a note to
explain why these do use ST[F]ADD.
2025-03-19 17:10:02 +00:00
Sarah Spall
dd17c649ab
[HLSL] Implement min and max overloads using templates (#131666)
Replace min and max overload implementation using macros with one using
templates.
Enable overloads of the forms:
 vector<T,N> min/max(vector<T,N> p0, T p1)
 vector<T,N> min/max(T p0, vector<T,N> p1)
 Add new tests.
Closes #131170
2025-03-19 09:57:46 -07:00
Reid Kleckner
5475834737
[sancov] Use comdats when one already exists (#131929)
This code avoids adding comdat groups to interposable linkage types
(weak, linkonce (non-ODR)) to avoid changing semantics, since comdat
elimination happens before weak/strong prevailaing symbol resolution.
However, if the function is already in a comdat, we can add to the group
without changing the semantics of the linked program.

Fixes an issue uncovered in PR #126240
2025-03-19 09:47:32 -07:00
Andy Kaylor
39ce99589b
[CIR] Upstream cir-canonicalize pass (#131891)
This change introduces the cir-canonicalize pass. This is a simple
cir-to-cir transformation that eliminates empty scopes and redundant
branches. It will be expanded in future changes to simplify other
redundant instruction sequences.

MLIR verification and mlir-specific command-line option handling is also
introduced here.
2025-03-19 09:42:03 -07:00
Krzysztof Parzyszek
cd26dd5595
[flang][OpenMP] Use OmpDirectiveSpecification in simple directives (#131162)
The `OmpDirectiveSpecification` contains directive name, the list of
arguments, and the list of clauses. It was introduced to store the
directive specification in METADIRECTIVE, and could be reused everywhere
a directive representation is needed.
In the long term this would unify the handling of common directive
properties, as well as creating actual constructs from METADIRECTIVE by
linking the contained directive specification with any associated user
code.
2025-03-19 11:34:40 -05:00
Peng Liu
b350bc2c0b
[libc++] Verify forward_list self-merging is a no-op (#129985)
https://wg21.link/LWG3088 requires that `forward_list::merge()` is a no-op when passed
`*this`, which aligns with the behavior of `list::merge`. Although libc++'s implementation
of `forward_list::merge()` already meets this requirement, there were no tests to verify
this behavior. This patch adds the necessary tests to ensure that self-merging remains a
no-op and prevents any future regressions on this.

Closes #104942.
2025-03-19 12:28:11 -04:00
Kristof Beyls
9a078a372e
2024 Security Group Transparency Report (#132011)
This adds the Security Response Group's transparency report for 2024.
2025-03-19 16:26:41 +00:00
Peng Liu
617646ab8d
[libc++] Use __alloc_traits in <deque> whenever it is available for consistency (#126595)
When an allocator-aware container already defines a member type alias
`__alloc_traits` for `std::allocator_traits<allocator_type>`, we should
consistently use `__alloc_traits`. Mixing the usage of both
`__alloc_traits` and `std::allocator_traits` can lead to inconsistencies
and confusion.
2025-03-19 12:23:35 -04:00
LLVM GN Syncbot
99997d717b [gn build] Port 7af0bfe62fff 2025-03-19 16:17:16 +00:00
John Harrison
7af0bfe62f
[lldb-dap] Ensure logging statements are written as a single chunk. (#131916)
I noticed this while debugging some unit tests that the logs
occasionally would intersperse two log statements.

Previously, it was possible for a log statement to have two messages
interspersed since the timestamp and log statement were two different
writes to the log stream.

I created a Log helper to ensure we have a lock while attempting to write
to the logs.
2025-03-19 09:16:53 -07:00
James Y Knight
25613b32ab NFC: fix whitespace lint in bazel file. 2025-03-19 12:16:09 -04:00
Peng Liu
70480fcff6
[libc++] Validate vector<bool> copy/move-assignment operators in realistic scenarios (#119817)
The existing tests for `vector<bool>` copy- and move-assignment
operators are limited to 3 bits only, which are inadequate to cover
realistic scenarios. Most `vector<bool>` operations have code paths that
are executed only when multiple storage words are involved, with each
storage word typically comprising 64 bits on a 64-bit platform.
Furthermore, the existing tests fail to cover all combinations
`POCCA`/`POCMA`, along with different allocator equality and/or
reallocation scenarios, leaving some critical code paths untested.

This patch enhances the test coverage by introducing new tests covering
up to 5 storage words, ensuring that partial words in the front or tail,
and whole words in the middle are all properly tested. Moreover, these
new tests ensure that the copy- and move-assignment operators are tested
under all combinations of `POCCA`/`POCMA` and various allocator equality
scenarios, both with or without reallocations.
2025-03-19 12:08:20 -04:00
Peng Liu
029cb8aff1
[libc++] Fix copy_backward for vector<bool> with small storage types (#131560)
This patch fixes an issue in libc++ where `std::copy_backward` and
`ranges::copy_backward` incorrectly copy `std::vector<bool>` with small
storage types (e.g., `uint8_t`, `uint16_t`). The problem arises from
flawed bit mask computations involving integral promotions and sign-bit
extension, leading to unintended zeroing of bits. This patch corrects
the bitwise operations to ensure correct bit-level copying.

Fixes #131718.
2025-03-19 11:58:02 -04:00
TatWai Chong
1456eabca8
[mlir][tosa] Finalize profile-based validation for TOSA v1.0 (#131208)
- When the operand type of an operation changes to a profile-dependent
type, the compliance metadata must be updated. Update compliance check
for the following:
- CONV2D, CONV3D, DEPTHWISE_CONV2D, and TRANSPOSE_CONV2D, as zero points
have changed to variable inputs.
  - PAD, because pad_const has been changed to a variable input.
  - GATHER and SCATTER, as indices has changed to index_t.
- Add an int16 extension check for CONCAT.
- Add a compliance check for COND_IF, WHILE_LOOP, VARIABLE,
VARIABLE_READ, and VARIABLE_WRITE.
- Correct the profile requirements for IDENTITY, TABLE, MATMUL and
LOGICAL-like operations.
- Remove unnecessary checks for non-v1.0 operations.
- Add condition requirements (anyOf and allOf) to the type mode of
metadata for modes that have multiple profile/extension considerations.
2025-03-19 08:57:22 -07:00
Peng Liu
a5b3d3a03f
[libc++] Fix {std, ranges}::copy for vector<bool> with small storage types (#131545)
The current implementation of `{std, ranges}::copy` fails to copy
`vector<bool>` correctly when the underlying storage type
(`__storage_type`) is smaller than `int`, such as `unsigned char`,
`unsigned short`, `uint8_t` and `uint16_t`. The root cause is that the
unsigned small storage type undergoes integer promotion to (signed)
`int`, which is then left and right shifted, leading to UB (before
C++20) and sign-bit extension (since C++20) respectively. As a result,
the underlying bit mask evaluations become incorrect, causing erroneous
copying behavior.

This patch resolves the issue by correcting the internal bitwise
operations, ensuring that `{std, ranges}::copy` operates correctly for
`vector<bool>` with any custom (unsigned) storage types.

Fixes #131692.
2025-03-19 11:55:51 -04:00
dong-miao
480202f0d1
[RISCV] Add Zilsd and Zclsd Extensions (#131094)
This commit adds the Load/Store pair instructions (Zilsd) and Compressed
Load/Store pair instructions (Zclsd).

[Specification
link](https://github.com/riscv/riscv-isa-manual/blob/main/src/zilsd.adoc).
2025-03-19 08:53:41 -07:00