[libc][FPUtil] Make hardware helpers usable in constant expressions (#242283)
## Summary
Part of #195623 (split 1/2). Makes the `FPUtil` hardware helpers usable
in constant expressions, which is the foundation the shared math
functions build on in #242285.
## What this PR does
- Guards the hardware/intrinsic paths in `FEnvImpl`, `sqrt`, `FMA`,
`nearest_integer`, and `multiply_add` behind `is_constant_evaluated()`,
so they fall through to the generic implementation during constant
evaluation while still using the hardware path at runtime.
- Applies this across all supported architectures: aarch64, arm,
hexagon, riscv, and x86_64.
## Compatibility
[10 lines not shown]
[mlir][Affine] Fix crash in loopUnrollUpToFactor on zero-trip loops (#245019)
When the constant trip count was lower than the unroll factor,
loopUnrollUpToFactor clamped the factor to the trip count. For a
zero-trip loop (e.g. `affine.for %i = 0 to 0`) this called
loopUnrollByFactor with factor 0 and tripped its "unroll factor should
be positive" assertion. Return early for zero-trip loops as
loopUnrollFull does, since there is nothing to unroll. Fixes #220458.
Assisted-by: MiMo-V2.6-Pro
[MC] Change section group name from Twine to StringRef. NFC (#245125)
str() conversions are expensive. All but one caller
(MCObjectFileInfo::getPseudoProbeDescSection) pass a StringRef. Take a
StringRef.
Coroutines: Only invalidate analyses of lowered functions in CoroCleanup
CoroCleanupPass already invalidates the analyses of the functions it
lowers, but then reported no preserved analyses, which clears every
cached function.
Also stop preserving CFG analyses for lowered functions, since noop
coroutine elision can change the CFG.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[MC] Hash section names once in recordELFMergeableSectionInfo. NFC (#245122)
Key both ELFSeenGenericMergeableSections and ELFEntrySizeMap by
CachedHashStringRef so that hash lookups don't need to recompute the
section name hash. ELFSeenGenericmergeableSections contains most
sections and the long C++ mangled names are expensive.
RuntimeLibcalls: Add SME attributes to the AArch64 SME support routines
SMEAttrs currently assumes these attributes based on the function
name. Add them to the function definition so this code can be cleaned
up in the future.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[orc-rt] Add DlfcnLoaderAdapter. (#245120)
DlfcnLoaderAdapter simplifies exposing an ORC runtime loader through the
dlfcn.h APIs. Subclasses implement dlopen, dlclose, dlsym, and dladdr in
terms of their underlying loader, reporting failures with Error and
Expected as usual in the ORC runtime. The adapter takes care of
translating those results into dlfcn.h's error-reporting scheme: each
failure returns the operation's POSIX failure value, and its message is
made available to the calling thread through dlerror. Failures are also
logged, under a new LoaderAPIs logging category.
JIT'd code reaches an adapter through C entry points
(orc_rt_DlfcnLoaderAdapter_*) and an instance symbol,
orc_rt_DlfcnLoaderAdapter_Instance, which the adapter adds to a symbol
table supplied by its creator. The creator publishes that table to the
session once the whole loader system has been constructed.
Supporting changes:
- orc-rt-c/bedrock/sys/posix/dlfcn-types.h provides orc_rt_Dl_info and
[6 lines not shown]
RuntimeLibcalls: Add attributes to __arm_sc_memcpy, memmove and memset
The streaming-compatible variants behave like memcpy, memmove and
memset. Omit captures(none) since these can be used to implement volatile
memory intrinsics.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Utils: Preserve function analyses in CanonicalizeAliases and NameAnonGlobals (#244987)
These passes only change aliases and the names of globals, so they do
not need to invalidate any function analyses.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
GlobalSplit: Preserve CFG analyses (#244959)
GlobalSplit only changes global variables, so it does not need to
invalidate every function analysis.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[MC] Allow relocation section to share name with a label (#245121)
We currently reject the new case in reloc-same-name-section.s as
"invalid symbol redefinition" while GAS allows it. Allow it by creating
a MCSectionELF directly with a null `Begin` symbol.
Revert "[SPIR-V] Default to NewPM" (#245119)
Reverts llvm/llvm-project#239489
Breaks https://lab.llvm.org/buildbot/#/builders/225/builds/26922. Looks
like a latent machine code verification bug where the legacy pipeline
wasn't running the machine verifier.
[X86] Skip finishLayout without MCBoundaryAlignFragment. NFC (#245114)
-x86-pad-for-branch-align defaults to true, so `finishLayout` walks
every text section even when branch alignment is disabled. Skip
it in the majority of cases when AllowAutoPadding is false.
Also add a test for -x86-pad-for-branch-align=0, which was uncovered.
[orc-rt] Add quote() to StringExtras.h. (#245112)
quote() wraps a string so that StringOutputStream prints it in double
quotes, escaping any embedded quotes and backslashes as std::quoted
does. A null const char * prints as NULL, so that nullable C strings
(e.g. arguments in diagnostics) can be printed without a separate null
check.
[SPIR-V] Use float LLTs to type FP vregs after legalization (#243866)
Read the SPIR-V type of float vregs from their LLT instead of guessing
it from their uses
[Clang] Fix qualifiers of ext vector components accessed via `->` (#244980)
For `p->x` where `p` points to an `ext_vector_type` vector, Sema takes
the qualifiers from the type of `p`, which is the pointer itself,
instead of the vector it points to. As a result, `p->x = 1` is accepted
even if `p` points to a `const` vector, while `(*p).x = 1` is rejected.
An address space on the vector is lost in the same way.
This PR takes the qualifiers from the vector for both `.` and `->`. A
swizzle that repeats a component, e.g. `v.xx`, is a computed value, so
it doesn't get any qualifiers.
This PR was assisted by AI but I reviewed all the changes.
[NFC][SanitizerCoverage] Reuse RuntimeCalls storage across functions (#244787)
Avoid swapping RuntimeCalls into a local SmallVector in
addFuncletBundles(), which frees its heap buffer after every function
with more than 16 callbacks even on non-scoped-EH targets. Clear
RuntimeCalls on scope exit instead to preserve allocated capacity across
functions.
Follow-up to #226762.
Assisted-by: Gemini
[NFC][SanitizerCoverage] Check FuncletPadInst for funclet bundles (#244788)
Check isa<FuncletPadInst>(Pad) instead of Pad->isEHPad() when attaching
funclet operand bundles. The IR verifier only accepts CatchPadInst or
CleanupPadInst operands for "funclet" bundles, whereas isEHPad() also
matches LandingPadInst and CatchSwitchInst.
Follow-up to #226762.
Assisted-by: Gemini
[ThinLTO] Preserve non-prevailing ifunc resolver definitions (#242990)
Currently, when multiple modules provide `weak_odr` definitions of the
same ifunc resolver (which is a common scenario in multi-versioning,
frontend will generate a resolver definition for all modules that use
versioning func), the ThinLink phase will resolve one as prevailing and
demotes the non-prevailing copy to `available_externally`. But this
violates the strict LLVM IR constraint that an ifunc must be bound to a
resolver defined in the same non-prevailing module, and will lead to an
`IFunc resolver must be a definition` verifier error.
The issue can be easily reproduced with the following minimal example:
```c++
// main.cpp
__attribute__((target("default"))) int select_impl();
__attribute__((target("avx2"))) int select_impl();
int main() { return select_impl(); }
// a.cpp
[12 lines not shown]
[Clang][Headers] Fix tgmath.h conj() of a real argument (#244854)
For a real argument, the type-generic conj() returned the argument
converted to complex, giving x + 0i. C11 7.25p5 requires the complex
function to be called, so the result should be conj(x + 0i), which
is x - 0i. Call conjf/conj/conjl for the real overloads, the same as
cproj() already does.
Declare the functions tgmath.h uses in the test math.h and complex.h,
and build the test with -Wsystem-headers, so a missing declaration is
an error.
Fixes #244639
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>