[CIR][test] Use global instcombine RUN line in AArch64 neon subtracti… (#207894)
Related to https://github.com/llvm/llvm-project/issues/185382
Follow-up to https://github.com/llvm/llvm-project/pull/207115
Include `instcombine` into the global LLVM RUN line and remove the
separate `LLVM-IC` prefix that only covered the narrowing-subtraction
tests in `clang/test/CodeGen/AArch64/neon/subtraction.c`.
Update LLVM CHECK to match the `instcombine` output: bitcast checks are
dropped, the inferred `nsw` flags are added on the widening subs, and
unused shuffle operands are canonicalized to `poison`.
BPF: Fix misfolding subregisters
This would end up introducing a copy between registers
with mismatched sizes previously. Defends against verifier
failures in a future change.
The actual transform here should be deleted. Optimizations should
not be trying to introduce SUBREG_TO_REG.
[AggressiveInstCombine] Factor out the common part of tryToRecognizeTableBasedCttz and tryToRecognizeTableBasedLog2. NFC (#208123)
They both start with the same GEP+load matching.
Assisted-by: Claude
BPF: Remove unnecessary isReg check on phi operand
These must be a register. This pass has quite a lot of
defensive code against invalid MIR that should be deleted.
[AMDGPU] Reimplement icmp and fcmp builtins using ballot (#208231)
Use `llvm.amdgcn.ballot` instead of the deprecated intrinsics
`llvm.amdgcn.icmp` and `llvm.amdgcn.fcmp`.
[cmake] FindLibXml2: fall back to xmlversion.h when pkg-config has no… (#207797)
… version
LLVM's cmake/modules/FindLibXml2.cmake uses PC_LIBXML_VERSION (from
pkg-config) as the VERSION_VAR in find_package_handle_standard_args.
When pkg-config has no libxml-2.0.pc file (e.g. when linking against a
static libxml2-pic.a that ships no .pc file), PC_LIBXML_VERSION is left
empty after pkg_check_modules fails and the >=2.8 version check reports
'Found unsuitable version ""', causing LLDB_ENABLE_LIBXML2 to be set to
FALSE.
Fix: before calling find_package_handle_standard_args, check whether
PC_LIBXML_VERSION is still empty and if so read LIBXML_DOTTED_VERSION
from the xmlversion.h header. This mirrors the version-detection logic
in the system CMake FindLibXml2 module and ensures LLDB is built with
libxml2 support on installations that use a static libxml2 without a .pc
file.
Regen syscalls tables.
This catches up with 692b0ef1506ba which added CAPENABLED to
clock_nanosleep(). Curiously recent additions of the pdopenpid(2) and
pddupfd(2) were done before the cited commit, and that regen did not
included the change.
Sponsored by: The FreeBSD Foundation
[lldb] Fix assert when `target frame-provider register` succeeds (#208232)
`CommandObjectTargetFrameProviderRegister::DoExecute` never called
`CommandReturnObject::SetStatus()` on its success path.
`CommandObject.cpp` has a `DoExecuteStatusCheck` RAII guard that resets
the result's status to `eReturnStatusInvalid` before `DoExecute` runs,
and asserts on exit that `DoExecute` changed it.
`AppendMessage()`/`AppendMessageWithFormatv()` don't touch status
(unlike AppendError()/SetError(), which call
`SetStatus(eReturnStatusFailed)`), so on the success path the status
stayed eReturnStatusInvalid, tripping the assert.
This went unnoticed because every existing `scripted_frame_provider`
test uses `SBTarget::RegisterScriptedFrameProvider` directly, bypassing
the `target frame-provider register` command entirely. Add a regression
test that exercises the command instead.
Assisted-by: Claude
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
[clang] Use DynamicRecursiveASTVisitor for AST listing (#202661)
Replace `ASTDeclNodeLister`'s CRTP `RecursiveASTVisitor` with
`DynamicRecursiveASTVisitor` while keeping `ASTPrinter` and
`ASTDeclNodeLister` separate. Set `ShouldWalkTypesOfTypeLocs` to false
to
preserve the previous traversal.
In identical arm64 release builds, standalone clang shrinks by 251,840
bytes
(0.215%), stripped clang by 149,488 bytes, and `ASTConsumers.cpp.o` by
153,352
bytes; linked `__TEXT` falls by 147,456 bytes and linked fixups increase
by
1,040.
The `-ast-list` output is byte-identical on the existing clang-check
input and
`ASTConsumers.cpp` (150,918 lines); two reversed-order ten-run timing
[6 lines not shown]
[libc++][pstl] Default implementation of parallel std::find_first_of (#206328)
This PR adds a default "one-liner" implementation of parallel
`std::find_first_of` expressed as a call to `__find_if`.
The implementation is based on find_if and any_of.
Part of #99938
[RISCV] Avoid let statements in RISCVSystemOperands. NFC (#207890)
Add an optional RV32Only operand to SysReg.
Add AltSysRegName and DeprecatedSysRegName wrappers.
[SelectionDAG][X86] Replace OriginalDemandedBits with DemandedBits in SimplifyDemandedBits ISD::PDEP handling. (#208104)
DemandedBits is set to all 1s if the node has multiple uses.
Fixes regression from #204144. The changed test case reverts back to the
output before that change.
[flang][acc] Emit acc.on_device operation for acc_on_device call
It is important we recognize acc_on_device calls as they need to be
folded during compilation. Emitting this operation helps with the
recognition of the runtime call in the optimizer.
[libc] Move fcntl implementation into the syscall_wrappers layer (#207878)
linux_syscalls::fcntl called SYS_fcntl unconditionally, breaking the
riscv32 full build where only SYS_fcntl64 exists. The syscall selection
and command translation already lived in internal::fcntl, so move that
implementation into syscall_wrappers/fcntl.h, delete the legacy
OSUtil/fcntl.h and OSUtil/linux/fcntl.cpp, and port the callers (fcntl
entrypoint, file.cpp, dup2.h) to linux_syscalls::fcntl.
[SPIRV] Support atomic exchange of pointers (#207830)
Similar to what we do for atomic loads and stores, support pointers by
converting the exchange value to an equally-sized int, the pointer to a
pointer to that equally-sized int, and convert the result back to the
original pointer type.
This was found enabling support for SPIR-V in libc.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply at anthropic.com>
Signed-off-by: Nick Sarnie <nick.sarnie at intel.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply at anthropic.com>
[llubi] Add support for constant inttoptr/ptrtoint expressions (#207028)
This patch adds support for constant inttoptr/ptrtoint expressions to
unblock the running of csmith-generated programs.
The test doesn't cover all the behaviours, as they have been tested by
previous tests.
This patch treats constant inttoptr/ptrtoint expressions as if they are
executed just before the user. However, since ptrtoint exposes the
pointer provenance and inttoptr relies on the current set of exposed
provenances, it is incorrect. Imagine that we have an inttoptr in a gep
instruction and a ptrtoint in an add instruction. They can be freely
DCEd/reordered. In addition, the behaviour also depends on the
initialization order of globals. That is terrible. Nikita's proposal
also mentioned this issue but left it as an open question:
https://hackmd.io/@nikic/SJBt4mFCll#Constant-expressions
From my perspective, constant expressions are allowed to execute at any
point in the program (before their users). Moving ptrtoint forward or
[4 lines not shown]
[clang][Serialization] Deduplicate loaded header-unit SLoc ranges
Header units that textually include the same large header used to consume
loaded SourceLocation address space independently, even when the serialized
file contents were identical. Importing many such header units could therefore
run out of the loaded SLoc region long before the translation unit was large in
any meaningful source sense.
Use the eager SLoc dedup metadata to share already-loaded file ranges when a
later header-unit PCM contains a matching dedupable file entry. The reader now
builds a per-module remapping from serialized local offsets to the global
SourceManager offsets actually used for the import. Fresh entries are packed
into the module's allocation, while duplicate file entries map back to the
canonical FileID and offset range from the first loaded PCM.
This changes the module-loading model from a single base-offset translation
for every loaded location to a segmented translation for PCMs that participate
in deduplication. Modules without dedup metadata keep the existing single-add
fast path. The SourceManager loaded-entry table only receives slots for entries
[6 lines not shown]
[clang][Serialization] Record SLoc dedup metadata in PCMs
Clang's loaded SourceLocation address space is finite: loaded AST files
reserve offsets from SourceManager's 32-bit loaded region. C++20 header
units make this easier to exhaust because independently-built PCMs can all
serialize SLocEntries for the same large textual include, such as a standard
library header.
This change adds the serialization-side metadata needed to recognize those
repeated file entries later. When the new cc1 flag is enabled, header-unit
PCMs now write an eager SLOC_ENTRY_DEDUP_INFO record parallel to
SOURCE_LOCATION_OFFSETS. Each serialized SLocEntry gets fixed-width metadata:
its local SLoc offset and length, an xxh3-128 content hash for dedupable file
entries, flags describing file properties that affect safe sharing, and the
input-file ID. Entries that are not currently dedupable keep zero hashes.
The record is intentionally module-kind agnostic, but emission is limited to
C++20 header units for the initial rollout. Readers cache the blob at module
load time without changing allocation behavior yet. The PCM major version is
bumped because this adds a new serialized AST record layout.
[mlir][acc] Add utilities for working with acc par dims (#208120)
Add shared helpers for reading, setting, and manipulating parallel
dimensions on operations, covering both discardable and inherent
attributes.
[Clang] Disable verifier passes by default in NewPM CodeGen (#208178)
By default, we shouldn't add expensive verifier passes to the pipeline.
This causes a substantial perf regression compared to the legacy PM.