[AArch64][llvm] Fix incorrect diagnostic (index/immediate in simm9)
Improve the error message in the simm9 diagnostics and use the word
'immediate' instead of 'index'. This was noticed when creating the
CFLT instructions for Armv9.8-A, but would have caused a lot of
unrelated churn if merged as part of that change.
Co-authored-by: Martin Wehking <martin.wehking at arm.com>
[CIR][CodeGen][NFC] Retire the CodeGenUtils.h catch-all header
Moves the last helpers out of `CodeGenUtils.h` into `ClassUtils.h`,
`ModuleUtils.h`, `TargetUtils.h` and `FunctionUtils.h` (`checkTargetFeatures`,
since it came from CodeGenFunction.cpp) and deletes the header. Only moves code
already on main, so it can be dropped on its own.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen][NFC] Share hasOwnStorage
Deduplicates `hasOwnStorage` between CIR and classic CodeGen into
`RecordLayoutUtils.h`.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen][NFC] Share hasOwnStorage
Deduplicates `hasOwnStorage` between CIR and classic CodeGen into
`RecordLayoutUtils.h`.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen][NFC] Share the Arm SME inlinability check
Deduplicates `ArmSMEInlinability` and `getArmSMEInlinability` between CIR and
classic CodeGen into a new `TargetUtils.h`.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen] Share isStandardLibraryRTTIDescriptor
Deduplicates `isStandardLibraryRTTIDescriptor` between CIR and classic CodeGen
into `ItaniumCXXABIUtils.h`, taking the classic implementation. The two copies
have been equivalent since #227781 filled in the builtin types CIR was missing.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen][NFC] Share canUseSingleInheritance
Deduplicates `canUseSingleInheritance` between CIR and classic CodeGen into
`ItaniumCXXABIUtils.h`.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen][NFC] Share hasExtraNeonArgument
Deduplicates `hasExtraNeonArgument` between CIR and classic CodeGen into
`TargetUtils.h`.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen][NFC] Share the Itanium __vmi_class_type_info flags computation
Deduplicates the `__vmi_class_type_info` and `__base_class_type_info` flags and
`computeVMIClassTypeInfoFlags` between CIR and classic CodeGen into
`ItaniumCXXABIUtils.h`.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen][NFC] Share requiresAMDGPUProtectedVisibility
Deduplicates `requiresAMDGPUProtectedVisibility` between CIR and classic CodeGen
into `TargetUtils.h`. The shared version takes a bool for "currently hidden" in
place of the `llvm::GlobalValue` and `cir::VisibilityKind` the two callers
passed.
Assisted-by: Claude Code (Claude Fable 5.1).
[CIR][CodeGen] Share the EH personality selection logic
Deduplicates the EH personality selection (`getEHPersonality`,
`getCXXEHPersonality`) between CIR and classic CodeGen, taking the classic
implementation. CIR's copy lacked the z/OS, Wasm and GNUstep-on-CygMing cases;
none are reachable in CIR today, so no test changes.
Assisted-by: Claude Code (Claude Fable 5.1).
[AMDGPU][SROA] Expand cast chain handling to floating point types (#228113)
CreateBitPreservingCastChain does not produce inttoptr or ptrtoint for
floating-point types. When promoting structs like { float, float } to <2
x float>, this can lead to pointers being bitcast directory to <2 x
float> which is invalid. This change expands the use of the intermediate
to these cases
RuntimeLibcalls: Add provider libraries for targets to reference
Add shared LibcallLibrary defs for targets to reference instead of listing
impls directly: compiler-rt, libm and libc. Define various OS specific library
variants.
ARM, Lanai and SPIRV are migrated to the new organization here. The remaining
targets' SystemRuntimeLibrary bodies are stubbed to (add) and filled in by
pending per-target changes.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[CIR][CodeGen][NFC] Share the bit-field and vbase layout ABI predicates (#227258)
Deduplicates `isDiscreteBitFieldABI` and `isOverlappingVBaseABI` between CIR and
classic CodeGen into `RecordLayoutUtils.h`, as free functions taking the
`ASTContext`.
Assisted-by: Claude Code (Claude Fable 5.1).
RuntimeLibcalls: Dedup dispatch calls to the same library function
Referencing a provider both as a base opt-out and as a same-name re-add
variant emitted the same setAvailableLibFuncs_<name> call twice. Collapse
references with the same (Name, FuncSuffix) into one dispatch, and drop
the unused dispatch-side exclusion list.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[Clang] [NFC] Introduce factory functions for `Token` (#229254)
There are quite a lot of places in Clang where we create a new `Token`
variable and then call `startToken()`, `setKind()` etc.
This patch introduces `Token::create()` to simplify creating tokens
manually, as well as `createAnnotation()` and `createEof()` because
creating annotation tokens and EOF tokens is a fairly common operation.
I made these factory functions rather than constructors because there
are a few places where we allocate uninitialised tokens. A refactor that
moves `startToken()` into a default constructor of `Token` would be
possible I think, but that would require some more changes, and I think
this is already enough of an improvement.
Assisted-by: Codex
[Clang][C++2d] Implement P3668R4: defaulted postfix increment and decrement operators
Allow the postfix `operator++(int)` and `operator--(int)` to be explicitly
defaulted, as specified by P3668R4 ([over.inc.default]). The implicit
definition of a defaulted postfix operator for a type C is equivalent to
C tmp(c);
++c; // or --c
return tmp;
where c denotes `*this` for an implicit object member function and the first
parameter otherwise. The copy is direct-initialized and `tmp` is a candidate
for named return value optimization.
The declaration requirements of [over.inc.default]p1 are checked: the first
parameter (counting the implicit object parameter) must be a reference to
C or to volatile C, the declared return type must be C, C must be complete,
and a definition as defaulted that appears in a class must be the first
declaration. Function templates and the prefix forms cannot be defaulted.
[20 lines not shown]
RuntimeLibcallsEmitter: Add isolated LibcallLibrary variant
This is essentially a hack to not break the common core functions shared
by most targets. Most targets have essentially the same base set of
compiler-rt or libc/libm functions, but a few are so radically different
there is nothing in common (e.g., the GPU targets have a handful of functions,
arm64ec changes every single function). This bit will pull these out of the
library merge-by-name system, and emitted as its own special case. This allows
the single name to be universal across targets without duplicating large
tables in the emitted inc file.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
RuntimeLibcallsEmitter: Let a consumer's own library variant beat its exclusion
A target can pull a shared library via LibraryRef<Lib, [impls]> to drop some
impls, then re-add its own versions through a same-name library variant guarded
on that target. Previously the exclusion's setUnavailable calls were emitted at
the end of setAvailableLibFuncs_<name>, after every variant, so they clobbered
the target's own re-adds.
Defer emitting a variant until after the exclusions when it re-adds an impl its
own consumer excludes (same predicates), so the target's re-add wins while
the exclusion still suppresses every other variant's contribution.
This is yet unused infrastructure for future changes.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
AMDGPU/GlobalISel: Split 4-byte aligned 64-bit LDS accesses on SI (#229531)
SI cannot use ds_read2_b32/ds_write2_b32 for 4-byte aligned 64-bit
accesses due to the LDS bounds checking bug with negative base
addresses, and the selection patterns for them require
HasUsableDSOffset. The explicit legality rules still treated these as
legal, so they failed to select. Split them into 32-bit accesses as
SelectionDAG does, and enable the GFX6 run lines in the local load and
store tests.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[DirectX] Cast the pointer for atomics whose value type differs (#226563)
`InterlockedExchange` on a `float` fails the DXIL validator with
`Invalid record`.
`DXILLegalize` rewrites a float exchange into an integer exchange, but
it does not change the pointer: Only `load`, `store` and `getelementptr`
users get their pointer elements casted.
This change adds `atomicrmw` and `cmpxchg` to PointerTypeAnalysis and
DXILPrepare. `cmpxchg` has the same defect, and float
`InterlockedCompareExchange` needs the same fix.
The output now matches DXC. If the types already agree, the atomic gets
no cast.
The test `llvm/test/tools/dxil-dis/atomicrmw.ll` covers a scalar global,
an array element and a `cmpxchg`. The `InterlockedExchange.float`
offload test now passes the validator.
[6 lines not shown]