[lld][ELF][SPARC] Support R_SPARC_TLS_DTPOFF32/64 in non-alloc sections (#248653)
GCC, and now clang, use %r_tls_dtpoff32/%r_tls_dtpoff64 in .debug_info
for the location of thread-local variables. Resolve them as R_DTPREL,
the offset within the TLS segment (SPARC uses no DTV bias).
Assisted-by: Claude Opus 5.5
[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.