[HLSL] Add the `SV_Barycentric` semantic (#233510)
Implements diagnostics, lowering and serialization of the
`SV_Barycentric` semantic for directx and spirv.
Resolves: https://github.com/llvm/llvm-project/issues/210786
Assisted by: ChatGPT Sol 6.1
[mlir][scf] Add scf.execute_region to the structural type conversions (#234405)
This change adds support for `scf.execute_region` to
`populateSCFStructuralTypeConversions`. `scf.execute_region` seems to be
an omission, so this change simply fills a hole.
Add `ConvertExecuteRegionOpTypes` (patterned after `ConvertIfOpTypes`)
to convert the types of `scf.execute_region` and add that to the list of
patterns in `populateSCFStructuralTypeConversions` and legality in
`populateSCFStructuralTypeConversionTarget`.
Also adds a unit test to check for type conversion in
`scf.execute_region`.
Assisted-by: Claude
RuntimeLibcalls: Fix signatures of fmin/fmax libcalls
These used Floating, which always lowered to float regardless of the
libcall type.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add signatures for simple FP libcalls
Add signatures for the FP arithmetic, fma, powi, fminimum/fmaximum and
sincospi libcalls, and for the conversions between f32/f64/f80/f128/
ppcf128 and i32/i64.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[CIR] Add 'loop-id' to loop and branch types. (#235052)
While working through the loop-hints lowering, I discovered that we need
a way to make each loop get a 'distinct' loop-annotation in LLVM-IR.
This relationship is lost during FlattenCFG when it splits to multiple
branches. #233890 adds this to the LLVM-IR dialect.
I considered/had a patch to do this to FlattenCFG as well, however when
working on further loop hints (parallel in particular), we need to be
able to spread this value inside of the loop itself, so it makes more
sense to generate the ID from the start.
I suspect this ID will come in handy outside of the loop-hints, so it is
left as a separate attribute.
[AtomicExpand] Let targets keep the release fence out of the reservation (#214867)
`expandAtomicCmpXchg` sinks the leading fence into
`cmpxchg.fencedstore`, between the load-linked and the
store-conditional. A strong cmpxchg recovers, because its retry
re-reserves after the fence. A weak cmpxchg has no retry, so where a
fence clears the reservation it can never succeed.
On a 32-bit PowerPC e500v2, `compare_exchange_weak` with any release
ordering never succeeds. One thread, an uncontended cell, a million
consecutive failures:
```
[atomic: compare_exchange_weak] NO PROGRESS after 1000000 tries in 2.28s
[atomic: compare_exchange] ok
[atomic: fetch_or + fetch_add] ok
```
`fetch_update` in Rust's core is a `compare_exchange_weak` retry loop,
[54 lines not shown]
RuntimeLibcalls: Use a single LibcallImpl for long double functions
Replace the per-format <func>l_{f80|f128|ppcf128} implementations with
a single <func>l implementaton. The concrete type is now derived from
the module/triple's LongDoubleFormat, so this is no longer a static
property.
On targets where long double is double, the l-suffixed functions do
not provide a libcall. This could be fixed in principle, but nothing
would use it in the compiler.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Emit signatures per libcall implementation
Index the signature table by RTLIB::LibcallImpl instead of
RTLIB::Libcall. RuntimeLibcallImpl inherits the signature of the
libcall it provides by default, but an implementation can now override
it. This will help avoid having multiple copies of the same libfunc
for every long double type.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Use explicit types for F80, F128 and PPCF128 libcalls
LDbl only makes sense for encoding the long double libm functions. Other
functions have need of the specific type. Separately, LDbl brokenly assumes
double instead of checking the module's long double format. Some functions
are inappropriately using a specific type instead of LDbl. I'll fix both
of these issues separately.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add signatures for atomic libcalls (#233601)
Define type signatures in tablegen for the various atomic
library functions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
ARM: Stop adding kill flags on new virtual registers (#235113)
Continue purging uses of kill flags.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[MemProf] Fix remapping of matching calls when assigning function clones (#231242)
When a function has several calls with identical callsite metadata, they
are recorded on one context node with the extra calls in
Node->MatchingCalls. If that function is cloned by context
disambiguation, assignFunctions must remap each version's matching calls
through the function clone's CallMap, the same way it remaps the primary
Call.
Two problems in the IR path:
* AssignCallsiteCloneToFuncClone rewrote the matching calls of the
original node (Node->MatchingCalls) instead of those of the callsite
clone being assigned. The clone node (whose MatchingCalls were copied
from the original at creation) kept the original instructions, and the
original node's list was overwritten with the clone's. UpdateCalls then
updated each function version's matching calls with the other version's
callee clone, i.e. swapped.
[15 lines not shown]
AArch64: Stop adding kill flags on new virtual registers (#235112)
Continue purging uses of kill flags
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Options] Add IR-unit helpers for per-context library options (#234761)
Add free functions alongside the private option structures so callers
can use getScalarOptions(L) instead of spelling out the loop-header and
context access chain.
This should make option checks much more readable:
```
if (getCodeGenOptions(MF).CGOpt)
if (getScalarOptions(Fn).ScalarSetting)
```
Before we'd do:
```
if (MF.getFunction().getContext().getLibraryOptions().get<CodeGenOptions>().CGOpt)
```
The MachineFunction CGOpt lookup is prevalent in our downstream with
[3 lines not shown]
[ARM][GlobalISel] Add legalizer and regbankselect tests for G_CONSTANT_FOLD_BARRIER
Cover the s32 (legal), s16 (widened), and s64 (narrowed) legalizer
actions, and the GPR bank mapping.
Assisted-by: Claude Opus 5.5
[libclang] Only resolve dependent member names, not arbitrary callees
HeuristicResolver::resolveCalleeOfCallExpr() does more than resolve
dependent names: for a callee that is itself a call it returns the class the
inner call returns, for a dependent ADL call it returns the single visible
candidate, and it looks through parentheses. That made the cursor for
'm.make()()' refer to the class 'Functor', and changed the result for some
non-dependent calls.
Instead, look through a call to its callee as getDeclFromExpr() does, and
only use HeuristicResolver for CXXDependentScopeMemberExpr and
DependentScopeDeclRefExpr. Add tests for both cases and a release note.
Assisted-by: Claude Opus 5.5
MC: Remove MCAsmInfo::ExceptionsType (#233030)
The exception model now comes from the module, and the MCAsmInfo
predicates that depend on it take the model as a parameter. The
target's default model is still available from
Triple::getDefaultExceptionHandling.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Update waterfall-call-inreg-agpr.ll mismatched CC (#235075)
update test such that the call CC matches the CC of the target function
Identified while investigating
https://github.com/llvm/llvm-project/issues/234232
[SimplifyCFG] Propagate unknown weights in ConstantFoldTerminator (#234823)
Before we were just dropping the metadata node which causes a profcheck
failure. Propagate the unknown profile so the profcheck verifier knows
that we have dealt with this case.
Found while doing a bootstrapping build of LLVM with -mllvm
-enable-profcheck-in-pipeline.
[libclang] Resolve dependent member references in clang_getCursorReferenced
Inside a class template, references to members of a dependent base, such
as 'this->size()' where the base is 'A<T>', aren't bound to a declaration
until instantiation, so clang_getCursorReferenced() returned a null cursor
for them.
Fall back to HeuristicResolver, which clangd uses for the same purpose, to
look the name up in the primary template, and return the result if it's a
single declaration. This also resolves 'type_trait<T>::value' in a
requires-clause or concept to the primary template's static member.
'A<T>::size()' (a qualified reference to an instance member) still isn't
resolved, because HeuristicResolver only considers static members for a
DependentScopeDeclRefExpr.
Addresses part of #15370.
Assisted-by: Claude Opus 5.5
InlineSpiller: Stop adding kill flags on virtual registers
The spiller was marking uses of the new virtual registers created for
rematerialization and spilling as killed. VirtRegRewriter recomputes
kill flags from live intervals after allocation, so these were never
needed.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[RegAlloc] Restrict statepoint remat by default
Statepoint deopt and GC operands may live in stack slots, but when a
statepoint has more of them than there are registers, InlineSpiller
can rematerialize them into registers in front of it. Greedy then
runs out of registers and the basic allocator asserts.
restrict-statepoint-remat makes these operands spill and fold into
the statepoint instead. It was added off by default pending
validation, and the statepoint register allocation tests already
enable it, so turn it on by default.