[clang][CMake][Darwin] Make HOST_LINK_VERSION a CACHE option on Darwin (#203917)
This allows specifying a fixed host linker version during Clang
configuration (e.g. -DHOST_LINK_VERSION=1249), bypassing the default
auto-detection. This is useful for hermetic packaging scripts where the
auto-detected host linker might differ from the intended target linker,
and we do not want certain features to be enabled that depends on the
host linker version -- e.g.
https://github.com/llvm/llvm-project/issues/203385
[SSAF][WPA] Add a lit test for the WPA improvement of #198889
This commit adds a lit test, which is an example of the issue solved
by #198889 and was discovered independently when applying the analysis
to a real project.
rdar://179754164
[SSAF][WPA] Add a lit test for the WPA improvement of #198889
This commit adds a lit test, which is an example of the issue solved
by #198889 and was discovered independently when applying the analysis
to a real project.
rdar://179754164
[libc++] Disable mistakenly enabled `optional<T&>` constructors for `optional<T>` (#194446)
Resolves #194415
- A constructor specifically meant for `optional<T&>` was left enabled
for `optional<T>`
- Fix it, and add a test to check for regression.
- This patch also corrects the constraints for `optional(optional<U>&)`
and `optional(const optional<U>&)` , as they were incorrectly
disallowing [valid conversions](https://godbolt.org/z/1r5Ea7z5M)
- Also, correct the `noexcept` specification.
- Add tests for both corrections.
(cherry picked from commit 239189ca28847aa4797368827107c22c32080509)
[LLVM] Fix vprintf modular format with constant format string (#203422)
The vprintf family of functions cannot readily have their arguments
scanned for type, but this isn't an obstacle when the format string is a
known constant. This change only requires argument examination as a
fallback when the format string is unknown.
Generated by Gemini; edited and reviewed by hand.
[libc][math][c23] Implement higher math function `cbrtf16` in LLVM libc (#132484)
This PR implements `cbrtf16` for half precision float (`float16`).
Closes #132199.
---------
Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>
[lldb] Enforce that ArchDefaultUnwindPlans declare other regs unfetch (#203684)
I noticed a few of the ABI plugins were not setting
UnspecifiedRegistersAreUndefined()==true in their UnwindPlan rows. This
prevents the unwind engine from trying to fetch registers from any newer
stack frames.
The arch default unwind plans are used by lldb when it doesn't have any
accurate information about the registers a function has spilled to
stack, or where -- it only knows enough to continue walking the stack,
assuming all the functions have stored the caller's pc & fp to stack. It
is the last-ditch fallback when we backtrace through no-symbol /
no-unwind info code.
Normally when the unwind engine does not see a non-volatile aka
callee-preserved register mentioned in an UnwindPlan, that means this
function did not save the register to stack, it left the reg contents
unmodified. So if we are looking for x12 in frame 3, and frame 2 doesn't
mention x12 in its UnwindPlan, we will look in frame 1 to see if it
[11 lines not shown]
[mlir][affine] Fix crash in `SplitDelinearizeSpanningLastLinearizeArg` (#201879)
`SplitDelinearizeSpanningLastLinearizeArg` reads the last element of the
source `affine.linearize_index`'s static basis via
`linearizeOp.getStaticBasis().back()` without checking that the basis is
non-empty.
Other canonicalization patterns can legitimately create an
`affine.linearize_index` with no inputs (and therefore an empty basis):
`CancelDelinearizeOfLinearizeDisjointExactTail` peels the matched
trailing
basis off both the linearize and the delinearize, and when every
linearize
input is part of the matched tail the rewritten linearize is left with
no
inputs. When the resulting delinearize is then visited by
`SplitDelinearizeSpanningLastLinearizeArg`, `.back()` is called on an
empty
`ArrayRef`, tripping the `assert(!empty())` in `ArrayRef::back()` (or
[16 lines not shown]
[llvm] Add floating point exception status for APFloat's exp function. (#203066)
- Add extra Status return parameter for possible float point exceptions.
- Use `LIBC_NAMESPACE::shared::check::exp_exceptions(x, rm)` to test for
floating point exceptions.
- Change `exp` return type to `std::optional<APFloat>` to avoid
`llvm_unreachable` and be able to tell other callers like clang's
`ExprConstant` about currently unsupported types and rounding modes.
[lldb] Decouple LLDB_EXPORT_ALL_SYMBOLS from dynamic interpreters (#203997)
With #201392, we generate a minimal export list when LLDB_ENABLE_
DYNAMIC_SCRIPTINTERPRETERS is set. We therefore no longer need to force
LLDB_EXPORT_ALL_SYMBOLS.
This PR makes the two options independent again. LLDB_EXPORT_ALL_SYMBOLS
now defaults to OFF and, when set, is honored regardless of whether the
script interpreters are built as static or dynamic libraries. otherwise,
when disabled, liblldb exports the generated subset if dynamic
interpreters are enabled, otherwise only the public lldb namespace.
[AMDGPU] Guard against opsel selection in V_PK_*64 (#203986)
These instructions do not have OPSEL or ABS so bail on selection.
This does not affect any tests now because v2f64/v2i64 are not legal
for BUILD_VECTOR and alike, but if it is legal it will silently
produce incorrect code. GlobalISel already has this guard.
[Hexagon] Skip CRT start files for relocatable (-r) links on musl (#201262)
Guard the dynamic-linker, crt1.o, and crti.o additions with OPT_r,
consistent with Gnu.cpp and the existing -pie suppression in this file.
CRT start files must not appear in partial links (-r) as they define
_start, causing duplicate-symbol errors when the output is later linked
into an executable.
[ACCRecipeMaterialization] add tests for private/firstprivate destroy (#203990)
While working on #203935, I noticed that private and firstprivate
recipes with destroy regions were not tested. Add these tests and fix a
bug from the previous commit that would have been caught had these tests
been fixed by generating the destroy region at the correct insertion
point
[AArch64] Add scalable i128 costmodel test coverage. NFC (#203996)
This also adds some basic sub costs, similar to the others, and sorts
the
operations into a more standard order.
[SLP] Fix insert point for insertvalue buildvector with copyable operands
Use the last insertvalue as the insert point (like insertelement) so the
vec2struct store/load are not emitted before the vectorized operand.
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/203994
[docs] Enforce unambiguous toctree in llvm/docs
It seems like using a non-`hidden` `toctree` for page navigation is a
bit of a trap, in that every doc must have a single unique path through
the global toctree to the root doc, and it is very easy to end up with
multiple.
This patch tries to address the warnings (actually infos, hence why it
does not fail the build) in llvm/docs/, namely:
$ sphinx-build -b html -jauto llvm/docs/ /tmp/sphinx-out
checking consistency...
llvm/docs/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack.md: document is referenced in multiple toctrees: ['UserGuides', 'AMDGPUUsage'], selecting: UserGuides <- AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack/AMDGPUDwarfExtensionAllowLocationDescriptionOnTheDwarfExpressionStack
llvm/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.rst: document is referenced in multiple toctrees: ['UserGuides', 'AMDGPUUsage'], selecting: UserGuides <- AMDGPUDwarfExtensionsForHeterogeneousDebugging
llvm/docs/CommandGuide/llvm-reduce.rst: document is referenced in multiple toctrees: ['CommandGuide/index', 'CommandGuide/index', 'Reference'], selecting: Reference <- CommandGuide/llvm-reduce
llvm/docs/GitHub.rst: document is referenced in multiple toctrees: ['GettingInvolved', 'UserGuides'], selecting: UserGuides <- GitHub
llvm/docs/GlobalISel/IRTranslator.rst: document is referenced in multiple toctrees: ['GlobalISel/index', 'GlobalISel/Pipeline'], selecting: GlobalISel/index <- GlobalISel/IRTranslator
llvm/docs/GlobalISel/InstructionSelect.rst: document is referenced in multiple toctrees: ['GlobalISel/index', 'GlobalISel/Pipeline'], selecting: GlobalISel/index <- GlobalISel/InstructionSelect
llvm/docs/GlobalISel/Legalizer.rst: document is referenced in multiple toctrees: ['GlobalISel/index', 'GlobalISel/Pipeline'], selecting: GlobalISel/index <- GlobalISel/Legalizer
[35 lines not shown]
[docs] Create utils/docs
llvm-project is home to many sphinx documentation sites, each with
configuration quirks and bespoke extentions.
The sphinx config model makes sharing code somewhat difficult. There
are options like sphinx-multiproject, but some of our docs builds are
out of the source tree while some are done out of the binary tree, so
the multiproject configuration itself would need to be generated. It
also would impose more uniformity around extensions than required.
This change instead creates a python package at utils/docs/llvm_sphinx
and makes it available to all sphinx-build processes via PYTHONPATH.
Each conf.py does not modify its own sys.path because not all builds are
out of the source tree, so there isn't a stable relative path to use to
refer to the utils/docs/ directory.
Type checking via pyright in new package is pinned to being python 3.8
compatible.
[29 lines not shown]
[CIR] Fix bitfield post-increment return value (#201723)
In \`emitScalarPrePostIncDec\`, the bitfield branch called
\`emitStoreThroughBitfieldLValue\` and returned its result directly,
bypassing the \`return e->isPrefix() ? value : input\` logic that
selects old vs new for post vs pre-increment. For post-increment on a
bitfield, this returned the new (incremented) value instead of the old
one, so \`if (s->nRefs++)\` always evaluated true even when \`nRefs\`
was zero on entry.
Fix by assigning the store result to \`value\` and falling through to
the existing prefix/postfix selector, mirroring the non-bitfield path.
Found via the SPEC CPU 2026 abc_r benchmark: \`Cnf_ManScanMapping_rec\`
uses \`if (pObj->nRefs++)\` on a 26-bit bitfield to detect
already-visited AIG nodes. With the bug, every call returned true
(already visited) immediately, producing an empty CNF mapping and a
spuriously satisfiable SAT problem (133 variables instead of 3018).
[CIR] NFC: Clarify Expand insertion-point guard
Gate the field-store insertion point on the same destAlloca condition
that gates emitting the stores. This makes it explicit that when the
CIRGen spill is absent (DCE removed it) the Expand path only reshapes
the signature and emits no stores, so no insertion point is consulted.
When the spill survives, the insertion point is its old slot, which sits
after the CIRGen allocas. No functional change.
[CIR] Lower __builtin_bswapg (#203618)
C++23 `std::byteswap` lowers every value wider than a single byte
through the type-generic `__builtin_bswapg` builtin, which CIRGen had no
case for, so `std/numerics/bit/byteswap.pass.cpp` hit `errorBuiltinNYI`.
This handles `__builtin_bswapg` the way classic CodeGen does
(`CGBuiltin.cpp`): a bool or single-byte integer is returned unchanged,
and wider values go through `cir.byte_swap`. Unlike the unsigned-only
`__builtin_bswap16/32/64`, the generic builtin also accepts signed
operands, so a signed argument is reinterpreted as unsigned of the same
width before the swap and cast back afterward.
`cir.byte_swap` previously accepted only 16/32/64-bit operands, but
`std::byteswap` instantiates it for `__int128` and wide `_BitInt` too
(the libc++ test reaches `_BitInt(256)`). The operand constraint is
widened to any unsigned integer whose width is a multiple of 16 bits --
which is what `llvm.bswap` requires -- and the existing CIR-to-LLVM
lowering already handles any such width. With the fix,
`byteswap.pass.cpp` passes under `-fclangir`.
[AMDGPU] Guard against opsel selection in V_PK_*64
These instructions do not have OPSEL or ABS so bail on selection.
This does not affect any tests now because v2f64/v2i64 are not legal
for BUILD_VECTOR and alike, but if it is legal it will silently
produce incorrect code. GlobalISel already has this guard.