[CIR] Atomic load and store via library call (#202671)
This patch adds support for atomic load/store operations that go through
calls to the `__atomic_load` and `__atomic_store` library functions.
This could happen when the size of the atomic type is too large or is
not a power of 2.
Assisted-by: Codex / gpt-5.5 xhigh
[libc] Add loff_t type (#204641)
Added loff_t type definition. This is a Linux extension required for
large file offsets.
* llvm-libc-types/loff_t.h: Include linux/loff_t.h on Linux.
* llvm-libc-types/linux/loff_t.h: Added Linux definition using
__kernel_loff_t.
* llvm-libc-types/CMakeLists.txt: Include linux subdirectory and add
dependency for loff_t.
* llvm-libc-types/linux/CMakeLists.txt: Registered loff_t.
* sys/types.yaml: Added loff_t to sys/types.
* libc/include/CMakeLists.txt: Added dependency to sys_types target.
Assisted-by: Automated tooling, human reviewed.
[LifetimeSafety] Model pointer-to-data-member access in the fact generator (#204612)
VisitBinaryOperator had no case for `obj.*pm` (BO_PtrMemD) /
`objptr->*pm` (BO_PtrMemI), so a borrow of the accessed member
(`&(obj.*pm)`) dropped the object's loan to an empty origin and a
use-after-scope was missed. Flow the object operand's origin into the
result, mirroring a member access: for `.*` the object is the LHS, for
`->*` it is the LHS pointer's pointee.
Assisted-by: Claude Opus 4.8
Co-authored-by: Gabor Horvath <gaborh at apple.com>
Recommit "[libc] Introduce the ioctl syscall wrapper and port all callers (#204640)" (#205317)
This patch reapplies #204640 (reverted in #205277), due to (-Werror)
build failure with gcc. Gcc warned about passing an uninitialized
structure through a `const void *` argument. This isn't a problem
because the ioctls in question write to that argument. The
fix/workaround is to provide a `void *` overload.
The original commit message was:
This patch adds an ioctl syscall wrapper in linux_syscalls namespace and
migrates all direct SYS_ioctl calls to use it.
To handle the polymorphic nature of ioctl arguments (where some commands
expect pointers, some expect scalar integers like queue_selector, and
some expect no argument at all), I use a helper struct IoctlArg with
implicit constructors. This avoids template bloat and overload
ambiguities (particularly around literal 0) while keeping call sites
clean.
Assisted by Gemini.
[SLP]Fix dominance crash for scheduled copyable PHI-operand bundles
Extend the copyable/non-copyable PHI conflict bail-out in
tryScheduleBundle to the scheduled path, not just the non-schedulable
one.
Fixes #205327
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/205372
[CIR] Add cir.builtin_int_cast operation to replace uses of builtin.unrealized_conversion_cast (#201592)
This patch adds a new operation builtin_int_cast to handle casting
between CIR integer types and builtin integer types. This will replace
the current use of the builtin.unrealized_conversion_cast since this
operation is only intended to be used temporarily when doing
transformations.
Assisted-by: Cursor/Claude Opus 4.8 High
[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 extensions.
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]
[docs] Add BOLTAArch64OptimizationStatus to toctree
Building docs-bolt-html fails with:
Warning, treated as error:
/home/slinder1/llvm-project/scratch/bolt/docs/BOLTAArch64OptimizationStatus.rst:document isn't included in any toctree
Just add the orphan document to the toctree in the index to silence
this. If there is a better parent it can be moved somewhere else in the
tree.
Change-Id: I1d26d96d5485d97d29231da89f8c8408b375c41f
Bump minimum required sphinx Python to 3.8
There seems to be de-facto use of at least 3.6 in docs, namely:
* Use of pathlib (3.4) in various places
* Format f-strings (3.6) and used in clang/docs/ghlinks.py
I don't see a strong reason to maintain the divide in minimum version
between test/docs, especially considering the "FIXME" indicating
the 3.0 lower bound was just a guess to begin with.
Change-Id: I11e00295ae0a13ec0f1c5cefbb2fdd2db272b152
clang/AMDGPU: Require 16-bit-insts for half typed image builtins
Typed image load/store operations with 16-bit elements require d16
support which was introduced in gfx8. They were previously gated only
on image-insts, so they were wrongly accepted on targets that have
images but lack 16-bit support (e.g. gfx700), where the backend then
fails to select.
Co-Authored-By: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Require 16-bit-insts for half typed buffer format builtins
Typed buffer format load/store operations with 16-bit elements require
d16 support which was introduced in gfx8. These builtins previously had
no required features at all, so they were accepted (and then crashed the
backend) on targets without 16-bit support.
Diagnose these in Sema, parallel to the image builtins. The manual
verification here suprised me. The automatic builtin feature verification
is enforced in codegen, which seems like a layering violation which
should be fixed.
Co-Authored-By: Claude (Opus 4.8) <noreply at anthropic.com>
[CIR] Lower elementwise saturating add/sub builtins (#203112)
`__builtin_elementwise_add_sat` and `__builtin_elementwise_sub_sat` were
still in the `errorBuiltinNYI` batch in `emitBuiltinExpr`, so any use
hit "unimplemented builtin call". That blocks C++26
`std::add_sat`/`std::sub_sat` (libc++
`<__numeric/saturation_arithmetic.h>`), which lower directly onto these
builtins.
This lowers them the way classic CodeGen does in `CGBuiltin.cpp`: select
the signed or unsigned saturating intrinsic from the operand's element
type (`sadd.sat`/`uadd.sat` for add, `ssub.sat`/`usub.sat` for sub).
Test coverage in `builtins-elementwise.c` exercises signed and unsigned,
scalar and vector, at i32 and i16 widths, checking the CIR
`cir.call_llvm_intrinsic` and the lowered `@llvm.{s,u}{add,sub}.sat`
calls on both the CIR and classic `-emit-llvm` paths.
[X86] madd.ll - add additional tests for matchPMADDWD folds that fail with larger source types (#205362)
matchPMADDWD handles sext/shl cases as well which don't fold either on SSE/AVX512 targets
[libc++][ranges] Backport P2711R1: Making multi-param constructors of views explicit (#190513)
As discussed in https://gcc.gnu.org/PR114298 - GCC and MSVC STL
implemented P2711R1 as a DR. This PR does the same for libc++.
Co-authored-by: A. Jiang <de34 at live.cn>
[docs] Fix typo in Docker.rst (#205346)
Small typo fix in the Docker documentation: Debian8 -> Debian12.
Signed-off-by: Felipe Novais <contact at felipenovais.com>
[clangd] fix preprocessor caching-lexer state tracking (#203716)
Fix `recomputeCurLexerKind` to avoid default fallback to
`CurLexerCallback = CLK_CachingLexer;`.
This prevents code-completion EOF handling from accidentally restoring
CLK_CachingLexer while a tentative parse is still active, which could
trigger a caching lexer re-entry assertion in clangd signature help.
Fixes https://github.com/llvm/llvm-project/issues/200677
---------
Signed-off-by: yronglin <yronglin777 at gmail.com>
[LegalizeTypes] Fix incorrect EVL1 clip in SplitVecRes_VP_SPLICE. (#205021)
We were incorrectly clipping EVL1 to be a valid index for the VT, in the
range [0, VT.getNumVectorElements() - 1]. It is legal for EVL1 to be
equal to VT.getNumVectorElements() here so that was incorrect.
In case it isn't clear, the clip is necessary to prevent turning poison
into UB by accessing outside the temporary stack object.
[RISCV][P-ext] Add mvd alias for padd.dw rd, zero, rs. Use for copy idiom. (#205223)
See https://github.com/riscv/riscv-p-spec/pull/304
I've refactored the MoveMerge code to use copyPhysReg to avoid duplication.
[clang][Dependency Scanning] Fix the Input File for By-Name Lookup's Input CC1 Command Line (#205214)
When the command line is a CC1 command, the scanner does not append the
fake input file to the command line when initializing the compiler
instance. This PR fixes that by passing the compiler instance
initialization the correct modified command line. Without specifying the
fake input file, clang picks up `-` as its input.
An observable behavior is that the diagnostics are pointing to incorrect
files for cc1 commands, hence a test is added to check the diagnostics
messages contain the correct file name.
Reland "[libc] Implement basename and dirname in libgen.h #204554" (#205352)
Added the POSIX standard functions basename and dirname under a new libgen.h header. The implementations modify the input path in-place using cpp::string_view to determine boundaries safely.
Added find_last_not_of to cpp::string_view to support trailing slash removal.
Implemented:
libc/include/libgen.yaml, libgen.h.def: Public API definitions.
libc/src/libgen/basename.cpp, dirname.cpp: Generic implementations.
libc/test/src/libgen/: Unit and hermetic tests.
Registered the new entrypoints for all active Linux targets (x86_64, aarch64, arm, riscv) and added docgen configuration.
The tests are skipped when using ASan because death tests do not currently work with them.
Assisted-by: Automated tooling, human reviewed.
[mlir][arith] Reject signful integer element types in `arith.constant` (#204937)
Update arith.constant verification to reject integer constants with
signed and unsigned element types including shaped constants like
tensors and vectors, as the arith dialect does not support
signed/unsigned types.
This incidentally address cases where further lowering would crash (e.g.
SPIR-V constant lowering used IntegerAttr::getInt() on an unsigned
integer attribute from tensor<2xui8>)
Fixes #204911
[Hexagon] Add KCFI support for forward-edge control flow integrity (#191746)
Add KCFI support for Hexagon. KCFI provides lightweight forward-edge CFI
for indirect calls by embedding a type hash before each function and
checking it before indirect calls, without requiring LTO.