AMDGPU: Check address alignment when merging TBUFFER accesses (#239852)
SILoadStoreOptimizer only checked the alignment of the immediate
offset when merging TBUFFER accesses, ignoring the rest of the
address. This could undo splitting done for alignment and cause
hangs. This is a theoretically stronger fix to piglit failures with
mesa which were previously hidden by conditioning this transform on
relaxed OOB mode.
Check the alignment of the whole address from the memory operand, and
assume each access is already aligned to its component size. Since the
buffer intrinsics don't provide any alignment information, accesses
with 8-bit or 16-bit components can no longer be merged from IR.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang][OpenACC] Emit NYI for unsupported scalar CHARACTER mappings. (#240551)
Automatic and assumed-length scalar CHARACTER variables, as well as
fixed-length host-associated scalars, can reach data-clause lowering as
fir.boxchar. This type is not currently mappable, causing an assertion
failure.
Emit an NYI diagnostic instead until the support for mapping `boxchar`
is implemented.
Assisted-by: Codex
RuntimeLibcalls: Add helper methods to insert declarations
Add methods to get or insert the declaration of a libcall
implementation in a module with the appropriate type and
annotations. A (potentially incorrectly declared) global that already
has the name is returned unmodified
Use them in DeclareRuntimeLibcalls, which no longer merges attributes
into or replaces the calling convention of existing functions, and no
longer crashes on a global variable with the name of a libcall
function.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
SafeStack: Take libcall declarations from RuntimeLibcallsInfo
Stop declaring __stack_chk_fail and __safestack_pointer_address
manually and construct them with the correct type automatically.
A function with the variable's name is now reported as not being a
global variable, rather than a renamed copy of the variable being
inserted. -safestack-use-pointer-address now requires
__safestack_pointer_address to be available for the target, instead of
unconditionally emitting a call to it. The tests using it on
non-Android triples move to Android.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Reland "[lldb] Honor the arm64 subtype when launching on Darwin" (#240579)
LaunchProcessPosixSpawn treated a CPU subtype of 0 as unset and fell
back to posix_spawnattr_setbinpref_np, which only takes a CPU type.
CPU_SUBTYPE_ARM64_ALL is 0, so launching the arm64 slice of a universal
arm64/arm64e binary ran the arm64e slice while LLDB reported arm64.
debugserver had the same check.
The original change (3e7841ef1d6f) was reverted in b5e55c9ca78f because
posix_spawnattr_setarchpref_np requires an exact subtype match.
Host::RunShellCommand launches helper tools with the host architecture,
which LLDB reports as arm64 on arm64e hardware. System binaries like
xcrun only ship arm64e and x86_64 slices, so launching them failed with
"Bad CPU type in executable".
The reland adds CPU_SUBTYPE_ANY as a second preference. The kernel still
picks the exact slice when present and otherwise falls back to any slice
of the CPU type. debugserver maps arm64_32 to CPU_SUBTYPE_ARM64_32_V8 so
the exact match succeeds.
[2 lines not shown]
[Bazel] Add BuiltinsHexagonDepTdFiles to basic_builtins_hexagon_gen (#240644)
Commit 848e36a316e8 refactored BuiltinsHexagon.td to include
BuiltinsHexagonDep.td. Add BuiltinsHexagonDepTdFiles td_library and
include it in basic_builtins_hexagon_gen deps.
[libc][math] Optimize pow 128-bit and 256-bit accurate passes and share exp2_df128. (#237026)
- Refactor 128-bit and 256-bit accurate passes to use multi-tier
fixed-point arithmetic (Frac64, Frac128, Frac256) and share
double_eval::exp2_df128 with exp/exp2/exp10.
- Simplify is_exact_rounding_boundary to operate on normalized (x_e,
x_mant), unify power loops, and replace 64-bit hardware divisions with a
leading-zero bit-width bound.
- Avoid general multi-limb normalization and conversion overhead in
pow_accurate and pow_accurate_256.
Assisted by: Gemini for analysis and refactoring
[AMDGPU] Price misaligned flat and LDS accesses with the LDS misaligned bug
In WGP mode on subtargets with the LDS misaligned bug, a flat access is
split into pieces no wider than its alignment and no narrower than 4
bytes, and an LDS access aligned below 4 bytes uses 8-byte pieces as one
aligned to 4 does.
[AMDGPU] Price buffer fat pointer memory operations
Price buffer fat pointer accesses as global accesses, except that an
aligned load is not widened and a vector of odd width elements is not
split element by element. Without relaxed buffer bounds checking, a
vector of elements that are a multiple of 32 bits wide is accessed in
pieces no wider than its alignment and no narrower than 4 bytes, and a
vector of other byte-sized or power of 2 wide elements in pieces of the
largest power of 2 bytes that divides the element size. The width comes
from buffer fat pointer lowering, which now exposes it. When the pointer
is a buffer resource plus a constant offset, the offset and a constant
number of records give the same bounds facts lowering uses to access it
in wider pieces.
[NFC][AMDGPU] Add tests for int to fp casts of a narrow i64 source (#240137)
Scalar and vector i64 sources with at most 32 significant bits from a
shift or a mask, converted to f16, bf16, f32 and f64.
Assisted-by: Claude Code Opus 5
[DWARFLinker] Share hashFullyQualifiedName between the linkers (#240621)
The classic linker hangs computing the Apple accelerator table hash of
a type whose DW_AT_specification or DW_AT_abstract_origin chain forms a
cycle or holds a reference it cannot resolve. Its loop has no bound,
and on an unresolved reference it retries the same DIE forever.
The parallel linker's copy bounds the walk with finiteLoop. Move it to
Utils and use it from both linkers, each with its own reference
resolver. The test links a type whose DW_AT_specification refers to
itself, which hangs the classic linker without this change.
The parallel linker now also ends the name at any unit DIE, not only a
DW_TAG_compile_unit, as the classic linker already did. The classic
linker still ends it at a DW_TAG_module scope. Hashes are otherwise
unchanged.
Assisted-by: Claude
[GlobalDCE][NFC] scan each vtable slot only once per function (#240541)
Extracted from https://github.com/llvm/llvm-project/pull/232495.
A small optimization to how often `ScanVTableLoad` runs: it now runs
only once per function. Especially after inlining, rust will regularly
load the same function pointer from a vtable multiple times in the same
function. Only the first load is relevant for liveness.
[AArch64][ARM64EC] Preserve native alignment in thunk names (#238613)
`getThunkArgTypes` gave every ordinary parameter alignment 1, so types
with different native alignment (e.g. `i128` vs `[2 x i64]`) mapped to
the same thunk name and shared a thunk that reads the wrong argument
registers. This PR makes it use the `DataLayout` ABI alignment so the
names differ and the right thunk is used.
---------
Co-authored-by: Breno Campos <brenoc at microsoft.com>
Co-authored-by: Copilot <223556219+Copilot at users.noreply.github.com>
Check arm64e ABI markers in static links too
Static links skipped the check, but ld64 takes only unversioned and
kernel objects there besides version 0, and ignores the other markers.
Assisted-by: Claude Code
Use hdr->cpusubtype directly in compatWithTargetArch
Drop the local sub, which held the full CPU subtype right next to subtype, the masked one.
Assisted-by: Claude Code
Set IsLittleEndian in arm64e-input-abi.s
#238122 makes IsLittleEndian required in Mach-O YAML. Set it here so this test works whichever of the two lands first.
Assisted-by: Claude Code
[lld-macho] Reject incompatible arm64e object ABI markers
The CPU subtype of an arm64e object carries a pointer authentication ABI
marker. In a dynamic link, ld64 accepts only objects marked userland ABI
version 0, even on macOS and Mac Catalyst, whose executables are marked
version 1. It names any other marker as another architecture
(arm64e.old, arm64e.v1, arm64e.kernel, arm64e.kernel.v1 or unknown) and,
as with an arm64 object, ignores the file with a warning, or reports an
error with -arch_errors_fatal. This applies to archive members too.
lld linked these objects. Check the marker in the same way. ld64 accepts
unversioned and kernel-ABI objects in static links, so those links are
not checked.
Assisted-by: Claude Code
[lld-macho] Sign arm64e TLV bootstrap binds and list __auth_got in map files (#234004)
Two small arm64e changes:
1. Sign the arm64e TLV bootstrap pointer as ld64 does. The first word of
a thread-local variable descriptor is bound to `__tlv_bootstrap`, which
dyld replaces with a pointer to `tlv_get_addr` that TLV accesses call
with `blraaz`. On arm64e, write that bind as an auth'd bind with the IA
key and no diversity, even though the object asks for a plain pointer.
2. List arm64e `__auth_got` entries in the map file. The map file
printed the entries of `__got` but not those of `__auth_got`, which
holds the targets of the stubs and the personalities.
Assisted-by: Claude
[AMDGPU] Price misaligned flat and LDS accesses with the LDS misaligned bug
In WGP mode on subtargets with the LDS misaligned bug, a flat access is
split into pieces no wider than its alignment and no narrower than 4
bytes, and an LDS access aligned below 4 bytes uses 8-byte pieces as one
aligned to 4 does.