[mlir][scf] Fix front-peel unsigned loops with at most one iteration (#231542)
For unsigned loops with constant bounds, read the bounds as `APInt` and
skip peeling when `ub <= lb` or `ub - lb <= step` (compared unsigned),
bail out if failed.
from #231100 and fixes #231541
[mlir][bufferization] Fix bug when moving dealloc operation (#229296)
This commit fixes bugs that were identified in #227975.
The core reason is that the existing code does not perform checks on
wether it is safe to move `dealloc`, and would blindly do a
`deallocOp->moveAfter(lastUser)`.
We have to check that where we move it to is:
- After all the operand definitions that the `dealloc` uses
- Before any of ops that consume the results produced by the `dealloc`
This is what the `findValidInsertionPoint` method does.
AI disclosure: assistance from copilot to navigate code base, and plan
out the code. Was still written by me.
[CIR] Support statements after co_return (#231046)
Emit code for statements after a co_return in a new block, which may be
reachable through a label. Unlike classic codegen, this patch still
keeps unreachable code alive through flattening to stay closer to the
source code, though this could still be changed.
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc++] Create a reusable workflow for submitting to LNT (#232127)
This allows reusing the same logic in other workflows, and most
importantly it will allow separating concerns (such as API keys) by
making them accessible only to the workflow that needs to submit to LNT,
not the workflows that produce the benchmark data.
[CIR] Handle lifetime-extended temporaries in loop conditions (#231469)
The lifetime of temporaries used to initialize a loop condition variable
needs to be extended to the end of each iteration. Example:
```c++
ConvertibleToBool get_ctb();
while(ConvertibleToBool const& cond = get_ctb()) {
...
} // destroy temporary here, then reevaluate
```
Capture the destructor cleanups so temporary lifetimes get extended.
Assisted-By: Claude Opus 5.5 <noreply at anthropic.com>
[orc-rt] Add C addressing regression tests for BSS. (#232137)
Add static/global x load/store tests for zero-initialized data, plus
load and store tests of the last element of a 1MB BSS array, which catch
zero-fill memory that is undersized (e.g. a single page) or only partly
writable.
[DAGCombiner] Use willNotOverflowAdd in addition to the nsw flag in DAGCombiner::visitAVG. (#231347)
I encountered a case in our downstream compiler where we generated
an avgfloors but a later reassociation brought an add with 1 closer
to the avgfloors, exposing an opportunity to use avgceils.
Unfortunately, we didn't have the nsw flag because DAGCombiner
doesn't infer it.
We could do this for avgflooru/avgceilu too, but I don't have a test
case yet. Converting the signed test I have to unsigned by using zext
still ends up picking avgfloors instead of avgflooru.
[llvm-objcopy] Stream ELF output to regular files
Write ELF output directly to seekable regular files instead of first allocating a buffer for the entire output. Keep buffered output for stdout and other non-seekable streams.
Use separate buffered and file-backed output implementations. Serialize regenerated metadata sequentially, seeking once per output range, and report sticky file errors after writing finishes. Truncate and extend seekable output up front so unwritten layout gaps read as zero without being materialized; explicitly overwrite only removed section contents within copied segments.
On a synthetic stamping-style ELF containing a 1 GiB payload, three warm-cache no-op copies had median peak RSS of 2,102,916 KiB before and 1,053,844 KiB after (49.9% lower). Median wall time improved from 1.06 s to 0.77 s, and the outputs were byte-identical.
Co-authored-by: Jeremy Braun <jtbraun at meta.com>
Co-authored-by: Fangrui Song <i at maskray.me>
Assisted-by: OpenAI Codex
[Support] Support seekable temporary output streams
Use raw_fd_stream for temporary outputs so callbacks can perform positioned writes and resize the destination. Add raw_fd_ostream::takeError and raw_fd_stream::resize, and return stream failures through Error while preserving an existing destination.
Co-authored-by: Jeremy Braun <jtbraun at meta.com>
Assisted-by: OpenAI Codex
[llvm-objcopy] Route section copies through writeSectionContents
Centralize section byte copies behind a virtual helper so ELF output can later target either a memory buffer or a seekable stream. Materialize SHT_SYMTAB_SHNDX entries using the target ELF word type to preserve output endianness.
Co-authored-by: Jeremy Braun <jtbraun at meta.com>
Assisted-by: OpenAI Codex
[lldb-dap] Return raw stop info from exceptionInfo (#231760)
lldb-dap folds the thread's extended stop info and the process's
extended crash information into the exceptionInfo description as
formatted text. Clients that want interpret these themselves currently
have to parse them back out.
Return both as raw JSON in two new lldb-dap extension fields,
`$__lldb_stopReasonExtendedInfo` and `$__lldb_extendedCrashInformation`.
rdar://188761988
[LoopPredication] Check profitability per widenable guard
The profitability check refuses to predicate a loop if any exit is more
than twice as likely as the latch exit. For a guard expressed as a
widenable branch, the guard's own deopt edge is one of these exits, but
predicating the guard cannot make that edge taken spuriously; it can only
move an actual failure to the loop entry.
A frontend that gives every guard a fixed, very small failure probability
(e.g. weights {983040, 1}) therefore never gets its guards predicated in
loops running more than ~1.97M iterations per entry, because the latch
exit becomes less likely than the guard's own deopt edge. This keeps the
range check inside the loop and blocks its vectorization.
Check the profitability separately for each widenable guard, ignoring
only that guard's deopt edge. Deopt edges of other guards and all other
exits still compete with the latch exit. Guard intrinsics and loop exit
predication still use the check for the whole loop.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[LoopPredication][NFC] Add tests for widenable guard profitability
The profitability check refuses to predicate a loop if any exit is more
than twice as likely as the latch exit. For guards expressed as widenable
branches it counts the deopt exit of the guard being predicated, so a
guard with the weights {983040, 1} is never predicated in a loop running
more than ~1.97M iterations per entry.
Record the current behavior for such a loop: a single guard, two guards,
and a frequently taken early exit. All three are refused now.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[Clang][counted_by] Load the count through unions by byte offset (#228309)
`getGEPIndicesToField()` indexed into a union with 0 and kept walking the
counter's struct field numbers, but the union's IR type is its largest
member, so the count was loaded from inside that member instead.
In Linux, `landlock_domain` hits this and FORTIFY panics on every nested
`landlock_restrict_self()` on kernel 7.3.0-rc5-next as of this writing.
I ran into this bug when trying to daily drive the aforementioned
kernel.
Below is a reduced version of `landlock_domain`. The `work` member
stands in for the kernel's `struct work_struct`, which is larger than the
anonymous struct holding the count, so it becomes the union's IR type.
```c
struct dom {
void *rules[3];
[18 lines not shown]
[WebAssembly] Preserve tail-call pseudos during stack-protector splitting (#230073)
WebAssembly tail calls use a parameter/result pseudo-instruction pair
that is combined during FinalizeISel. Before that, stack-protector
insertion looks for the first terminator so it can move the terminating
sequence into the success block. The tail-call pseudos lack those flags,
causing an assertion in findSplitPointForStackProtector.
This reproduces with an assertions-enabled build:
```llvm
declare i32 @callee(i32)
define i32 @caller(i32 %x) sspreq {
%r = tail call i32 @callee(i32 %x)
ret i32 %r
}
```
```sh
[15 lines not shown]
[scudo] Re-check freelist before populating blocks in popBlocksWithCV (#231750)
In popBlocksWithCV, the region freelist may become non-empty before the
thread calls populateFreeListAndPopBlocks. This can happen in two
scenarios:
1. Another thread may push blocks or finish
populateFreeListAndPopBlocks() in the window between releasing FLLock in
popBlocks() and reacquiring it in popBlocksWithCV().
2. releaseToOSMaybe() holds MMLock while temporarily extracting
GroupsToRelease with FLLock unlocked, and merges those groups back into
BlockList before releasing MMLock.
When this does happen, popBlocksWithCV unconditionally calls
populateFreeListAndPopBlocks, permanently growing the region mapping and
BatchClassId freelist metadata.
The fix here is to re-check popBlocksImpl() under FLLock before setting
[5 lines not shown]
[lld][MachO] Don't create thunkMap entries for branches without a thunk (#231594)
This is part of the ld64.lld performance improvements tracked by
#222068.
TextOutputSection::finalize() created a thunkInfo for every thunkMap
entry found using []. However, the DenseMap::operator[] inserts an empty
default constructed entry whenever the key is not in thunkMap.
This led to millions of unnecessary empty entries. This change adds a
TextOutputSection::findThunkInRange that first uses find() to check if
the thunk exists.
It then calls getThunkInRange(), so the reads in finalize() still
function the same, just without adding a default entry that counted as a
cache miss anyways.
This commit is output preserving.
[sanitizer_common] Implement address sanitizer on AIX: process memory mapping (#138537)
Implement process memory mapping on AIX using `sys/procfs.h`. We don't
have direct access to the full path in the case of user libraries or
executables, so we use the path `/proc/<pid>/object/<object_id>` for
now.
Issue: https://github.com/llvm/llvm-project/issues/138916
---------
Co-authored-by: Midhunesh <midhunesh.p at ibm.com>
[CIR] Move records through memory in x86_64 call lowering (#231663)
CIR lowers a union to its storage type, so moving one as an SSA value
can drop bytes. An x86_fp80 member stores only 10 of its 16 bytes, for
example. The calling-convention rewriter now passes records through
memory at every coercion site, the way classic CodeGen does. That lets
us drop the union check #230302 added, which broke std::format.
Assisted-by: Cursor / Claude Opus 5.5
[AArch64] Add pre-commit tests for SVE AND-NOT folding
Add pre-commit tests demonstrating missed BIC selection for SVE AND-NOT
operations. Record the current NOT plus AND sequences for all-active and
undefined NOT results, and for intrinsic pairs with matching predicates.
Cover merging inactive lanes, commuted operands, all integer element
widths, and multiple uses of NOT. Include negative cases where folding
would change defined inactive lanes.
Both test files pass with SVE, SVE2p2, and streaming SME, with machine
instruction verification enabled.
[AArch64] Combine SVE AND-NOT operations into BIC
Fold a scalable-vector AND of an SVE NOT into BIC when the NOT predicate
is all-active or its inactive lanes are undefined.
Also fold SVE AND-NOT intrinsic pairs with matching predicates before
lowering discards the AND predicate. The NOT passthru is irrelevant in
the active lanes, allowing defined passthru values to fold as well.
Preserve the first operand's inactive lanes for merging AND, and only
commute the undef form. Keep standalone NOTs available for predicated
instruction selection.
Update the pre-commit tests to show BIC replacing NOT plus AND, while
retaining the negative cases. Both test files pass with SVE, SVE2p2, and
streaming SME, with machine instruction verification enabled.
[RISCV][P-ext] Use ISD::AVGSUBFLOOR(S/U) for (p)asub(u).
This replaces RISCVISD::ASUB(U) with ISD::AVGSUBFLOOR(S/U).
Co-Authored-By: Claude Sonnet 5.5 <noreply at anthropic.com>