[ARM] Disable hardware loops without thumbv8.1-m.main instructions. (#243831)
Using +lob with thumbv8-m is not a valid combination, but the hardware
loop pass would attempt to insert instructions that were not selectable.
Make sure we don't try to generate hardware loops without thumbv8.1m
instructions.
Fixes #243545
[lldb][test] Remove leftover benchmark test infrastructure (#243494)
The old benchmark infrastructure were removed in 7e5fe3ec5aed (#108629).
but some supporting pieces were left behind:
* lldbbench.py which has has no users.
* The dotest '-y' option, whose handling was already removed in
923fdbadae3c but whose argparse definition remained.
[Hexagon] Use unsigned compare for unsigned hwloop distance guard (#236824)
The hardware-loop pass guards the trip count of an unsigned less-than or
less-or-equal loop with a signed comparison of the distance register. A
distance of 0xffffffff, such as a bound of UINT32_MAX, is seen as -1, so
the count is clamped to 1 and the loop exits after its first iteration.
Use C2_cmpgtui for unsigned CmpLess so the distance is compared as an
unsigned value. Signed loops and CmpGreater keep C2_cmpgti.
Signed-off-by: Kushal Pal <kushpal at qti.qualcomm.com>
[CIR] Add bytecode encodings for types other than records (#243865)
Without a bytecode encoding, MLIR stores a dialect type as its printed
text, nested types included. Every CIR value and many attributes
reference a type, so after the attribute encodings (#229586) types are
most of what is left as text in a CIR bytecode file.
This adds native encodings for every CIR type except !cir.struct and
!cir.union:
- Integer (width, signedness, _BitInt), the floating-point types and
long double, bool, void, vptr.
- Pointer (with its address space), array, complex, function (the return
type is absent for void, so it carries a presence flag), vector (fixed
or scalable), matrix.
- Data member and method pointers, bit-field access units (plus
#cir.bitfield_decl, so they store no text), the CUDA surface/texture
types and the EH token types.
[13 lines not shown]
ARM: Use LastSubtargetCache in getSubtargetImpl (#242561)
Reuse the last subtarget for functions with the same function attribute
set and module, or the same subtarget relevant attributes, float ABI
and ABI, instead of building the subtarget key. This works towards
all targets using a common pattern.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc++] Submit the LNT results of main commits as the main branch (#243970)
LNT now supports a concept of branches. This patch changes the CI jobs
to submit data as being under the `main` branch.
Assisted by Claude
[NFC][clang] Adjust PPMemoryAllocationsTest ASan threshold (#244162)
The #243000 reduced the BumpPtrAllocator's GrowthDelay from 128 to
8, so the geometrically growing slabs leave the currently open slab
mostly empty. The test measures getTotalMemory(), which counts slab
capacity, and the 1M-#define workload now reports 150.96 bytes per
define under ASan instead of about 136.8, failing the 145.0 bound.
The bytes actually requested are unchanged; only the unused tail of
the last slab is larger.
Raise the ASan bound from 145.0 to 160.0 to cover the slab slack, as
done for the redzone overhead in #209024. The non-ASan bound of 130.0
is unchanged.
Attributor: Use types instead of IDs in AAKindSet (#244076)
Some MSVC builds reject the addresses of IDs of abstract attributes in
anonymous namespaces as template arguments. Pass the abstract attribute
types instead and compare the types to find the mask bits, which also
works with older GCC.
Fixes 19901848353e
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AArch64] Share materialized constant between add x,k and sub x,k (#225430)
## Summary
Fixes Issue
#[222095](https://github.com/llvm/llvm-project/issues/222095).
When a function needs the same constant magnitude `k` both added and
subtracted (e.g. `use(a + k, b - k)`), and `k` doesn't fit as a direct
arithmetic immediate on this target, LLVM previously materialized two
unrelated constants -- `k` and `-k` -- into two separate registers, even
though only one ever needed to be built.
Example (from the linked issue, `k = 4097`):
```c
u32 use(u32 a, u32 b);
auto src(u32 a, u32 b) {
u32 k = (1 << 12) + 1;
[16 lines not shown]
[Driver][AMDGPU] Enable sanitizers AMDGCN flavoured SPIR-V (#241411)
Sanitizer support was not advertised for AMDGCN flavoured SPIR-V, which
is incorrect. The gating was based on XNACK being enabled (which, with
SPIR-V can only be ascertained at finalisation time) and on the triple
being an AMDGPU one. This patch corrects both of those aspects.
[mlir] Handle lexical/dominance inversion in OperationEquivalence
Operation equivalence used to traverse blocks in their lexical order, i.e., the
order in which they are stored in the region. This order is not guaranteed to
match the dominance order. Operation equivalence therefore would not have
marked dominating values from a lexically following block as equivalent in the
cache, and would incorrectly consider them as not equivalent.
Traverse all blocks first to record equivalence between arguments and op
results first, then look at operands separately.
[IndVarSimplify] Use context to prove a narrow IV def non-negative (#236461)
When IndVars widens an IV, it checks for each narrow def (the IV and its
users) whether it is non-negative on every iteration. If so, zext and
sext of it are equal, so when widening the def’s users they can use
either.
Previously, non-negativity of the def was proved without context, so in
some cases we were unable to prove it and left trunc + zext pairs in the
code.
Now we ask SCEV at the def’s context, which lets it use dominating
guards and assumes.
This allows it to not insert unnecessary truncs/zexts. E.g. in
```
if (m > 0)
for (i32 i = 0; i < m; i++)
use(zext(i + m <nsw>));
```
[8 lines not shown]
[IndVarSimplify][LoopVectorize][NFC] Add tests for widening a non-negative IV (#236443)
IndVars widens users of a non-negative IV with both sext and zext, but
doesn’t use guards on the IV start to prove it non-negative. It leads to
spare trunc + zext inserted for widened users.
Add tests for widening of the IV and its users with guards showing that
the IV start is non-negative.
Also add vectorizer tests showing that widening i - 32 affects runtime
checks, and tests showing that the widened IV worsens SCEV’s constant
max backedge-taken count after the exit rewrite to an smax bound.
[X86] Fix ADC/SBB throughput in the znver3 and znver4 scheduling models (#243093)
WriteADC holds an ALU for 4 cycles (ReleaseAtCycles = [4]), so the model
allows only one ADC/SBB per cycle. ADC8mr/SBB8mr have an override that
holds an ALU for 7 cycles, with latency 1. On Zen 3 and Zen 4, ADC and
SBB use one ALU for one cycle, the same as ADD. This is also true for
the 8-bit RMW form.
This patch sets WriteADC to [1] in the znver3 and znver4 models and
removes the ADC8mr/SBB8mr override. The znver4 model is also the model
for znver5 and znver6. On Zen 5, uops.info also gives ADC about the same
cost as ADD.
Zen 3, measured with llvm-exegesis on a Ryzen 9 5950X (-mode=latency
--repetition-mode=loop --loop-body-size=64, min of 20 runs). Model:
llvm-mca Total Cycles / 1000 iterations; znver3 and znver4 give the same
values. Cycles per snippet; snippets at https://godbolt.org/z/arxd3dGxd.
exegesis model before model after
[36 lines not shown]
[AMDGPU] Fix FLAT offsets for constant memory on gfx101x (#242413)
gfx101x ignores FLAT instruction offsets for global memory. Extend the
existing workaround to all global-memory address spaces, including AS4
and AS6, in SelectionDAG matching and the shared offset legality check.
Assisted by: GPT 6.1-Sol
[JITLink][COFF] Give external absolute symbols default scope (#239718)
Depends on #239712
Please review only the last commit of this set.
COFFLinkGraphBuilder makes every absolute symbol local, but ORC's
object interface lists an external one as a definition. So an object
with `.globl x` / `x = 5` fails to link with "Missing definitions".
Use the storage class, as lld-link does: external absolute symbols get
default scope. Static ones, such as @feat.00, stay local.
Assisted-by: Claude Code
---------
Co-authored-by: Lang Hames <lhames at gmail.com>
[Offload][Omp] Fix libomptarget OMPT disconnect segfault (#243190)
Libomp is calling libomptarget `finalizeLibrary` as part of its `atexit`
tear-down process. But because the order of library dependencies,
libomptarget deinitializes first so when `finalizeLibrary` is called,
calling even a simple `ODBG` (with debug enabled) results in a segfault
because the stream has already been destructed.
In this PR, we ensure that OMPT is disconnected (in libomptarget) at
deinit at the latest and avoid doing that again if recalled from libomp.
Also, the LibraryFinalizer was never used (and in any case it should be
called before olShutDown) so simplify the disconnect to the minimum.
[RelLookupTableConverter] Support table with poison elements (#244155)
Support lookup tables with poison holes. We can convert this to a
relative lookup table with poison elements.
[Offload] Avoid shadowing of test variables in the unittest ASSERT macros (#243921)
ASSERT_SUCCESS, ASSERT_SUCCESS_OR_UNSUPPORTED, ASSERT_ERROR and
ASSERT_ANY_ERROR store the checked result in a local variable named Res.
This is a ticking bomb: Res is also the name the test code itself uses
for results, e.g. 'ol_result_t Res = olInit(nullptr)' in olInit.cpp and
Environment.cpp, and several helpers in Fixtures.hpp and Properties.hpp.
Passing such a variable to one of the macros, e.g. ASSERT_SUCCESS(Res),
expands to 'ol_result_t Res = Res'. The macro's local shadows the test's
variable, is initialized from itself and is then dereferenced, so the
test crashes instead of checking the result. It only works today because
nobody happened to pass a variable named Res to these macros yet.
Rename the macro local to Res_ so it unlikly to collide.
Assisted-by: Claude
[CGP] Vector LSR postcommit comments addressed (#240839)
Fixing up postcommit problems found in #226197
* Use CreatePtrAdd instead of CreateGEP
* Use TypeAllocSize of SourceElementType
* Add test for i24 indexing
[flang][OpenMP] Exclude user-defined reductions from assumed bounded recipe effects (#240814)
Currently, user-defined reduction recipes may have their memory effects
assumed to be bounded, for example through the presence of
a`task_reduction_assume_bounded_recipe_effects` attribute. However
user-defined reduction recipes may access storage beyond their operands,
violating the operation contracts of the
`*_reduction_assume_bounded_recipe_effects` attributes.
Add a new flag `hasUserDefinedReduction` tracking whether a construct
with a reduction has any user-defined reduction recipes.
I'm not aware of any other way of doing this, for example in the
existing `canAssumeBoundedRecipeEffects` helper functions a variable
symbol may be involved in multiple reductions.
AI-Assisted-by: Codex
[JITLink] Skip allocation for graphs with only empty sections (#239712)
An object whose only definitions are absolute symbols still has an
empty __text section on MachO. JITLinkerBase sent its graph to the
memory manager, and FinalizedAlloc asserted on the empty allocation.
Skip sections with no blocks, as BasicLayout does.
Assisted-by: Claude Code
Co-authored-by: Lang Hames <lhames at gmail.com>
[AMDGPU] Preserve noclobber after acquire operations from a different addrspace (#231855)
Follow-up to #219991 to address reviewer comments:
AMDGPUAnnotateUniformValues should annotate uniform global loads as
`!amdgpu.noclobber` if the memory they are reading is never clobbered (since
kernel launch) before the load is executed.
PR #219991 strengthened the logic to consider acquire operations before the
load as clobbering (because they cause stores from other threads to be observed
by the load without a data race).
This PR weakens this criterion to ignore acquire operations that don't affect
the global address space (because they don't affect what the load in question
may or may not see). This addresses the performance-relevant case of s_barriers
with LDS-only fences.
The logic is still overly pessimistic for one-as load acquires, they could also
be ignored when looking for clobbering operations.
Disclaimer: Claude gave review comments and suggestions that I addressed during
[4 lines not shown]