[llvm-ifs] Handle STB_GNU_UNIQUE ELF symbols (#241122)
Add an optional "Unique: true" symbol attribute to the IFS text format
for STB_GNU_UNIQUE ELF bindings and bump IFSVersionCurrent (and Clang's
-emit-interface-stubs output) from 3.0 to 3.1 while preserving backward
compatibility with existing 3.0 IFS files.
When generating ELF stubs, emit STB_GNU_UNIQUE for unique symbols and
set EI_OSABI to ELFOSABI_GNU whenever any symbol uses "Unique: true"
(keeping ELFOSABI_NONE otherwise) so static linkers handle resolution
directly.
Also reject symbols specifying both Weak and Unique, handle Unique and
major-version mismatches symmetrically when merging IFS files, diagnose
unsupported exported ELF bindings, and update unit and lit tests.
Assisted by Gemini.
vmm: Fix double free with devmem_create_cdev error
devmem_create_cdev() does not allocate name storage and should not free
it in the error path. It is already freed by the caller on error.
Reviewed by: markj
Fixes: cef5f43f819c
MFC after: 1 day
MFC to: stable/15
Differential Revision: https://reviews.freebsd.org/D61529
[RISCV] Rematerialize vmset.m and vmclr.m (#248627)
PseudoVMSET_M_* and PseudoVMCLR_M_* only take an AVL and SEW operand and
have no passthru, so they can be rematerialized like vmv.v.i and vid.v.
The pseudo's SEW/LMUL ratio is fixed by its opcode, so recomputing it
with the same AVL produces the same VL, and mask results are tail
agnostic.
Assisted-by: Claude
[LoopIdiom] Give a strlen formed in a funclet its funclet bundle (#246787)
When a strlen or wcslen loop is in a Windows EH funclet, the call that
replaced it had no "funclet" operand bundle. WinEHPrepare then treats
the call as implausible and makes the rest of the funclet unreachable,
so a catch handler with such a loop traps as soon as the string isn't
empty. Add the bundle of the preheader's funclet, as the inliner does,
and leave the loop alone if the preheader isn't in exactly one funclet.
Assisted-by: Claude Opus 5.5 (Anthropic)
[LangRef] Specify vp.strided.{load,store} is byte aligned
https://github.com/llvm/llvm-project/pull/241715 clarified in llubi that the individual lane accesses of a strided load/store are byte aligned, and that the align attribute is only applied to the base pointer. This matches how e.g. the attributor propagates the align attribute.
Update the LangRef to reflect this, and whilst we're here convert the example to opaque pointers.
[C++20] [Modules] Touch members for dtor (#248767)
Close https://github.com/llvm/llvm-project/issues/246162
The root cause of the problem is, some member of
the base of the dtor is omitted in reduced BMI.
The corresponding fix is to touch them for dtor in reduced BMI.
Assisted by AI.
[lldb] Move PlatformWasm::FindFreeTCPPort to TCPSocket::FindFreePort (NFC) (#248693)
Move the free-port lookup out of the wasm platform so other platforms
can use it.
Broken out from PR #243197 after feedback
Assisted-by: Claude Code using Opus 5.5
Co-authored-by: Michael Georgariou III <georgariou at apple.com>
[Flang] Use simple summation by default at all optimization levels
Add a scope option to SimplifyHLFIRIntrinsics and adjust the pipeline to
enable SUM expansion at -O0 while keeping other intrinsic expansions
conditional on array expression optimization. This makes simple
summation the default for SUM expansion across optimization levels.
Previously, floating-point SUM used the runtime's Kahan summation at
-O0, whereas -O1 and higher generally generated loops with simple
sequential addition. This expansion substituted a different algorithm
rather than inlining the runtime implementation, causing numerical
results to depend on the optimization level.
Add -fcompensated-sum to preserve the runtime's compensated algorithm
for REAL and COMPLEX SUM. When enabled, exclude SUM from HLFIR intrinsic
simplification and prevent SimplifyIntrinsics from replacing real SUM
runtime calls with uncompensated reduction loops.
Fixes #176282
[3 lines not shown]
Attributor: Fix inverted liveness lookup in checkForAllInstructions
attributor is 0.1-2.0% and attributor-cgscc 0.1-1.0% faster on CTMark
sources (callgrind).
Assisted-by: Claude
DAG: Don't zero a mostly empty CSE map on every clear
CSEMap never shrinks, so after one large block, clearing it zeroes a
large table even for small DAGs. Mesa hits this since it compiles many
functions with one pass manager.
Add a FoldingSetBase::clear() overload that takes the set's nodes and
zeroes only their probe chains. Use it when CSEMap is less than an
eighth full.
Compile time of radeonsi shader-db shaders: -1.0% (-0.9% cycles).
CTMark instructions:u: +0.01% (-O3), +0.003% (-O0 -g).
Assisted-by: Claude
[lldb][NFC] Don't copy the name index map in Symtab::FindFunctionSymbols (#248745)
GetNameToSymbolIndexMap() returns a reference, but `auto map = ...`
copied the whole UniqueCStringMap for each base name, method name or
selector lookup, which can be millions of entries for a large binary, to
read a few matches.
assisted-by: claude
Mips: Include the stack alignment override in the subtarget key (#248753)
The subtarget depends on the override-stack-alignment module flag, so
modules with different values need different subtargets.
Assisted-by: Claude
EntryExitInstrumenter: Don't pass the return address to __cyg_profile_func_enter_bare (#248706)
__cyg_profile_func_enter_bare does not take any arguments. It was
passed the return address on AArch64, LoongArch and RISC-V because it
shared the mcount path, which started passing it for _mcount in
eafbab6facb0.
Assisted-by: Claude
[ctxprof] Hold the samples lock while the root auto-detector reads them
The root auto-detector means to lock each thread's samples while it reads them, but the lock guard was an unnamed temporary, so the lock was released at the end of the same statement and the samples were read unlocked. Name the guard so the lock is held while the samples are read.
[ctxprof] Avoid blocking on flat profile allocation
Flat profile allocation previously blocked on the function and flat arena mutexes, which can stall or deadlock flat-profile allocation if a user-space fiber holds a lock while a sibling spins, or if a signal handler interrupts a thread holding one of those mutexes. Switch those acquisitions in getFlatProfile to TryLock and fall back to the scratch context when contended, and log the missed activation count on profile fetch when nonzero.
[ctxprof] Preserve live current root across nested and recursive entries
A failed TryLock in tryStartContextGivenRoot previously cleared __llvm_ctx_profile_current_context_root even when the thread already held an outer root, preventing the outer root from unlocking Taken on exit. Keep a live __llvm_ctx_profile_current_context_root intact across nested or recursive root entries and track the entry depth of the held root so Taken is unlocked only on its outermost exit.
[ctxprof] Track under-context depth across nested and contended roots
Entering a root marks the thread as under a root regardless of whether the thread acquires the root's collection lock, but exiting cleared that state only when the thread held the lock. Track a per-thread root entry depth instead, so flat profiling resumes once a contended root exits and stays suppressed across nested or recursive root activations until the outermost root exits.
A function the root auto-detector promotes while one of its activations is already running exits that activation without a matching entry. The depth does not go below zero, but if that activation runs under another root, flat profiling resumes on that thread before the outer root exits. This affects only activations in flight at promotion time; explicitly stated roots are not affected.
[libc] Use FPBits::is_inf() for printf and strfromx inf/nan checks (#248696)
On x86 80-bit `long double` (`X86_Binary80`), `FPBits::get_mantissa()`
excludes the explicit integer bit. Pseudo-infinities (`biased_exp ==
0x7FFF`, `int_bit == 0`, zero fraction) and zero-fraction unnormals
(`biased_exp != 0`, `int_bit == 0`, zero fraction) both satisfy
`is_inf_or_nan()` and `get_mantissa() == 0`, so `printf` and `strfroml`
formatted them as `inf` instead of `nan`.
Switch the inf/nan checks in `float_dec_converter.h`,
`float_dec_converter_limited.h`, `float_hex_converter.h`, and
`str_from_util.h` to `FPBits::is_inf()`, which requires `biased_exp ==
0x7FFF` and `int_bit == 1` with a zero fraction on `X86_Binary80` and
matches the prior check on implicit-bit formats. Rename
`mantissa_is_zero` to `is_inf` in `InfNanFPBitsProperties` and
`FloatHexExpFPBitsProperties`, and add `sprintf` and `strfroml` tests
for canonical infinities, pseudo-infinities, and zero-fraction
unnormals.
Assisted-By: Gemini
[Attributor] Restore the load/store and alloca walks
The callers should not have to know which AAs the seeding relies on.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[X86] Move subvector broadcast load reuse to combineBROADCAST_LOAD (#245000)
Move the ordinary-load fold from `combineLoad` to
`combineBROADCAST_LOAD`, extending its existing base-pointer use-list
search. This avoids walking a Chain use list for every eligible load
when there is no subvector broadcast. Reordering the per-user checks
alone would still traverse that list.
Replace matching loads with extracts from the broadcast and revisit it
to handle remaining loads. The pointer, input-chain, memory-size and
simple-load checks are retained.
Fixes #244549