[compiler-rt][Darwin] Drop i386 slice for builtins on modern SDKs (#215388)
The SDK >= 10.15 i386-removal in darwin_test_archs was gated by `if(NOT
TEST_COMPILE_ONLY)`, so it never fired for the builtins config, which
sets TEST_COMPILE_ONLY=On. `-arch i386` still compiles fine on current
SDKs — ld is the only stage that rejects it — so the compile-only probe
kept i386 in DARWIN_osx_BUILTIN_ARCHS, and downstream `strip` on the
resulting fat archives fails on Xcode 27 with "ld: linking for i386 is
no longer supported".
Hoist the check above the guard so it applies to both the runtime and
builtin arch probes.
[libc] Remove APPEND_LIBC_TEST (#215869)
It is not needed now that we're never running hermetic and unit tests in
the same build, and it also avoids races with leftover unit test
binaries in the build folder.
[CVP] Infer no-wrap flags from operand ranges at use sites. (#207522)
When processBinOp cannot prove a no-wrap flag from the operand ranges at
the definition, fall back to querying the operand ranges constrained at
the binop's use sites. This recovers nsw/nuw when the guard that
establishes the range dominates the uses but not the definition (e.g.
the def sits in the loop body ahead of the overflow-guard branch that
all uses are behind).
This is triggers in a number of C/C++ workloads and is also quite common
in Swift code which emits overflowing ops extensively, and aborts if the
check fails.
https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/621
Alive2 proof for `@same_guard_diff_ops` from the tests
https://alive2.llvm.org/ce/z/YvHQsK
[3 lines not shown]
[LLVM] Move fp libcall selection into TableGen (#204029)
Summary:
Currently we maintain several different spaces that want to ask which
libcall an intrinsic / type value lowers to. This PR consolidates this
into tablegen by emitting floating point families. Change
getLibcallForIntrinsic to take FunctionType and derive the FP type
from the complete call signature, rather than requiring callers to pass
a preselected type.
This resolves some outstanding TODOs. The main motivation is a follow-up
where we use this information to augment the LTO pass to more
intentionally extract symbols. I.e. if we see `llvm.sin.f64` we should
extract `sin` from an LTO library.
[LV] Don't form a histogram if the bucket value or its update escapes (#215021)
The histogram intrinsic performs the load, update and store of a bucket
as a single operation, so neither the loaded value nor the updated value
is available to other users. Currently other users are served by a
separate gather, which is incorrect.
Reject cases where either the update or bucket value have multiple
users.
PR: https://github.com/llvm/llvm-project/pull/215021
[flang][OpenMP] Revert array element reduction lowering (#215617)
Revert #196094 and its follow-up #209701. The expression override
mechanism does not preserve reduction-object identity across all data
environments, leading to incorrect lowering for procedure-local and
nested private arrays.
Restore the pre-#196094 lowering while retaining semantic-context
plumbing needed by later user-defined reduction support. Keep coverage
showing that array-element constructs compile through the boxed-array
reduction path.
This was in response to this comment:
https://github.com/llvm/llvm-project/pull/196094#issuecomment-5248085956
Fixing exactly the bug in the comment wasn't hard but AI code review
found a large number of follow on bugs so I think the design needs a
rethink, and definitely shouldn't be included in the LLVM release.
Assisted-by: Codex
[InstCombine] Fold (X - X%C) u>= C to X u>= C (#214381)
(X - (X urem D)) is D*(X/D), a multiple of D. A multiple of D is u> C
exactly when X u>= D for any C u< D, and u< C exactly when X u< D for
any
0 u< C u<= D.
icmp ugt (sub X, (urem X, D)), C --> icmp ugt X, D-1 for C u< D
icmp ult (sub X, (urem X, D)), C --> icmp ult X, D for 0 u< C u<= D
The ugt case previously required C == D-1; it now folds for the whole
[0, D) range. The ult case is new.
alive2 (ugt): https://alive2.llvm.org/ce/z/_sUmC2
alive2 (ult): https://alive2.llvm.org/ce/z/x4vfAz
alive2 : https://alive2.llvm.org/ce/z/ktjUcP
[SandboxVectorizer] Make LoadStoreVec::vectorizeStores direction-agnostic
Remove classifyStoreOperands()/isFoldableLoadOperand(): vectorizeStores()
no longer gates on whether a store chain's value operands are all loads,
all constants, or neither. Instead it always builds the vector value via
a new packOperands(), which packs any mix of loads, constants, or
arbitrary SSA values via extractelement/insertelement -- direction-
agnostic in the sense that it doesn't care what kind of operand it's
given, unlike the load-specific and constant-specific paths it replaces.
packOperands() combines operands at the granularity of their narrowest
common scalar element type (the same rule getCombinedVectorTypeFor()
uses), splitting a wider operand into multiple lanes via a bitcast. A
plain bitcast can't convert between pointer and non-pointer types, and
inttoptr requires an integer source, so reinterpretSameWidth() picks
bitcast, ptrtoint, or inttoptr as needed, routing a non-integer,
non-pointer operand (e.g. double) through an intermediate same-width
integer when the target granularity is a pointer.
[38 lines not shown]
[HLSL] Move `degrees` implementation to header files (#215436)
Closes #213096.
This PR replaces the previous implementation of `degrees` with a new one
inside the header files.
The SPIRV intrinsic (`int_spv_degrees`) and its lowering are
intentionally kept, since a follow-up will pattern-match `Val *
(180/pi)` back to the extended instruction and needs the SPIRV intrinsic
to do so.
Assisted-by: Claude Opus 4.8
[mlir][bufferization] Make the dialect's bufferization customizable (#215590)
The bufferization dialect's ops declared `BufferizableOpInterface` in
their ODS trait lists, so the models were part of the op definitions.
The MLIR interface map keeps the first model attached to an op, and an
op-defined model is always first, so a downstream project could not
replace them. For `bufferization.alloc_tensor` the only remaining hook
was `BufferizationOptions::allocationFn`. That hook cannot change the
buffer type without a contract break: `getBufferType` keeps reporting a
static identity layout, the allocation function returns a different
layout, and every consumer that predicts the type before the buffer
exists then disagrees with the buffer that appears.
Move the models out of the op definitions into external models, the same
way `arith`, `tensor`, `scf`, and the other dialects do it.
`bufferization::registerBufferizableOpInterfaceExternalModels` attaches
the models for `alloc_tensor`, `dealloc_tensor`,
`materialize_in_destination`, `to_buffer` and `to_tensor`, and
`registerAllDialects` calls it. A project that must control how these
[8 lines not shown]
Fix lambda merging to apply to locally-parsed lambdas. (#215661)
Clang's lambda-merging logic was implemented in the ASTReader, meaning
that it only applied for lambdas that were imported from AST files. This
caused us to fail to merge lambdas in the case where both lambdas were
parsed as part of the current compilation, for example if they are
included into distinct submodules in the same header module.
Fix this by moving the merging logic out of ASTReader and into Sema, and
moving the tracking of lambdas that need to be merged out of ASTReader
and into ASTContext. This removes the AssignedLambdaNumbering callback
from ExternalSemaSource, which was only being used for this purpose.
Fixes #214560.
Assisted-by: Gemini for the mechanical reorganization. Rework of
handleLambdaNumbering done by hand.
[lldb] Remove ConstString from DumpValueObjectOptions (#215421)
There are 2 uses of ConstString in DumpValueObjectOptions:
DeclPrintingHelper and ChildPrintingDecider, both being std::functions.
The former takes 2 ConstString arguments and the latter takes just one.
These functions don't really need their arguments (type names, var
names, register names) to actually be in a ConstString. For the most
part, they are just printing the string out or otherwise analyzing it.
[CIR] Honor -fno-clangir (#214904)
`-fno-clangir` was a no-op whenever `-fclangir` also appeared on the
command line, in either order: the CIR pipeline ran regardless.
Options.td already declares clangir as a BoolFOption with a NegFlag, so
last-wins semantics were intended and the generated marshalling
implements them correctly.
[lld][WebAssembly] Follow relocations of TLS-base accessors during GC (#206831)
With `--gc-sections` (the default), `wasm-ld` garbage-collects functions
that are only reachable through `__wasm_get_tls_base` /
`__wasm_set_tls_base` in the cooperative-threading (libcall
thread-context) configuration. This produces a linked module that is
invalid or behaves incorrectly: the relocation inside
`__wasm_set_tls_base` is left dangling / mis-resolved, so callers trap
at runtime (e.g. `validation error: ... values remaining on stack at end
of block`, or a call to an unrelated function).
In cooperative-threading mode (`--cooperative-threading`, added in
#200855), per-task thread context is accessed through libcalls rather
than wasm globals. `wasm-ld` synthesizes `__wasm_init_tls` /
`__wasm_init_memory`, which invoke `__wasm_get_tls_base` and
`__wasm_set_tls_base` via **raw `call` instructions that carry no
relocations**. To keep those accessors in the output, the linker marks
them live with `Symbol::markLive()`.
[77 lines not shown]
[flang][OpenMP] Lower DO and SIMD variants in metadirectives
A standalone metadirective and its associated DO are sibling PFT evaluations,
so a selected loop replacement cannot directly reuse ordinary OpenMP loop
lowering. Runtime selection must also preserve exactly one copy of the loop in
each reachable branch. Temporarily associate the evaluations while lowering
to support DO, SIMD, and DO SIMD replacements without losing or duplicating the
ordinary fallback loop.
For example:
```fortran
!$omp metadirective &
!$omp& when(user={condition(flag)}: do) &
!$omp& otherwise(nothing)
do i = 1, n
a(i) = i
end do
```
[49 lines not shown]