[Flang][OpenMP] Add nsw flags to OMPIRBuilder loop IV arithmetic (#214165)
- Extended the support of `-fno-wrapv` flag setting from frontend to the
OMPIRBuilder via `omp.integer_wrap_around` module attribute.
- When this attribute `omp.integer_wrap_around` is false (-fno-wrapv),
the OMPIRBuilder attaches `nsw` to all loop IV arithmetic.
- This enables SCEV to form proper `AddRec` expressions for the loop IV,
allowing `IndVarSimplify pass` to widen it from i32 to i64 and eliminate
the in-loop sext instruction which helps some backend optimizations and
also producing IR similar to Clang.
Fixes https://github.com/llvm/llvm-project/issues/213718
[mlir][complex] Fix signed zero miscompile with complex.add fold (#212751)
The pattern `a + complex.constant<0.0, 0.0>` currently gets folded to
`a`. This is incorrect when e.g. `a=(-0.0, 1.0)` since as per the IEEE
spec and what's done in the arith dialect `0.0 + (-0.0) = 0.0 !=
(-0.0)`.
This PR changes the pattern to `a + complex<-0.0, -0.0> -> a` and
updates the associated test.
[flang][MIF] Update prif_coarray_handle in accordance with PRIF 0.8 #214080 (#214747)
In PRIF revision 0.8, the representation of `prif_coarray_handle` was
changed. This PR updates this representation for this type and updates
the MIFOpConversion pass for the relevant operations.
Fixes issue #214080
A minor fix has been made to the deallocation to ensure that, on the
Flang side, the variable is properly deallocated, since previously the
deallocation was only performed at the `coarray_handle` level.
(cherry picked from commit 066dfd519323589e89847e65a40d4a9836f61188)
[InstCombine] Fold X + ((-X) & (C - 1)) to (X + C - 1) & -C (#215122)
`X + ((-X) & (C - 1)) --> (X + C - 1) & -C` for power-of-two `C`.
This is the align-up idiom as allocators usually write it. `-C == ~(C -
1)`, so
the mask is just the inverted low-bit mask.
No wrapping flags needed - it verifies without nsw/nuw on either side.
Flags on
the original add are dropped.
The other fold in the issue, `X + (X | -X) --> X & (X - 1)`, already
exists in
visitAdd, so this only adds the second one.
One case that doesn't hit this: `C = 2`. InstCombine turns `(-X) & 1`
into
`X & 1` first, so the neg is already gone.
[3 lines not shown]
[Support] Optimize ScaledNumbers::multiply64 (#215172)
The 128-bit product is assembled from four 32x32 cross products.
(4 imul on x86-64). Use `__uint128_t` where available.
[BFI] Index iterative inference by block number (#215179)
`applyIterativeInference` builds a DenseMap assigning each participating
block a position in a dense vector. Block numbers already provide that
index, and BFI uses them elsewhere.
[clang][CodeGen] Never collect return value alloca into coroutine frame (#213580)
The coroutine return value must not reside within the coroutine frame;
otherwise, a heap-use-after-free error will occur, as the frame is
destroyed before the return is completed.
In the front end, emit `coro_outside_frame` metadata for the
return-value alloca so that it does not accidentally enter the frame.
Close #49843
[CIR] Derive record padding from the member marks
Now that every record member carries a kind, the record-level `padded`
bool is redundant: a record is padded exactly when some member is marked
pad. Drop the parameter and answer `getPadded()` from the marks.
That also fixes `computeStructDataSize`, which had read the bool as "the
last member is tail padding" and so dropped a real member when padding
sat between two data members. It now drops the trailing run of pad
members instead.
Assisted-by: Cursor / claude-opus-5
[AMDGPU] Prevent GFX11 VALU Hazard Wait merging into terminators (#214935)
Fix an issue where a pending wait would be moved into the block
terminators causing a validation error.
Flush all pending waits and exit optimization loop when reaching first
terminator within a block.
[ORC] Reimplement EPCGenericMemoryAccess on RTBridge proxies (#215160)
Move EPCGenericMemoryAccess off ExecutionSession::callSPSWrapperAsync
and onto rt::Proxy objects. The FuncAddrs struct (13 ExecutorAddrs)
becomes Funcs (13 rt::Proxy members), and each access method collapses
to a single proxy call: the ProxySpec's dispatch now handles argument
serialization and the (Error, Result) -> Expected result plumbing that
was previously open-coded in each method.
Funcs members are protocol-agnostic rt::Proxy values, so a client can
populate a Funcs for a different protocol and pass it to the (public)
constructor. A new static Create(ES) provides the SPS convenience path,
resolving the proxies from the bootstrap JITDylib. The proxy types are
named once as rt::Mem*Proxy aliases in Proxy.h (beside the existing
Call*Proxy aliases) and reused by both the Funcs struct and the
memory-access ProxySpecs added to RTBridge/SPS/ProxySpecs.h.
InProcessEPC and SimpleRemoteEPC now just call
EPCGenericMemoryAccess::Create.
[4 lines not shown]
[LoongArch][LASX] Fix fptosi/fptoui from <4 x float> to <4 x i64> (#214621)
These were lowered through a 128-bit f32 to i32/u32 conversion followed
by a sign/zero extension, which silently clamps any finite input that
does not fit in i32/u32 instead of producing the correct 64-bit integer.
Convert directly with xvftintrzl.l.s for the signed case. For the
unsigned case there is no f32 -> u64 lane conversion in LASX, so widen
to f64 first (which is exact) and convert with xvftintrz.lu.d. Both
forms use xvpermi.d to move the inputs into the low 64 bits of each
128-bit lane, as required by these lane-wise conversions.
Built and verified on Arch Linux for Loong64:
https://github.com/lcpu-club/loongarch-packages/pull/974. Both the LLVM
side and the Highway test suite that discovered the bug have passed
verification.
Assisted by Kimi K3 AI agent.
Fixes https://github.com/llvm/llvm-project/issues/214605
[SandboxVec][Legality] Fix a warning when build with GCC (NFC) (#214907)
Remove `maybe_unused` attribute from ResultReason member, beacuse it
used in `getReason` method. This PR fixes:
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h:186:33:
error: ‘maybe_unused’ attribute ignored [-Werror=attributes]
186 | [[maybe_unused]] ResultReason Reason;
| ^~~~~~
[ORC] Construct EPCGenericMemoryAccess from ExecutionSession. (#215097)
Construct EPCGenericMemoryAccess objects from ExecutionSessions, rather
than ExecutorProcessControl objects. This is a step towards migrating
EPCGenericMemoryAccess off of raw callSPSWrapper* calls and on to the
new Proxy objects (d99bd3ed157).
[PowerPC][AIX] Reject .weak_definition like ELF (#156072)
weak_definition is a Mach-O-specific directive and is not supported on
XCOFF. Previously it crashed the XCOFF streamer via report_fatal_error
in emitSymbolAttribute. Return false for MCSA_WeakDefinition like
MCELFStreamer does, so the parser rejects it with the same diagnostic as
ELF.
Revert "[libc] Add realpath to linux entrypoints" (#215156)
Reverts llvm/llvm-project#212925, the tests assume that `/tmp` is a
real, valid directory on the system, which is not true for all
buildbots. `libc-riscv32-qemu-yocto-fullbuild-dbg` in particular seems
to have a symlink or similar from `/tmp` to `/var/volatile/tmp`. See
https://github.com/llvm/llvm-project/pull/212925#issuecomment-5234167255.