[clang][OpenMP] Restore CapturedStmtInfo after an IRBuilder taskgroup (#242345)
EmitOMPTaskgroupDirective set CapturedStmtInfo to a local when it was
null, and left it pointing to the local after returning. Found by
-Wlifetime-safety.
Assisted-by: Claude Opus 5.5
The other two fixes are split out into
https://github.com/llvm/llvm-project/pull/242420 and
https://github.com/llvm/llvm-project/pull/242421.
Co-authored-by: Gabor Horvath <gaborh at apple.com>
[CIR] Preserve attributes on rebuilt function calls (#243166)
When a later declaration or definition changes a function's CIR type,
rebuilding its existing calls loses argument, result, and call-site
attributes. Preserve those attributes while retaining the callee
selected by the replacement logic.
Removed the obsolete attribute-count NYI. The caller derives function
attributes from the replacement declaration, so old declaration
attributes must not be copied onto the new function.
Added direct and indirect replacement coverage, check that stale
noreturn attributes do not leak into a replacement definition, and
update related attribute expectations.
Addresses item 2 of #192321.
Assisted by: OpenAI Codex
[lldb] Don't show a static of an inlined function twice (#243363)
f40e20dbff9c adds the variables that the abstract origin of a block
describes with a location to the block. A compiler can also emit a
variable in the concrete instance that only refers to the abstract one.
That variable inherits the location, so it was listed twice. Skip an
abstract variable that a concrete one refers to.
Also add an abstract variable that has a constant value, which is the
same in every instance too. Make the concrete block the scope of these
variables. The scope was the function, because the abstract parent has
no block.
In the test, create the breakpoints once and declare both() static
inline like inlined().
Assisted-by: Claude
[flang] Remove unused CharacterExprHelper::createLoadCharAt (NFC) (#243521)
The last caller was removed on November 17, 2026 in commit
e737958551f67828326215520c17ba729cd83122.
Assisted-by: Antigravity
Attributor: Only destroy the cached opcodes' instruction vectors (#241012)
The FunctionInfo destructor checked all of the ~70 opcode slots of
OpcodeInstMap, but only the interesting opcodes are ever filled in.
Loop over those instead.
Instruction counts (callgrind) of attributor-light:
sqlite3 -0.02%, kimwitu++ k -0.30%, SPASS cnf -0.03%, consumer-typeset
z08 -0.01%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Offload][Omp] Do all geometry computations in 64-bit (#243507)
As discussed in #243452, currently, geometry computation is using a mix
of 32 and 64 bit integers, which require to cross the boundary multiple
times, making it confusing and error-prone.
This PR changes it so all the computation is in 64-bits after widening
some of the inputs. The result is also narrowed at the very end to
conform with the liboffload accepted sizes (and after checking we
wouldn't truncate the value).
Assisted by Claude.
[SPIR-V] Enable extended LLT in GlobalISel (#240752)
Let LLTs tell float from int so the PostLegalizer type fallback can stop
giving int types to float values, as patched case by case in, for
example, #238510 and #213785
[SPIR-V] Widen icmp on non-power-of-two vectors (#238513)
Align the G_ICMP legalizer rule with G_FCMP, which already widens to the
next power of two
Otherwise icmp on <5 x i32> fails to legalize
[libc] Add internal locale structures and config options (#211470)
Add internal category data structures and static locale objects for C
and UTF-8 locales. Introduce LIBC_CONF_DEFAULT_LOCALE and
LIBC_CONF_DISABLE_RUNTIME_LOCALE configuration options.
When LIBC_CONF_DISABLE_RUNTIME_LOCALE is set, the locale subsystem is
designed to eliminate all runtime overhead. Indirection through locale_t
objects and thread-local state lookups are bypassed in favour of direct,
compile-time constant lookups, allowing all runtime locale machinery and
dynamic objects to be elided for embedded environments.
Assisted-by: Automated tooling, human reviewed.
[libc] Add <arpa/nameser.h> with the RFC 1035 constants (#243501)
This patch adds the <arpa/nameser.h> header with the NS_* constants
based on RFC 1035 (NS_PACKETSZ, NS_MAXCDNAME, NS_HFIXEDSZ, etc.). I've
left out the compatibility aliases (PACKETSZ, HFIXEDSZ, ...) and the
rest of the header (ns_msg, ns_rr, ns_initparse, ...) for now.
I've put the constants into a llvm-libc-macros header instead of the
yaml file, as I expect the getaddrinfo implementation to need them for
building DNS queries and parsing the responses. For the same reason, I'm
also adding a proxy header in hdr/, even though nothing uses it yet.
I'm enabling the header on linux aarch64, riscv and x86_64, where the
rest of our networking headers are. It goes into the regular (not
experimental) list, as there's nothing incomplete about the constants
themselves. I don't add a test, as this is just a bunch of constant
definitions.
Assisted-by: Claude
[libc] Harden regerror null check and use string_view (#242402)
POSIX permits calling regerror with a null buffer when errbuf_size is 0
to query the required buffer length, but passing a null buffer with a
non-zero errbuf_size is undefined behaviour. Previously, regerror
silently skipped writing when errbuf was null and errbuf_size was
non-zero, diverging from the null-pointer hardening in regcomp, regexec,
and regfree.
Guard errbuf with LIBC_CRASH_ON_NULLPTR when errbuf_size > 0 while
preserving size queries when errbuf_size == 0. Return cpp::string_view
directly from the message lookup lambda so literal lengths fold at
compile time without a runtime strlen scan.
Assisted-by: Automated tooling, human reviewed.
[X86] Expand vector atomicrmw through a cmpxchg loop (#230788)
Fixes #226002.
`shouldExpandAtomicRMWInIR` returned None for the operations
xchg/add/sub when the operand
was a vector whose size did not exceed the native width of 64 bits (if
size > native_size). A <2 x i32> is 64 bits, so it skipped that check
and reached type legalization stage as an `ATOMIC_LOAD_ADD` node with a
vector result, which aborts with "do not know how to widen the result of
this operator".
x86 has no native atomic RMW instruction for vectors, so this patch
always expands them to a `cmpxchg` loop. `AtomicExpandPass` already
bitcasts the vector to an integer of the same width.
128-bit vectors use `cmpxchg16b` when `+cx16` is available and otherwise
fall back to libcalls such as `__atomic_*_16` (typically implemented
with a lock; correct but slower).
[5 lines not shown]
[libc][math] Expand polyeval.h with array, loop, and Estrin evaluation.
Add array-based, non-unrolled loop, and right-heavy Estrin polynomial
evaluation helpers to fputil:
- Add array overloads with optional OFFSET template parameter for
polyeval and altpolyeval, using sub_multiply for altpolyeval and
supporting both value (<= sizeof(double)) and const-ref (> sizeof(double))
coefficient types.
- Add loop_polyeval and loop_altpolyeval with LIBC_LOOP_NOUNROLL for
code-size-sensitive evaluations.
- Add estrin_polyeval (array and variadic overloads) using a precomputed
dyadic power table and a minimum-depth right-heavy binary tree.
- Add unit tests in polyeval_test.cpp covering float, double,
DoubleDouble, DyadicFloat<128>, and Frac128 across rounding modes and
evaluation-order sensitivity.
[libc][math] Rename PolyEval.h to polyeval.h.
Rename src/__support/FPUtil/PolyEval.h to polyeval.h to match lowercase
snake_case header naming, and update includes, CMake, and Bazel rules.
[libc][math] Use multiply_sub and sub_multiply across math headers.
Replace negated multiply_add calls (multiply_add(a, b, -c), multiply_add(-b, c, a),
and multiply_add(b, -c, a)) across FPUtil and math implementation headers with
multiply_sub and sub_multiply.
[libc][math] Add multiply_sub and sub_multiply to multiply_add.h.
- Add fputil::multiply_sub (x * y - z) and fputil::sub_multiply (x - y * z)
alongside fputil::multiply_add (x * y + z).
- Use template-based hardware FMA dispatch and size-aware inline overloads so
explicit multiply_add<T> calls also use hardware FMA when available.
- Add NumberPair<T> add/sub overloads in double_double.h, and matching
multiply_sub and sub_multiply overloads for DoubleDouble and DyadicFloat.
- Add unit tests in libc/test/src/__support/FPUtil/multiply_add_test.cpp.
[ARM] Emit clrex wherever it's available in emitAtomicCmpXchgNoStoreLLBalance (#242972)
This method previously just checked for hasV7Ops, but CLREX is available
in Arm state in v6K and in Thumb state wherever v7clrex is present,
including v8-M Baseline.
[mlir][vector] Add `getDefaultUnrollTargetShape` to `VectorUnrollOpInterface` (#242315)
Add an interface hook that provides a default target shape for `Vector`
unrolling when no shape callback is configured through
`UnrollVectorOptions`. Explicit caller configuration takes precedence.
Move the shape-selection logic from `TestVectorUnrollingPatterns` into
the interface and the corresponding `Vector` operations. This simplifies
the test pass and keeps operation-specific defaults alongside the
operations that define them.
These defaults are intended primarily for testing. Callers with
performance requirements should continue to configure target shapes
through `UnrollVectorOptions`.
The test pass now uses the type-dependent contraction default regardless
of the `unroll-based-on-type` option.
Also group the unrolling interface methods consistently within
[2 lines not shown]
[flang][OpenMP] Remove unused OmpStructureChecker::GetLoopIndex (NFC) (#243370)
The last caller was removed on November 16, 2026 in commit
30dd629584112f7d01e5d6af6efa1b892e86153d.
Assisted-by: Antigravity
[VPlan] Use uitofp for the index of FP derived IVs (#240743)
expandVPDerivedIV converts the index of an FP derived IV with sitofp,
but the index is an unsigned iteration count. With an i32 canonical IV,
an index of 2^31 or more gives wrong FP induction values. Use uitofp,
and update the cost to match.
Depends on #240741.
Assisted-by: Claude Code
[CIR] Canonicalize code that cir.goto and cir.switch enter
Since #225814, MLIR's greedy driver skips every operation in a block
that the entry block of its region does not reach. Until the goto solver
runs, cir.goto is not a CFG edge. So cir-canonicalize no longer rewrites
the code after a cir.label that only gotos reach, nor the blocks only
that code reaches. In C this is most error paths. In ten isl source
files, 722 of the 737 labels start a block with no predecessors. A
cir.case after a break, return or goto has no predecessor either,
although its cir.switch jumps to it.
Add GotoAnalysis, which answers whether control can reach an operation
when those jumps are counted. Control enters a region at its entry block
and at each operation that is or holds a cir.label, or a cir.case below
its cir.switch. From there it follows the CFG. As a rewriter listener,
it keeps its results while the IR changes and updates them on the next
query, so merging blocks needs no rescan.
cir-canonicalize passes the analysis to MLIR's greedy driver as its
[6 lines not shown]
[mlir] Let callers decide reachability in the greedy rewriter
Since #225814, the greedy rewriter skips an operation whose block has no
CFG path from the entry block of its region: values there may form SSA
cycles, on which folds and patterns can crash or loop. Some dialects
transfer control without CFG edges. In ClangIR, cir.goto enters its
cir.label and cir.switch enters its nested cir.case operations until
later passes turn them into branches, so the code they enter looks
unreachable and the CIR canonicalizer stops rewriting it.
Add GreedyRewriteConfig::setReachability, a function the worklist asks
instead of the CFG whether an operation is reachable. The caller must
not report an operation reachable whose operands may form an SSA cycle.
The region-based entry points still erase blocks that have no CFG path
from the entry, so the function matters to applyOpPatternsGreedily.
Assisted-by: Claude Code (claude-opus-5-5).
[libc++abi] Use a strong enums or bools in private_typeinfo.h (#230769)
The enum values for the kind of path we currently have is moved into an
`enum class path_kind`. We now only track whether a derived type _might_
be derived from a static type instead of whether it might be, we know it
to be, or we know it not to be, since that's the only information we
care about. For that we can use a `bool` instead.
[PowerPC] Use the 16-byte stack and vector alignment on FreeBSD (#232336)
FreeBSD uses the ELFv2 ABI on both byte orders, so it has the same
16-byte stack alignment as Linux. The explicit vector alignment is a
backend workaround that does not depend on the OS. There is no
reason for the layouts to differ.