[clang][LifetimeSafety] Split live origins into persistent and block-local (#213543)
LoanPropagation already keeps origins that cross block boundaries apart
from those confined to one block, so that only the former take part in
joins. Do the same for LiveOrigins, and share the single prepass that
classifies them.
Block-local origins are not merely a minor share of the liveness state:
many expression origins are made live by a `UseFact` but never killed,
because several `OriginFlow` sites propagate only the outermost origin
of an expression's list (see the FIXMEs in `handleFunctionCall`), and a
`StringLiteral` glvalue origin is only ever a flow's source. Those
origins survived to the top of their block and then propagated backward
across the whole function. In `EmitARMMVEBuiltinExpr`, of 68644 origins
only 490 are persistent, and the liveness map at a block boundary peaked
at 11725 entries; it now peaks at 326.
`computePersistentOrigins` moves to `FactManager`, which computes it on
first use and hands the same bit vector to both analyses. Sharing it is
[27 lines not shown]
[mlir][linalg] Constrain tiling semi-affine maps (#212240)
Expands checks in Linalg's tiling implementation in presence of
semi-affine indexing maps to reject unsafe tiling configurations.
Current tiling can produce incorrect results when tiling occurs on a
dimension accessed via semi-affine map. This is due to lack of tile
offset tracking as shift in tiled slices cannot be represented today
using symbol-free indexing maps.
Assisted-by: Claude
[mlir][tosa] Support more float types in resource transpose folding (#213226)
Add support for f4, f8, f16, bf16, and f64 constants backed by
DenseResourceElementsAttr.
[NFC][analyzer] Introduce the BoundsChecking library (#213957)
Building on my recent commit 25d51a8156da0845928e2fc09bb2736507fc5adf
this commit moves the general-purpose bounds checking logic from
ArrayBoundChecker.cpp to the new files BoundsChecking.{cpp,h}.
This new library currently only serves the needs of
`security.ArrayBound`, but it will be gradually expanded, generalized
and used to bring other bounds checking checkers out of alpha stage.
The code is moved without modifications, except for the removal of a
TODO note that asks for moving the code into a separate library.
[Clang][AIX] Preserve -mloadtime-comment-vars variables across serialization
Named internal-linkage variables were silently dropped when their
definition crossed a PCH or C++20 named-module (BMI-to-object) boundary:
DeclMustBeEmitted did not know the implicit attribute, so the PCH writer
never marked the unreferenced variable as required, and for named modules
only non-discardable variables are recorded in the module-initializer
lists that EmitModuleInitializers walks. Teach DeclMustBeEmitted about
the attribute (the CodeGen-side check becomes redundant and is removed)
and record validated internal-linkage module-purview variables in the
module-initializer list.
Since DeclMustBeEmitted now sees the attribute, a preserved variable no
longer triggers -Wunused-const-variable: it is materially used.
Add tests for C++20 module preservation, importer behavior, and
instantiation diagnostics; PCH preservation; unused-warning suppression;
the non-AIX cc1 no-op; and char8_t element-type exclusion. Document the
modules/PCH rules.
[AMDGPU] Add `isConvergent=1` to `DS_ATOMIC_*_BARRIER` instructions (#214166)
The intrinsic already has it. The instructions may issue a wake-up
signal on barrier completion so the set of waves that execute the
instruction
may not change.
The test case shows taildup duplicating the MachineInstrs when
`isConvergent=0`.
Assisted-By: Claude Opus 4.8
Claude found the reproducer for me after I found the lack of
`isConvergent=1` on those
instructions.
[lldb][test] Improve error for C++ compiler detection and improve docs (#214199)
I did not realise that LLDB_TEST_COMPILER should be the C compiler, so I
got:
cxx = cc_dir / (cc_prefix + cxx_type + cc_ext)
TypeError: can only concatenate str (not "NoneType") to str
Config=aarch64-/usr/bin/g++
I have simplified the logic and added a more informative error:
RuntimeError: Could not infer C++ compiler name from compiler type "g++"
Added a note to the documentation.
The CMake description does say "C compiler", but it's easy to gloss over
that so I extended that to say how we get the C++ compiler.
[libc] (Re)skip tests failing after #213860 (#214425)
(At least) two tests enabled by #213860 are failing on the amdgpu bot
(which only runs hermetic tests). This patch skips them, but it a
different way, so that they keep running in hermetic mode on supported
targets.
For the sched_test, I add a dependency on the sched_getscheduler target
(used in the test) to trigger the auto-skipping logic.
The memory utils test fails due to a missing cmp_is_expensive
specialization, so I enable the test only on targets which have them
(listing targets explicitly).
[compiler-rt][pgo] Add profile instrumentation test for coroutines (#213801)
This PR adds a compiler-rt test (`instrprof-coroutine-profile.cpp`) to
verify PGO profile counter generation and ingestion for C++20
coroutines.
During investigating the iFDO profile ingested for coroutine pass, we
found that the profile data contains entry counts for the original
coroutine function (`foo`), but lacks the entry counters for the split
`foo.resume` function.
After inspecting
[PassBuilderPipelines.cpp](https://github.com/llvm/llvm-project/blob/f7b7ec8d5542dcede1ae607aa74dfe36d7a3c530/llvm/lib/Passes/PassBuilderPipelines.cpp#L1273)
confirms that `PGOInstrumentationGen` runs before `CoroSplitPass`.
Therefore,
- 1) the iFDO profile correctly ingests and associates profile counters
with coroutine function `foo`.
- 2) Separate function entry counters for `foo.resume` are not expected
in the iFDO profile.
[16 lines not shown]
[AArch64][GlobalISel] Add legalisation to G_EXRACT_SUBVECTOR (#207956)
Prevent legalisation of this opcode falling back to SDAG.
In situations where a G_EXTRACT_SUBVECTOR is being performed on two
vectors which aren't double/half the size of each other, represent the
extract as build_vector(extract_vector_element, extract_vector_element,
...).
[libc] Implement sleep and usleep for Linux (#213912)
Implemented the sleep and usleep entrypoints for Linux. Refactored the
syscall implementation out of the public nanosleep entrypoint into a
standard internal syscall wrapper.
Fixes #214293.
Co-authored-by: Jeff Bailey <jbailey at raspberryginger.com>
[Clang][AIX] Preserve -mloadtime-comment-vars variables across serialization
Named internal-linkage variables were silently dropped when their
definition crossed a PCH or C++20 named-module (BMI-to-object) boundary:
DeclMustBeEmitted did not know the implicit attribute, so the PCH writer
never marked the unreferenced variable as required, and for named modules
only non-discardable variables are recorded in the module-initializer
lists that EmitModuleInitializers walks. Teach DeclMustBeEmitted about
the attribute (the CodeGen-side check becomes redundant and is removed)
and record validated internal-linkage module-purview variables in the
module-initializer list.
Since DeclMustBeEmitted now sees the attribute, a preserved variable no
longer triggers -Wunused-const-variable: it is materially used.
Add tests for C++20 module preservation, importer behavior, and
instantiation diagnostics; PCH preservation; unused-warning suppression;
the non-AIX cc1 no-op; and char8_t element-type exclusion. Document the
modules/PCH rules.
[libc] Enable UNIT_TEST_ONLY tests in hermetic mode (#213860)
This mainly consists of removing the UNIT_TEST_ONLY lines as previous
patches made sure the tests work. The only slightly nontrivial part is
adding support for C_TEST to the hermetic test macro.
After this, the only UNIT_TEST_ONLY tests are those that require the
MPFR library.
[TailRecElim] Introduce support for shift accumulator optimization (#181331)
This PR enables Tail Recursion Elimination (TRE) for functions where the
accumulator operation is a shift (`shl`, `lshr`, `ashr`) by a constant
amount -- i.e., pseudo-associative relation.
As pointed out in #178805, `InstCombine` often strength-reduces
multiplications (or `f(x-1) + f(x-1)`) into `shl`.
Currently, TRE strictly requires operations to be associative and
commutative:
https://github.com/llvm/llvm-project/blob/05e908609227e1e8d993659e604a63668dfd2825/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp#L377-L379
This prevents TRE from transforming recursive shifts into loops,
creating a phase-ordering problem where canonicalization blocks a
structural optimization.
This PR does **not** perform shift accumulator optimization when there
are multiple base cases: it is reserved for future work.
Fixes #178805.
[AMDGPU] Insert exec-forced V_NOP after V_PERM_PK16 (gfx1250 hazard)
On gfx1250 the V_PERM_PK16 family (V_PERM_PK16_B4/B6/B8_U4) has a hazard:
the instruction must be immediately followed by a "safe" instruction that
issues on the pipe which clears the hazard. Insert V_NOP with forced
non-zero EXEC as needed.
Assisted-by: Opus 4.8 Medium
[AMDGPU] Insert exec-forced V_NOP after V_PERM_PK16 (gfx1250 hazard)
On gfx1250 the V_PERM_PK16 family (V_PERM_PK16_B4/B6/B8_U4) has a hazard:
the instruction must be immediately followed by a "safe" instruction that
issues on the pipe which clears the hazard. Insert V_NOP with forced
non-zero EXEC as needed.
Assisted-by: Opus 4.8 Medium