[PAC][libc++] Fix build with `ptrauth_calls` feature (#211033)
After partial revert of #208330 in #209928, the libcxx build started
failing because of missing `<cstdint>` include required for `uintptr_t`
declaration used only by code behind `ptrauth_calls` feature check. See
https://lab.llvm.org/buildbot/#/builders/227/builds/3358
This patch adds the missing include.
(cherry picked from commit 12e1c7f70f34d59c023d05d0fe2c228a4e9aac11)
[clang-format][clang-tools-extra] Fix leaking of host-level config into test environment (#206358)
These leaks were causing false test failures due to my global
.clang-format being in an ancestor directory of the build directory.
These changes prevent those issues when running the tests on my system.
I used MiMo v2.5 Pro agentically in Zed to find and fix the issue. But I
understand the changes and judge them to be safe and a clear improvement
over the status quo.
[lldb] Fix Unicode code point formatting to use proper notation (#211131)
- use uppercase hex digits
- only emit "U+" notation for valid code points (<= U+10FFFF),
zero-padded to a minimum of four digits.
rdar://173817553
Assisted-by: claude
(cherry picked from commit 0cd942fa1b6de94fd6d7fa7ba73f0233293115f8)
[RISCV][P-ext] Add packed sign and zero extend intrinsics (#208685)
Add SelectionDAG and intrinsic support for the RISC-V P packed sign- and
zero-extend operations.
Sign-extend is matched through `sext_inreg` (folded from the `shl`/`ashr`
idiom by the generic combiner) and selects to `psext.*`. Zero-extend reuses
the existing `PPAIRE` node with a zero operand instead of a new target node,
since `pzext.* rd, rs` is an alias of `ppaire.* rd, rs, x0`: implementing
`isVectorClearMaskLegal` lets the generic `DAGCombiner::XformToShuffleWithZero`
rewrite the `(and vXi16, 0xff)` / `(and vXi32, 0xffff)` idiom into a shuffle
with a zero operand, which `lowerVECTOR_SHUFFLEAsPPair` folds to `PPAIRE`.
Also adds the LLVM IR intrinsics `llvm.riscv.psext.b`/`.h` and
`llvm.riscv.pzext.b`/`.h`. For RV64 32-bit packed results, the lowering widens
to the legal 64-bit type and extracts the low subvector.
[DTLTO] Forward loop interchange to DTLTO remote compilations (#208591)
Recent upstream LLVM changes enabled `LoopInterchangePass` by default
through `PipelineTuningOptions`. TLTO observes that state directly from
the LTO config, but DTLTO was not forwarding the equivalent Clang option
to the remote compiler. As a result, TLTO could run loop interchange
pass while DTLTO did not, producing codegen differences for
configurations that exposed profitable/legally interchangeable loops.
Note that this was a pre-existing issue, the change in default has
simply exposed it.
Forward `C.PTO.LoopInterchange` as `-floop-interchange` when
constructing the common DTLTO remote compiler options. Extend the
testing to check that the SN-DBS remote command line includes the
forwarded option.
The code for forwarding such options is only intended as a temporary
measure. A more comprehensive solution is in discussion here:
https://discourse.llvm.org/t/synchronizing-lto-code-generation-configuration-between-clang-and-lld-dtlto
[2 lines not shown]
[DTLTO] Add remote compiler option forwarding coverage (#208589)
Add a cross-project DTLTO test that checks the existing LTO
configuration state serialized into the remote Clang command line. The
test uses the validate.py distributor to inspect the generated DTLTO
JSON.
Cover all the existing forwarded options.
Add paired negative checks for optional flags so the test also verifies
they are not emitted when the corresponding configuration state is not
set.
(cherry picked from commit c012610ab9924f465baea5e62397056ea9594567)
[GVN] Support critical-edge splitting in loop-load PRE
When the only in-loop blocker of a loop-load PRE candidate has multiple successors, the reload was placed at the end of that block, so it also ran on the loop-exit edge. Split the critical edge to the unique in-loop successor and insert the reload there, so it runs only on the path back to the header. Bail out on indirectbr or multiple in-loop successors, and keep backedge splitting gated behind the existing flag. Also refresh the stale TODO comments on the freeable-pointer tests, which stay un-PRE'd because the pointer may be freed.
[GVN] Add tests for loop-load PRE into a multi-successor block
Precommit tests for loop-load PRE when the loaded pointer cannot be freed (a gc-managed address-space pointer and a nofree function). PRE currently fires but sinks the reload into a cold block with multiple successors, so it also runs on the loop-exit edge.
[Reassociate] Use UniformityInfo to group uniform operands together (#198507)
On targets with branch divergence (TTI.hasBranchDivergence()), boost the
rank of divergent operands in ReassociateExpression() so they sort
towards the root of the expression tree. This clusters uniform operands
at the leaves, letting the backend lower the inner sub-expression to a
scalar ALU instruction (s_mul/s_or/s_and) instead of a vector.
Ref:
https://github.com/llvm/llvm-project/pull/175167#issuecomment-4476483692
[LoopIdiom] Use narrower bit widths where possible in `optimizeCRCLoopUsingClmul` (#210139)
The original implementation of `optimizeCRCLoopUsingClmul` (#203405)
uses a single conservative bit width for most operations, but this width
is not always necessary. Use more restrictive bit widths for each clmul
according to their inputs, and narrow the bit width for the initial
CRC/data setup.
[X86] Fix swapped VPTERNLOG231_imm8/VPTERNLOG312_imm8 SDNodeXForm bodies (#209782)
Fixes #157929
VPTERNLOG231_imm8 and VPTERNLOG312_imm8 had their bodies swapped,
causing ISel to emit the wrong truth-table immediate whenever operand
reordering was needed (-O1+, not -O0).
Test changes:
- **avx512-vpternlog-commute.ll: regenerated with
update_llc_test_checks.py**
(accounts for the large diff)
- Added 4 new cases: vpternlog231_rmik, vpternlog312_rmik,
vpternlog231_rmbik, vpternlog312_rmbik
Tested: llvm-lit on llvm/test/CodeGen/X86 (no regressions), original
repro verified correct at -O0 through -O3, -Os, -Oz.
(cherry picked from commit bd38dd0ace19c3b9512da2b37bb9690ee6c9e97f)
[DWARFLinker] Fix RefTypeName crash and type-table non-determinism (#209033)
The parallel linker computes DIE placement (artificial type unit vs
plain DWARF) concurrently across compile units.
1. updateDependenciesCompleteness checked the placement of the enclosing
root type (getRootForSpecifiedEntry) instead of the actual referenced
DIE. A nested type can be demoted to plain DWARF while its root stays in
the type table, leaving a type-unit DIE that references a plain DIE and
tripping the RefTypeName assertion in
DIEAttributeCloner::cloneDieRefAttr. Carry the actual referenced DIE on
the worklist item and check its placement.
2. The completeness dependency set was recorded as a side effect of the
concurrent marking traversal, which short-circuits on already-marked
DIEs (isAlreadyMarked) before maybeAddReferencedRoots. When a shared
cross-CU DIE was already marked by a racing CU, the current referencing
root's outgoing dependencies were dropped, so the demotion fixpoint
missed demotions and whole type subtrees were left in the artificial
[9 lines not shown]
[VPlan] Compute blend masks from minimum set of edge masks (#201783)
#201784 aims to preserve SSA in early exit loops, and in doing so insert
phi nodes. More phi nodes results in more VPBlendRecipes, so this PR
optimizes the edge masks generated for those blend recipes to prevent
regressions.
The idea is to compute a minimal set of edges that lead to each unique
incoming value in a phi. It does this by iterating up the edges in the
post dominance frontier till the outgoing edges no longer lead to the
same value.
This is a simpler, less general version of #184838 since this can't
optimize away edges that aren't postdominated by the phi. This is fine
the early exit use case though, since we only need to optimize phi nodes
inserted in the latch.
The big advantage over #184838 is that it doesn't require several
depth-first searches to compute the set of reachable nodes, and can be
done entirely by iterating the post-dominator frontier.
[libc][cmake] Add LIBC_TEST_SUBPROCESS_TESTS (#211238)
This replaces the ENABLE_SUBPROCESS_TESTS preprocessor flag with a cmake
variable. By lifting the logic into cmake, we select which test
framework files to build, and also exclude whole tests, if they do not
make sense without subprocess support.
This enables us to fix failures from (now reverted) #209999 and
#210889, as it will let us skip the *exit family of tests. The problem
there was that GPU targets support the *exit entry points (so the
auto-skipping logic does not kick in), but they do not have (and maybe
cannot have?) the functionality necessary to test them.
I convert two libgen tests (the only users of ENABLE_SUBPROCESS_TESTS)
to the new framework.
[compiler-rt][sanitizer_common] Size readlink/getsockopt post-hook unpoison by bytes written (#209209)
# About
`readlink`/`readlinkat` return the number of bytes placed in the buffer
in res and do not NUL-terminate it, and getsockopt writes *optlen bytes
of binary option data. The post-hooks instead sized their POST_WRITE
(MSan unpoison) with internal_strlen(buf) + 1, which reads past what the
kernel wrote -- over- unpoisoning the uninitialized tail (masking real
bugs) and, on a buffer with no NUL, reading out of bounds inside the
runtime. For binary option data an early zero byte instead
under-unpoisons.
Size the unpoison by the actual written length, matching the
corresponding libc interceptors (readlink unpoisons res bytes, and
getsockopt unpoisons *optlen bytes).
Seems to be present since the file's 2013 import.