[ORC] Add ConnectionSpec for connection string parsing (#224000)
A ConnectionSpec is the parsed form of a string describing one
connection a process should establish with its peer:
<transport>[:<action>]=<descriptor>
E.g. "fd=3" or "tcp:connect=localhost:20000". The parser only checks
punctuation: transport and action names are opaque tokens, and the
descriptor's syntax is left to the transport, which lets a descriptor
contain ':' and '=' unescaped (e.g. "tcp:listen=[::1]:0").
This will be used by llvm-jitlink and llvm-jitlink-executor to
generalize out-of-process executor connection setup beyond the current
fd/TCP-only options.
[clang][flang][OpenMP] Correct OpenMP context selector matching and scoring
Context selector ranking is shared by DECLARE VARIANT and metadirective
lowering. Incorrect construct matches, context-dependent device weights, or
overflowing scores can select a different variant and cause Flang to skip
required loop diagnostics.
Preserve the highest-scoring ordered construct matches and derive device
weights from the enclosing context. Widen score arithmetic as needed, and
retain selector identity and scores for unknown properties so MATCH_ANY and
MATCH_NONE handle dynamic conditions and implicit NOTHING correctly. Bound
lowering contexts at TARGET and include SIMD traits so Clang and Flang use
the same context for selection.
Assisted with codex.
[SPARC] Fix SelectForceADDRrr for global addresses and non-reg operands (#220013)
When lowering byte-swapped memory operations on SPARC V9, LLVM emits
ASI-tagged memory instructions (such as STHArr, STArr, LDArr, etc.) that
require register+register addressing modes matched via ForceADDRrr.
SelectForceADDRrr previously forwarded 2-operand address nodes directly
to SelectADDRrr. However, SelectADDRrr explicitly returns false when
encountering SPISD::Lo (used in %hi/%lo global address calculations) or
small constant offsets in order to allow standard ADDRri patterns to
match. Because SelectForceADDRrr returned the result of SelectADDRrr
directly instead of falling back to Base = Addr, Disp = %g0, any
endian-adjusted load or store targeting a global variable failed to
select and caused a backend compiler crash:
"Cannot select: SPISD::STORE_LITTLE ..."
Fix SelectForceADDRrr so that if SelectADDRrr fails to match, it falls
back to evaluating the full address into a base register and using %g0
as the offset register. Also add tests for global variable byte-swapped
[7 lines not shown]
[libc++] Don't assume a valid range in find_if for empty inputs (#213752)
Iterators for empty ranges are sometimes implemented using a
non-aligned sentinel value. Requiring proper alignment in that
case (which is part of the valid range assumption) causes a
hardening failure. Instead, don't make the assumption of a
valid range when the input range is empty in find_if.
(cherry picked from commit 83290d61f6ead40a5c38297a0442b63291ce7a48)
[libc++] Opt `std::*set` out of map key extraction optimization (#220452)
PR #154512 (relanded by #155565) removed `__can_extract_map_key`, which
had a blanket opt-out for `std::*set`s. The new logic does not have that
opt-out, leading to `std::set`s being incorrectly constructed.
The new regression tests demonstrate this, but essentially the idea is:
1. Have `std::set<T> foo;`
2. Call `foo.emplace(some_t,
arg_that_influences_comparisons_or_hashes);`
3. The emplace will internally search using `some_t` as the key, *not*
`T(some_t, arg_that_influences_comparisons_or_hashes);`
This opts out `std::*set` from this optimization to match previous
behavior.
Tests and fix were produced by an LLM. I reviewed them and they seem
reasonable to me, though I don't have a strong background in libc++
testing conventions.
[7 lines not shown]
[DirectX] Make DXILOpLowering split vector coordinates, offsets, and gradient operands (#223091)
Fixes https://github.com/llvm/llvm-project/issues/217777
DXILOpLowering didn't split vector coordinates, offsets, and gradient
operands into scalars for textureLoad, textureStore, and sample
intrinsics like it did for store data. This PR fixes that.
This PR also removes inconsistencies where the DXILOpLowering pass
emitted a mix of i64 and i32 indices for `extractelement`. It now just
emits i32 indices.
Assisted by: Claude Opus 5
[test][bazel][libc] Allow LLVM-libc tests to be run in full-build mode
This PR makes the required changes to run LLVM-libc full build tests in Bazel. After this PR, most tests pass:
```
bazel test @llvm-project//libc/test/... --config=ci --@llvm-project//libc:build_mode=full --keep_going
Executed 680 out of 853 tests: 681 tests pass and 172 fail to build.
```
Follow on PRs will fix specific tests that are failing (lots of missing deps etc).
This PR mostly involves propagating the correct dependencies and compiler/linker options from [`add_libc_hermetic`](https://github.com/llvm/llvm-project/blob/4098f568c46e06b6df470111868b4c165dd80f4d/libc/cmake/modules/LLVMLibCTestRules.cmake#L750). Slightly more involved changes:
- `BazelFilePath.cpp` also had to be fixed so that it doesn't depend on the non-namespaced `getenv` function. This PR models after https://github.com/llvm/llvm-project/commit/ee407f7e7069cccfdc1815de07e17cebf83d19f9 in order to conditionally use LLVM-libc's getenv under full-build mode.
- All tests have a dependency against `crt1.o` when run under full-build. This PR updates `merge_relocatable_object` so it also exposes a `CcInfo` with the merged object file and its transitive deps. In order to do so, this PR also makes the logic a little more careful about PIC vs non-PIC deps.
[HLSLSemanticSignatures] Implement the indexed packing of elements (#218061)
Implements the indexed packing algorithm.
Resolves: #205877
Assisted by: Claude Opus 5 and GPT-5.6 Sol
WebAssembly: Drive Emscripten EH from the exception model, drop the cl::opt
Remove the deprecated -enable-emscripten-cxx-exceptions flag. This should now
be driven by the generic exception-model mechanisms. There was also some special
case handling of the -mllvm flag in the clang driver which also needed removal.
Also reverts the test change in b6912258891caefffbf15edb1bceff3724b75af5 now that
the backend doesn't need to be built to test the flag behavior.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
RuntimeLibcalls: Read exception model from the module flag
Source the exception model in the RuntimeLibcallsInfo(Module) constructor
from the "exception-model" module flag via Module::getExceptionModel(),
instead of forwarding it from TargetOptions. An absent flag resolves to
Default and then to the triple default; an explicit "none" disables
exceptions.
Since the model now comes from the module, drop the ExceptionModel that
RuntimeLibraryAnalysis carried and forwarded, and its argument at every
construction site.
To keep the -exception-model= command-line option working for llc and opt
synthesize the "exception-model" module flag from the option as is done for
"float-abi".
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[RISCV] Don't construct a subtarget for function declarations in RISCVPromoteConstant. (#224115)
Intrinsic declarations in particular don't have a target-features
attribute so the subtarget constructor may print warning like:
hard-float 'd' ABI can't be used for a target that doesn't support the D
instruction set extension
This can occur in LTO builds in -mcpu is not passed to the clang driver
on the LTO step. The target-machine won't have any CPU features.
[CIR] Add cir.ptr_mask
`cir.ptr_mask` ANDs a pointer with an integer mask and gives back a
pointer, lowering to llvm.intr.ptrmask. Paired with `cir.ptr_stride` it
rounds a pointer up to an alignment the way classic's
emitRoundPointerUpToAlignment does, without the round trip through an
integer that would lose provenance.
llvm.ptrmask needs the mask at exactly the target's pointer index width,
so the lowering extends or truncates it first. GEP takes an index of
any width, so `cir.ptr_stride` never needed this.
Assisted-by: Cursor / claude-opus-5
[CodeGen] Size live ranges in real instructions
Slot indexes keep counting instructions that earlier passes erased,
because erasing one only clears the pointer in its index list entry.
The leftovers are not spread evenly, so they inflate some live ranges
more than others and reorder greedy's priority queue, spilling heavily
on register-starved functions.
Add SlotIndexes::getRealInstrSpan(), counting only entries that still
have an instruction, and use it for the size getPriority ranks by.
Off by default behind -greedy-size-in-real-instrs.
[RISCV] Use template PredicateMethod for ImmAsmOperand when suffix is empty. NFC (#224098)
This allows us to remove forwarding wrappers from RISCVAsmParser.cpp.
Assisted-by: Claude
lldb: Require x86_64 for x86_64-specific NativePDB tests
These tests contained x86_64 datalayout and triples, but only
required system-windows. On an aarch64 windows host, %build will
be an incompatible datalayout, so require exactly x86_64 windows
hosts. Alternatively the test could be changed to not have the
datalayout, but I'm not sure if that's correct here.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[CIR] Accept a union whose members do not cover its declared size (#223594)
`union { unsigned Words[3]; void *Ptr; }` is 16 bytes because the
pointer's alignment rounds it up, and no member covers that size. The
pass refused to classify unions like that at all, so anything holding
one failed to compile. Tail padding doesn't change how an eightbyte
classifies, so this drops the precondition and classifies the union from
its own size.
[CI] Make updates to .ci actually test everything (#224125)
We ran into an issue where test failures in cross-project-tests were not
surfaced when bumping the image to Ubuntu 26.04 due to the script not
correctly calculating dependencies for changes to .ci and the premerge
workflow. This patch fixes that by ensuring the projects executed for
.ci/workflow changes are derived from everything else which means we do
not need to manually maintain the list and risk leaving it out of date.
[CAS] Read a CAS file's reserved size from st_blocks, not st_blksize (#224104)
FileSizeInfo reports how much disk a file already has, which
MappedFileRegionArena records so it knows how far ahead it has reserved.
However the file size was accidentally computed from st_blksize which is
the preferred I/O size, not the number of allocated blocks for the file.
The value is read when a database is created or reopened, so a reopened
database believed almost none of its disk was reserved and reserved it
again from near zero, a megabyte per allocation. Fix the problem by
using the correct size.
[WebAssembly] Use Single as the default Triple thread model (#223917)
Clang defaults WebAssembly to a single-threaded model unless atomics and
bulk-memory are enabled, whereas Triple::getDefaultThreadModel()
previously defaulted to POSIX for all targets. Because Clang only emits
the "thread-model" module flag when the active thread model differs from
the triple's default, single-threaded Wasm objects recorded
"thread-model"="single" while multithreaded objects omitted the flag.
When linking mixed objects in LTO, the merged module inherited "single",
causing passes like LICM and AtomicExpand to treat multithreaded
programs as single-threaded.
Change Triple::getDefaultThreadModel() to return ThreadModel::Single for
WebAssembly so that multithreaded objects explicitly record
"thread-model"= "posix" and single-threaded objects omit the flag.
Additionally, update WebAssemblyCoalesceFeaturesAndStripAtomics to set
the module thread model to POSIX when threading features are enabled and
no explicit module flag is present, ensuring backend passes like
AtomicExpandPass preserve atomics in raw IR modules compiled via llc.
Assisted-By: Gemini
[scudo] Do not trim the secondary cache if releasing is disabled. (#223881)
When the ReleaseInterval is set to less than zero, then releasing has
been disabled. In this case, honor this and do not trim the cache using
the MaxCacheResidentyBytes value.
Add a test to verify this behavior.