[libc] Use execve syscall wrapper in execve.cpp (#223186)
Use the existing execve syscall wrapper in `execve.cpp` instead of
invoking SYS_execve directly.
[libc] Use execve syscall wrapper in execv.cpp (#223181)
Use the existing execve syscall wrapper in `execv.cpp` instead of
invoking SYS_execve directly.
[AMDGPU][True16][GlobalISel] Update True16 handling for FMA_MIX instructions in GlobalISel (#205431)
The FMA_MIX instructions can extend 16-bit input values, but must have
32-bit registers as operands. This patch handles cases in True16 mode
where the 16-bit input value lives in a VGPR-16 and must be widened.
[compiler-rt] Fix host-only AMDGPU tests being added to GPU build (#223505)
Summray:
We do have AMDPGU tests, but these are for the standalone / minimal
configurations that don't require any host runtime. The tests added in
the previous patch are for offloading, i.e. HIP or OpenMP, not C/C++
compiled fro the GPU.
[Offload] Link against specific HSA library and then fallback (#223454)
Summary:
HSA uses a versioning system, the `.1` is usually a more specific
release while one without is a generic or untested version. We should
use the specific one and fall back.
Reapply "clang: Use TargetID parsing from AMDGPUTargetParser" (#213824)
This reverts commit 8f82ba2c79f4e6a69a884cc9e19bd0b8c0bbe932.
Try again now that clang has full support for new subarch triples.
[libc] Change cookie_seek_function_t to take off_t argument (#223306)
cookie_seek_function_t is defined as taking off_t rather than off64_t
for offset argument in all C library implementations that support
fopencookie.
InferAddressSpaces: Replace -assume-default-is-flat-addrspace cl::opt with pass parameter
Migrate the pass-specific command-line option to a new pass manager
pass parameter, exposed as
infer-address-spaces<assume-default-is-flat-addrspace>.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[ConstantTime] Allow dead llvm.ct.select to be removed
An unused llvm.ct.select outlived the InstructionSimplify fold, which kept
both value arguments live and contradicted the LangRef text saying the unused
argument becomes dead code. Add the intrinsic to the wouldInstructionBeTriviallyDead
whitelist next to llvm.allow.runtime.check and llvm.allow.ubsan.check, which
carry IntrInaccessibleMemOnly for the same reason: to pin the call in place,
not to model a real memory access.
Keep IntrInaccessibleMemOnly rather than switching to IntrNoMem. As a pure
value the call is sunk into a conditionally-executed block by InstCombine
(gated on mayWriteToMemory) and split into one copy per branch arm by GVN PRE.
Also correct the undef condition semantics, trim the declaration list, and
drop claims from the definition comment that the memory effect does not
actually provide.
Co-Authored-By: Claude Opus 5 <noreply at anthropic.com>
[ConstantTime] Use ARITH_FENCE as the combine barrier in CT_SELECT expansion
Replace the CopyToReg/CopyFromReg vreg barrier in ExpandCTSELECT with
ISD::ARITH_FENCE. The legalizer no longer creates vregs or picks register
classes via getRegClassFor, and scalable vectors are now covered too.
Codegen tests regenerated; output stays branchless.
[ConstantTime] Move the CT_SELECT expansion into a helper
The CT_SELECT case in ExpandNode was around 180 lines. Move it to
SelectionDAGLegalize::ExpandCTSELECT and name the operands, so the case is
three lines. Pure code motion: emitted assembly is unchanged for every RUN
line of the existing ct.select codegen tests.
Also use a temporary for the promoted SELECT so the call fits on one line
instead of wrapping after the assignment.
Co-Authored-By: Claude Opus 5 <noreply at anthropic.com>
[ConstantTime] Address reviewer feedback on llvm.ct.select core
- Fix vector-split build error: call the existing SplitRes_Select for
CT_SELECT instead of the nonexistent SplitRes_CT_SELECT.
- Fix a VP_MERGE result-split regression: the CT_SELECT switch reformat had
moved ISD::VP_MERGE onto the SplitRes_SELECT_CC line, which reads operand 4
(out of bounds for VP_MERGE's 4 operands) and builds a SELECT_CC without
splitting the EVL, crashing or miscompiling any vp.merge whose result
vector must be split. Restore it to the SplitRes_Select group.
- Accept byte types (bN and vectors of them) in the Verifier and document
them in LangRef; add byte-typed X86 codegen and Verifier test coverage.
- Drop the redundant `VT0 == MVT::i1` guard in visitCT_SELECT; the inner
condition-type checks already cover correctness after promotion.
- LangRef: reword the constant-fold rule to the enforceable "constant
operand" form, restate fast-math flags via the general FP-call rule (only
nnan/ninf are poison-generating), and switch undef/poison to match select,
dropping the noundef return attribute so poison propagates (both arms always
evaluate, so poison in either yields poison).
- Revert an unrelated whitespace change in LegalizeTypes.h.
[2 lines not shown]
[ConstantTime] Address reviewer feedback for llvm.ct.select core
Model llvm.ct.select as IntrInaccessibleMemOnly so the call stays pinned
without pessimizing alias analysis. Make CT_SELECT flagless (drop the
getCTSelect flags parameter, dead flag propagation, and
setFlags-after-getNode) and assert its condition is scalar. Blend the FP
memory fallback at the widest legal integer width with ext-load and
trunc-store tails instead of illegal i8 chunks. Restore the LangRef
section dropped in the rebase onto the Markdown docs migration and note
RISC-V Zkt/Zvkt. Apply review style fixes and regenerate affected tests.
[ConstantTime] Fix CT_SELECT expansion to preserve constant-time guarantees
Create CT_SELECT nodes for scalar types regardless of target support, so
they survive DAGCombiner (visitCT_SELECT is conservative). Expand to
AND/OR/XOR during operation legalization after SETCC is lowered, preventing
the sext(setcc)->select fold chain that converts constant-time patterns
into data-dependent conditional moves (e.g. movn/movz on MIPS).
The mask uses SUB(0, AND(Cond, 1)) instead of SIGN_EXTEND because type
legalization already promoted i1 to the SetCC result type, making
SIGN_EXTEND a no-op for same-width types.
[ConstantTime][LLVM] Add llvm.ct.select intrinsic with generic SelectionDAG lowering
[LLVM][CodeGen] Improve CTSELECT fallback lowering and target support modeling (#179395)
This pull request refactors and improves the **fallback handling** of
constant-time select (CTSELECT) in LLVM’s code generation
infrastructure. The changes clarify semantics, simplify
target-capability checks, and improve the correctness and
maintainability of fallback lowering, without changing the intended
constant-time guarantees.
- **CTSELECT semantics**
- Clarified documentation for the `CTSELECT` node to explicitly describe
its operands and its role as the lowering target for the constant-time
select intrinsic.
- **TargetLowering cleanup**
- Removed CTSELECT-specific entries from `SelectSupportKind`.
- Introduced a dedicated `isCtSelectSupported(EVT)` hook to cleanly
[23 lines not shown]
[libc] Don't declare vector_size types that cannot be compiled (#221119)
On machines where [[gnu::vector_size(N)]] types are generally
supported, each given N can only be used when the corresponding
CPU features are enabled by the particular -m switches et al.
Don't make any use of a type that's not enabled for native
register use according to the predefines reflecting -m switches.
Even inline and template functions that wind up being unused can
make the compiler give errors about the use of a type whose use
is disabled for ABI or ISA configuration reasons.
[HIP] Use new spelling in buildbot script (#223491)
This adds the new spelling to enable HIP Kokkos tests in the buildbot
script.
The old spelling will be removed.
[bazel][libc][test] 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.