[IRBuilder] Assert correct offset width for CreatePtrAdd (#238806)
Assert that the offset width matches the pointer index width. This is
supposed to become an IR well-formedness requirement when we switch to
ptradd, so we should start asserting it in the builder now.
Helpers like CreatePtrAddWith(Unsigned|Signed)Offset and
CreatePtrAddWith[SZ]ExtOrTrunc can be used to more conveniently create
ptradds with appropriately sized offsets.
Problematic uses of CreatePtrAdd were already adjusted in #238347.
[mlir][ODS] Include headers required by generated definitions (#238735)
Generated op, attribute and type definitions use C++ constructs that are
not declared by the headers included by the generated declarations. They
therefore relied on the surrounding source file to include these headers
before including the definitions.
This PR makes the definitions emit `#include` directives for these
headers at the start of the `GET_OP_CLASSES`, `GET_OP_DEFS_<N>` and
`GET_{ATTR,TYPE}DEF_CLASSES` sections.
Similar to #236155 but for the definitions file now. A hardcoded list
suffices in this case
[AMDGPU][NFC] Explicitly narrow conversions in subtarget and analysis passes (#215194)
This fixes 17 instances of MSVC warning C4244 and 3 of C4267 ("possible loss of data") across several files in llvm/lib/Target/AMDGPU.
Assisted-by: Claude <noreply at anthropic.com>
[ControlFlowHub] Only move PHI entries for redirected edges (#237917)
reconnectPhis moved the PHI entry for every incoming block of the hub
that is a predecessor of Out, even if that block's edge to Out does not
go through the hub. FixIrreducible creates such hubs: it redirects the
internal edges to the cycle header, but not the internal edges to the
other cycle entries. If a block in the cycle branches both to the header
and to another entry, the PHI entry for the direct edge was moved
anyway, giving either invalid IR ("PHINode should have one entry for
each predecessor") or a PHI that sees a stale value along the direct
edge. A self-loop on an entry that is not the header is one example.
Only move the entries for edges that are redirected through the hub.
This is the second problem described in #232399.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[llvm][TableGen] Resolve intra-record field references to `?`
An inconsistency existed in TableGen prior to this PR:
* Referencing a template argument whose value was `?` resolved to and propagated `?`
* Referencing a record whose field is `?` resolved and propagated `?`
However, referencing a field of the record being built remained unresolved, even in the final resolution pass.
This meant that code like:
```tablegen
class Self {
string str = ?;
assert !if(!initialized(str), !ne(str, ""), 1), "str must not be empty";
}
def : Self;
```
would fail to compile as `!initialized(str)` was left unfolded, and `!if` never received a bit value: https://godbolt.org/z/oGh1PzP88
Similar issues arose with other code such as with `!dump` etc.
This PR fixes that issue by resolving a record field to `?` if the record is complete and this is the final resolve pass. As a follow-on effect, some places that previously relied on being kept unresolved now resolve to `?` which required implementing semantics for `?.field` accesses (instead of the current crash using `llvm_unreachable`). This PR therefore also defines `?.field` as resolving to `?`, similar to `?{0}` or `!cast`.
[lldb][test] Fix flaky missing-oso.cpp that mixed stderr and stdout (#238110)
`missing-oso.cpp` expects `error:` line is before
`(lldb) image dump separate-debug-info --errors-only`, but the error
message is
from the event handler thread. The main thread does not wait for that
event and runs the next `-o` command, so the `error:` line can land
before, between or after the `image dump` echo and output. `2>&1` joins
both writers in one pipe and nothing orders them.
The fix does:
- drop `2>&1` from the `%t.two` run and send stderr to `%t.two.err`,
use two `FileCheck` to check each,
- `--implicit-check-not=error:` on the stderr check replaces both
`TWO-NOT: error:` lines, so the error must still appear exactly once,
- `-l 28` is now `-l 30`, the new line of `main`
[mlir][OpenMP] Add memory effects of omp.single (#237929)
Added a new attribute for the copyprivate clause
`copyprivate_assume_bounded_recipe_effects`. Applied when the
copyprivate variables satisfy certain constraints.
Updated helper functions for applying bounded recipe attributes.
Add direct memory effect tests, CSE & canonicalisation tests.
Add tests for correct application of the
`copyprivate_assume_bounded_recipe_effects` attribute.
AI-Assisted-by: Codex (OpenAI)
[libc] Implement copy_file_range in unistd (#236914)
This patch implements `copy_file_range` in LLVM libc under `unistd` for
Linux systems (kernel 4.5+).
- Implements internal syscall wrapper `copy_file_range` using
`ErrorOr<ssize_t>`.
- Adds public entrypoint in `unistd` with Doxygen documentation header.
- Adds unit tests verifying in-kernel data copying, offset tracking, and
error handling (`EBADF`, `EINVAL`).
- Updates entrypoints across Linux targets (`x86_64`, `aarch64`, `arm`,
`riscv`).
Fixes #236897.
[AArch64] NFC: Add pre-commit tests for SVE AND-XOR/XOR-AND combining
Add tests for patterns like AND(a, XOR(a, b)) and XOR(a, AND(a, b))
that could be replaced by `BIC(a, b)`.
Cover various cases involving plain LLVM AND/XOR instructions and
sve.and/eor[.u/z] intrinsics.
Add negative test cases where the instruction sequence can't be replaced
by BIC.
[libc][math] Fix `cospif16` error handling (#236371)
Follow up of https://github.com/llvm/llvm-project/pull/235780, tested
`cospif16` with CORE-MATH's exhaustive checker in all four rounding
modes. With `CORE_MATH_SUPPORT_ERRNO` and `CORE_MATH_CHECK_INEXACT`
enabled.
[flang][NFC] Narrow the -Waix-compat suppression in real.h to word_ (#238651)
`real.h` suppresses `-Waix-compat` for the whole `Real` class template
with `#if defined(_AIX)` and `#pragma GCC diagnostic ignored
"-Waix-compat"`. GCC does not know that warning, so a GCC build on AIX
would get a `-Wpragmas` warning ("unknown option after '#pragma GCC
diagnostic' kind") in every file that includes `real.h`, and an error
with `-Werror`.
This switches to the form #238605 and #238635 use for
`RealValue::opaque_` in `real-value.h`: a clang-only suppression around
`word_`, the one member the diagnostic is attached to, with a comment
explaining why the warning does not apply. No functional change.
Assisted-by: AI