[scudo] Add DoubleFreeFromSecondary death test (#242398)
Complement DoubleFreeFromPrimary with a death test verifying that
double-freeing a cached secondary allocation fails with "invalid chunk
state" (or faults under MTE, which marks cached secondary entries
MAP_NOACCESS). Guard the test on configurations with an active secondary
cache, since uncached blocks are unmapped on the first deallocate() and
fault when loading the chunk header instead.
Also remove an unused condition_variable.h include.
Used Gemini to review my change.
[bazel] Add subpackages for libc/hdr/... (#242520)
This PR creates subpackages for `libc/hdr/...` as part of
https://github.com/llvm/llvm-project/issues/238076.
The refactor was entirely generated by a one-off tool
[jtstogel/bazel-move-targets](https://github.com/jtstogel/bazel-move-targets)@1e51f7f
(LLM-written), since AFAICT there's no good standard tooling for this
kind of thing.
Generated by:
```
function new-pkg() {
pkg=$1
shift
bazel-move-targets move \
--workspace_root=utils/bazel/llvm-project-overlay \
--src_package=libc \
[9 lines not shown]
clang/AMDGPU: Check constant argument ranges of builtins
These builtins take a constant argument that the IR verifier range
checks on the corresponding intrinsic. Sema didn't enforce this, so
you could write code that failed the IR verifier. Use the new Range
annotation on the builtins to fix this.
This only covers builtins that previously had no range validation at
all. Builtins already checked by the manual switch in SemaAMDGPU will
be converted separately.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[docs] Use intersphinx for LLVM cross-project links
Configure the LLVM documentation with the external project inventories it
references and replace absolute cross-project documentation URLs with
validated intersphinx document and reference roles.
Part of #214861
LLM-aided
[docs] Use intersphinx for Clang cross-project links
Configure the Clang documentation with the external project inventories it
references and replace absolute cross-project documentation URLs with
validated intersphinx document and reference roles.
Part of #214861
LLM-aided
[docs] Add a shared intersphinx inventory for LLVM projects
Define the documentation sites of the LLVM subprojects in one place so each
project's Sphinx configuration can resolve cross-project links through
intersphinx instead of absolute URLs. The mapping is not used by any project
yet; follow-up changes adopt it. Document the `inv:` link syntax in the Sphinx
quickstart so authors know how to write these links.
By default the inventories are fetched from the published sites, which keeps
developer builds fast and free of new dependencies. Setting
LLVM_SPHINX_INVENTORY_DIR makes a
build hermetic instead: an `inventory` Sphinx builder writes only `objects.inv`
for each project, and the HTML builds read them all from that directory, so every
link resolves with no network access, including links to labels added by the
same change and circular links. The tools and the runtimes are separate CMake
builds, so the utils/docs/hermetic_build project builds both as ExternalProjects:
first their inventories in parallel, then their docs in parallel. The
documentation CI workflow uses it and always builds all of the docs, because
the projects'"'"' docs now depend on each other.
[4 lines not shown]
[clang][deps] Flush the in-process module cache on a background thread
The in-process module cache keeps every PCM built during the lifetime of the
dependency scanning service in memory, and flushes them to disk at the end.
Long-running builds that scan many variants of modules (e.g. with different
search paths or macro definitions) accumulate tens of gigabytes worth of
scanning PCMs this way. Moreover, the final flush is single-threaded and
happens after all scanning work is done.
This PR makes the service start a background thread that flushes each PCM to
disk as soon as it's written, and then replaces its in-memory buffer with the
memory-mapped file. Readers of the in-memory buffer keep it alive on their own
(shared ownership), and importers of the freshly built PCM never wait for the
IO, since the file gets written without holding the entry lock. Reads and
timestamps are still served from memory. The final flush is kept, but only
writes PCMs the background thread failed to write. With
`-no-flush-module-cache`, nothing changes.
I tried several approaches, all measured on a scan of the macOS SDK where
[52 lines not shown]
[clang] Extract built PCMs from their container without copying
When a module is built implicitly, the importing instance extracts the AST
file from the module cache's view of the written PCM and stores a copy of it
in its `InMemoryModuleCache`. That's an extra heap copy of every built PCM,
kept alive for the lifetime of the translation unit.
This PR resolves the FIXME by storing a buffer that keeps the written PCM
alive and exposes just the AST file: the `__clangast` section for PCMs
wrapped in an object file (`-gmodules`), or the whole PCM otherwise. The
in-process module cache now shares the memory of its entry with the
importing instance, and the cross-process module cache gives it the
memory-mapped file.
For a regular implicit modules build importing Foundation and friends, this
reduces peak memory footprint from ~150 MB to ~100 MB. For a TU importing
Foundation with `-gmodules` (31 PCMs), the copy increased the peak memory
footprint by 12-17%.
[clang] Use the module cache's view of built PCMs
When building a module implicitly, the compiler hands the PCM contents to
`ModuleCache::write()` and then extracts the AST file from the PCH container
of its own buffer, storing a copy of it in the `InMemoryModuleCache` of the
importing instance.
This PR makes `ModuleCache::write()` return a buffer with the written
contents, which the importing instance now extracts the AST file from. The
in-process module cache returns a buffer sharing ownership of its entry, the
cross-process module cache returns the written file, read back from the same
file descriptor it was written through (memory-mapped for all but small
files). This is a prerequisite for storing the module cache's view in the
`InMemoryModuleCache` without copying it.
To support this, `writeImpl()` can now read the written file back from the
same file descriptor, guaranteeing we map exactly the contents we wrote and
making it immune to concurrent replacement of the file.
[4 lines not shown]
[clang][deps] Share ownership of buffers in the in-process module cache (#242382)
Previously, `InProcessModuleCache::read()` returned non-owning
references
to buffers stored in the cache entry. Since other threads may be reading
an entry while it gets written, the entry had to keep the buffer it read
from disk alive alongside the written buffer for the lifetime of the
service. This happens whenever a PCM read from disk turns out to be out
of
date and gets rebuilt.
This PR stores a single buffer with shared ownership in the entry and
makes `read()` return a buffer that keeps the contents alive. Writing to
the entry now simply replaces the buffer, and the previous one gets
released
once the last reader is done with it. This is a prerequisite for
evicting
buffers from memory.
[9 lines not shown]
[lldb] Use the indexed host shared cache for symbolication (#194998)
Add HostInfo::WithSharedCacheImage to look up a dyld shared cache image
directly by UUID, replacing the expensive repeated loading of the SC in
ObjectFileMachO's symbol table parsing. The new API takes a callback
that receives the retained image handle, ensuring it remains valid for
the duration of the call.
[ValueTracking] Propagate poison through lround and llround (#242066)
`llvm.lround` and `llvm.llround` (along with their constrained FP
variants) have the same poison-propagation semantics as `llvm.lrint` and
`llvm.llrint`. Add them to `intrinsicPropagatesPoison` so
`propagatesPoison` and `InstSimplify` fold poison inputs to poison.
Gemini was used to help generate this change and its tests.
Hexagon: Remove dead kill flag maintenance in HexagonQFPOptimizer (#239775)
The operands are virtual registers, which can no longer carry kill flags.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[bazel] Add subpackages for libc/src/... (#242489)
This PR creates subpackages for `libc/src/...` as part of
https://github.com/llvm/llvm-project/issues/238076.
`alias` targets are left for compatibility so that downstream targets do
not need to be updated in lock step w/ this PR.
The refactor was almost entirely generated by a one-off tool
[jtstogel/bazel-move-targets](https://github.com/jtstogel/bazel-move-targets)@1e51f7f
(LLM-written), since I couldn't find any standard tooling for this kind
of thing.
Generated with commands:
```
function new-pkg() {
pkg=$1
shift
[52 lines not shown]
[AMDGPU] Insert s_nop 0 for cross-wave VALU co-execution on gfx942/gfx950
On subtargets with FeatureGFX9CrossWaveVALUCoexecution, a SIMD can
co-issue VALUs of two waves, depending on both VALUs. While an older
wave issues a sequence of VALUs, a younger wave's VALU that cannot
be co-issued with them stalls, and so do the VALUs that follow it.
Inserting s_nop 0 in the older wave lets the younger wave issue that
VALU.
SIPreEmitPeephole now inserts s_nop 0 where this lets the younger wave
co-issue a sequence of VALUs. It does so only in small loops that
consist mostly of such VALUs, outside MFMA shadows, and when the
occupancy is not known to be 1.
-amdgpu-gfx9-cross-wave-valu-coexec-opt-threshold=0 disables the
transformation.
Assisted-by: Claude Opus 5.5
[SystenZ][z/OS] Beautify HLASM output
Instructions are currently indented by 2 spaces, which makes the output
hard to read. This changes increases the indentation to 10, which improves
the readability. The indent is now controlled by a constant instead of
hard-coded spaces.
Fix incorrect `this` alignment in virtual function thunks. (#242501)
In a few different places we were incorrectly computing the alignment of
`this` when emitting thunks for virtual function calls, generally by
picking up information from the derived type's this pointer, which in
general might be more aligned than the this pointer that a thunk
actually sees.
Assisted-by: Antigravity with Gemini and Claude