[CIR][NFC] Decouple target lowering selection from C++ ABI setup (#236537)
Select target lowering rules from the target triple without constructing
a `LowerModule` or allocating Clang target and C++ ABI state. Share the
factory with ABI lowering so type conversion can query target
representations independently.
Assisted-by: Codex / GPT-6
[libc][stdio] Implement putc_unlocked (#243329)
Implements `putc_unlocked` for Linux full builds.
Adds the entrypoint, internal header, stdio.yaml declaration, CMake
targets,
entrypoint entries for aarch64/riscv/x86_64, and three unit tests.
Part of #242485
GlobalDCE: Only clear the analyses of deleted functions (#243713)
GlobalDCE reported no preserved analyses whenever it deleted anything,
which clears every cached function analysis in the module. Refine this
to only discard analyses of erased functions.
callgrind instructions, opt -O3: kimwitu++ k.bc -0.07%, where the
cleared TargetLibraryInfo had to be computed again for each function.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[lldb][test] Fix DebuggerSupportsLLVMTarget always returning false (#243716)
SBStructuredData::GetStringValue returns the size needed to hold the
string, which includes the terminating NUL. The StringRef built from
that size never compared equal to the target name, so the helper
reported every target as unsupported.
[Flang][OpenMP] Fix missing implicit barrier for empty sections constructs. (#241735)
This patch fixes a missing implicit barrier at the end of an empty
`!$omp sections` construct, where threads could previously proceed
without synchronization, violating OpenMP semantics.
The fix ensures that `convertOmpSections` emits the required implicit
barrier when `sectionCBs` is empty, unless the `nowait` clause is
specified.
DeadArgumentElimination: Only invalidate the analyses of changed functions (#243712)
DeadArgumentElimination reported no preserved analyses whenever it
changed anything, discarding all cached function analyses in the
module. Refine this to functions whose calls or argumenst are changed.
callgrind instructions, opt -O3: kimwitu++ k.bc -0.21%, sqlite3 -0.11%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Use SCC branches for uniform truncates to i1 (#241944)
A branch on a set low bit reaches isel as brcond (truncate x), either
from an IR trunc to i1 or from SimplifySetCC folding (and x, 1) != 0
into truncate x. The uniform truncate-to-i1 patterns already select to
S_CMP and produce SCC, but isCBranchSCC only accepted SETCC, so the
branch went through s_cselect, a lane mask and EXEC before branching on
VCC.
Also accept a one-use uniform truncate from i16, i32 or i64, the source
types the SCC-producing patterns in SIInstructions.td cover, so these
branches become s_bitcmp + s_cbranch_scc. Divergent truncates keep the
lane-mask path.
Assisted-by: Claude Opus 5.5
AlwaysInliner: Preserve the function analysis manager proxy (#243711)
AlwaysInliner already updates the analyses of the functions it inlines
or deletes, but did not preserve FunctionAnalysisManagerModuleProxy,
which ends up clearing every cached function analysis in the module.
This doesn't make much difference in CTMark since few of the programs
use alwaysinline, with the exception of kimwitu++ k.bc (-0.50%).
always_inline is well overused in GPU code, so a sample of 441 ROCm
bitcode files show a -0.08% geomean improvement.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[MIR2Vec] Fix the common operand index for MO_LaneMask (#243374)
CommonOperandNames has no MO_DbgInstrRef entry, so lookups for later
types used the wrong slot
Map each operand type to its vocabulary entry explicitly, so the index
no longer depends on enum order
Operand types without an entry get a zero embedding
GlobalDCE: Only clear the analyses of deleted functions
GlobalDCE reported no preserved analyses whenever it deleted anything,
which clears every cached function analysis in the module. Refine this
to only discard analyses of erased functions.
callgrind instructions, opt -O3: kimwitu++ k.bc -0.07%, where the cleared
TargetLibraryInfo had to be computed again for each function.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc][math][NFC] Rename PolyEval.h to polyeval.h. (#243339)
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] Expand polyeval.h with array, loop, and Estrin evaluation. (#243523)
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] Use multiply_sub and sub_multiply across math functions. (#243290)
Replace `multiply_add(a, b, -c)`, `multiply_add(-b, c, a)`, and
`multiply_add(b, -c, a)` with `multiply_sub` and `sub_multiply`.
[libc][math] Add multiply_sub and sub_multiply to multiply_add.h. (#243269)
- Add `fputil::multiply_sub` `(x * y - z)` and `fputil::sub_multiply`
`(x - y * z)` alongside `fputil::multiply_add` `(x * y + z)`.
- Add `NumberPair<T>` `add/sub` overloads in `double_double.h`, and
matching `multiply_sub` and `sub_multiply` overloads for `DoubleDouble`
and `DyadicFloat`.
- Specialization to use `fmadd`/`fmsub` instructions when available.
DeadArgumentElimination: Only invalidate the analyses of changed functions
DeadArgumentElimination reported no preserved analyses whenever it
changed anything, discarding all cached function analyses in the
module. Refine this to functions whose calls or argumenst are changed.
callgrind instructions, opt -O3: kimwitu++ k.bc -0.21%, sqlite3 -0.11%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AlwaysInliner: Preserve the function analysis manager proxy
AlwaysInliner already updates the analyses of the functions it inlines
or deletes, but did not preserve FunctionAnalysisManagerModuleProxy,
which ends up clearing every cached function analysis in the module.
This doesn't make much difference in CTMark since few of the programs
use alwaysinline, with the exception of kimwitu++ k.bc (-0.50%).
always_inline is well overused in GPU code, so a sample of 441 ROCm
bitcode files show a -0.08% geomean improvement.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[compiler-rt] Fill Windows runtime version metadata (#243544)
Windows compiler-rt DLLs lack descriptions, copyright information and
original filenames, and their numeric ProductVersion is zero.
Fill the descriptive fields and identify ASan as "AddressSanitizer
runtime". Record the actual DLL filename and set numeric ProductVersion
to the same numeric version as FileVersion.
[lldb] Run module scripts' --at-initial-stop hooks at the current stop (#243394)
A module's dSYM script often adds a stop hook from
`__lldb_module_added_to_target`, to do something once the process can be
read, and adds it with `--at-initial-stop` so it also runs when LLDB
first gains control of the process. That covers a script that LLDB loads
before that stop, like when it attaches or loads a core file. But when
the module joins a target whose process already stopped, for example
with `target modules add`, or by turning on
`target.load-script-from-symbol-file` as LLDB's warning suggests, that
stop already ran its stop hooks, so the stop hook waits for the process
to stop again. To avoid that, the script has to check whether there's a
stopped process and do the work itself.
This patch solves that by collecting the stop hooks, and the hooks from
`target hook add`, that a module's `__lldb_module_added_to_target` adds.
When it returns, if the process already stopped, we run the ones added
with `--at-initial-stop` right away. We don't resume the process,
whatever they vote, since resuming it is up to the user. If the process
[13 lines not shown]
RegisterCoalescer: Only shrink subranges in ShrinkMask after a join (#243348)
When joinCopy needs to shrink the main range, shrinkToUses was called
on the whole interval. This also shrinks every subrange. If the join
did not set ShrinkMainRange, no subrange is ever shrunk, so the join
is already trusted to leave only the subranges in ShrinkMask needing
it. The other reasons for shrinking the main range (pruned main range
values, uses that now read only undef lanes) do not change any
subrange. Pass ShrinkMask to shrinkToUses to restrict which subranges
it shrinks, unless the source interval was in ToBeUpdated.
llc instructions:u, AMDGPU sample: -0.11%
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>