[1/2][AMDGPU] Fixed crash due to virtual register defs not dominating uses (#198472)
Fixes https://github.com/llvm/llvm-project/issues/196671.
Fixes duplicate ROCM-24494, LCOMPILER-2224.
In Rewrite AGPR-Copy-MFMA pass, a spill reload may not have a dominating
spill store. If such a slot is unspilled into a vreg, the elimination
phase crashes because virtual register defs do not dominate all uses.
This patch checks for that dominance property for all reloads and skips
unspilling if such a condition is found.
This patch is adapted from
https://github.com/llvm/llvm-project/pull/167347
Cherry-picked https://github.com/ROCm/llvm-project/commit/e5d02ddb
Authored by: Austin Kerbow <Austin.Kerbow at amd.com>
Instead of scanning through instructions within the reload basic block,
[17 lines not shown]
[Clang] Prevent an assertion failure when instantiating an invalid friend function template (#216727)к
Fixes #216694
---
This patch addresses an assertion failure that occurs when instantiating
an invalid friend function template by marking its `FriendDecl` wrapper
as invalid.
lang/gcc15: fix build after base d08296c7ab0d
After base d08296c7ab0d7bb259bf7b8cdf9ffb819c1929ab ("libc: Implement
qualifier-preserving standard library functions"), lang/gcc15 fails to
build with errors like:
/wrkdirs/usr/ports/lang/gcc15/work/gcc-15.2.0/libgomp/affinity-fmt.c: In function 'gomp_display_affinity':
/wrkdirs/usr/ports/lang/gcc15/work/gcc-15.2.0/libgomp/affinity-fmt.c:330:25: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
330 | char *q = strchr (p + 1, '}');
| ^~~~~~
and:
In file included from /wrkdirs/usr/ports/lang/gcc15/work/.build/gcc/include-fixed/stdio.h:52,
from cp-demangle.c:109:
/wrkdirs/usr/ports/lang/gcc15/work/gcc-15.2.0/libstdc++-v3/../include/libiberty.h:225:14: error: expected identifier or '(' before '_Generic'
225 | extern void *memrchr(const void *, int, size_t);
| ^~~~~~~
[25 lines not shown]
lang/gcc15: fix build after base d08296c7ab0d
After base d08296c7ab0d7bb259bf7b8cdf9ffb819c1929ab ("libc: Implement
qualifier-preserving standard library functions"), lang/gcc15 fails to
build with errors like:
/wrkdirs/usr/ports/lang/gcc15/work/gcc-15.2.0/libgomp/affinity-fmt.c: In function 'gomp_display_affinity':
/wrkdirs/usr/ports/lang/gcc15/work/gcc-15.2.0/libgomp/affinity-fmt.c:330:25: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
330 | char *q = strchr (p + 1, '}');
| ^~~~~~
and:
In file included from /wrkdirs/usr/ports/lang/gcc15/work/.build/gcc/include-fixed/stdio.h:52,
from cp-demangle.c:109:
/wrkdirs/usr/ports/lang/gcc15/work/gcc-15.2.0/libstdc++-v3/../include/libiberty.h:225:14: error: expected identifier or '(' before '_Generic'
225 | extern void *memrchr(const void *, int, size_t);
| ^~~~~~~
[23 lines not shown]
SYSINIT: add SI_SUB_KENV
Since the kernel environment has its own dependencies, lurking at the end
of the SI_SUB_KMEM sequence appeared to be fragile. Provide own subsystem
for it. The init_dynamic_kenv() goes SI_ORDER_FIRST, and two modules that
depend on it go SI_ORDER_ANY.
PR: 297492
Reviewed by: imp, markj, emaste
Differential Revision: https://reviews.freebsd.org/D58836
math/gmp: fix build after base cd0727ec709b
After base cd0727ec709bb54f8f82104f6113284a15dd3464 ("libc: Add
<stdio.h> C23 feature test macro"), math/gmp fails to build with errors
similar to:
inp_str.c:63:10: warning: call to undeclared function '__gmpz_inp_str_nowhite'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
63 | return mpz_inp_str_nowhite (x, stream, base, c, nread);
| ^
../gmp-impl.h:1782:29: note: expanded from macro 'mpz_inp_str_nowhite'
1782 | #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite
| ^
inp_str.c:68:1: error: conflicting types for '__gmpz_inp_str_nowhite'
68 | mpz_inp_str_nowhite (mpz_ptr x, FILE *stream, int base, int c, size_t nread)
| ^
../gmp-impl.h:1782:29: note: expanded from macro 'mpz_inp_str_nowhite'
1782 | #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite
| ^
inp_str.c:63:10: note: previous implicit declaration is here
[20 lines not shown]
math/gmp: fix build after base cd0727ec709b
After base cd0727ec709bb54f8f82104f6113284a15dd3464 ("libc: Add
<stdio.h> C23 feature test macro"), math/gmp fails to build with errors
similar to:
inp_str.c:63:10: warning: call to undeclared function '__gmpz_inp_str_nowhite'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
63 | return mpz_inp_str_nowhite (x, stream, base, c, nread);
| ^
../gmp-impl.h:1782:29: note: expanded from macro 'mpz_inp_str_nowhite'
1782 | #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite
| ^
inp_str.c:68:1: error: conflicting types for '__gmpz_inp_str_nowhite'
68 | mpz_inp_str_nowhite (mpz_ptr x, FILE *stream, int base, int c, size_t nread)
| ^
../gmp-impl.h:1782:29: note: expanded from macro 'mpz_inp_str_nowhite'
1782 | #define mpz_inp_str_nowhite __gmpz_inp_str_nowhite
| ^
inp_str.c:63:10: note: previous implicit declaration is here
[18 lines not shown]
[CIR] Classify around a record's padding on x86_64
The x86_64 bridge refused any struct whose CIR type carries a pad member, which
is every over-aligned record and every record with a gap between two members.
The ABI library already reads each field's explicit offset, sizes the record
from its own size, and treats a gap no field overlaps as holding no user data.
However, the bridge was handing it every member as a field, padding included, so
a record's padding bytes read as data. Now we build the field list from the
members that hold data.
Assisted-by: Cursor / claude-opus-5
Address review comments
Only clamp negative inputs to zero when saturating. Without saturation
the result is poison, so nothing needs to be emitted and no select gets
a poison operand.
Trim the comments added by the previous commit.
Change-Id: I7b86ebd6d0b7853f4dea7312bec21aea2bb91def
[flang] Improve error for misplaced statement after CONTAINS in derived type (#215886)
A statement after `CONTAINS` in a derived type that is not a type-bound
procedure binding (e.g. a second `CONTAINS`, an `IMPORT`, or a misplaced
subprogram) leaked the intrinsic type-spec parse failures (`expected
'COMPLEX'`, `expected 'INTEGER'`, ...) instead of reporting that a
type-bound procedure binding was expected. In the misplaced-subprogram
case flang emitted an avalanche of unrelated `expected '<type-keyword>'`
errors.
This is a diagnostic regression from #203379, which added
`DataComponentDefStmt` as a trailing alternative in the
type-bound-proc-binding parser. Its intended `fail<>()` message only
fires when `DataComponentDefStmt` fully matches; for other invalid
statement the partial parse into `declarationTypeSpec` displaced the
recovery message in `CombineFailedParses`.
This patch wraps the binding alternatives in `withMessage()` so that
when none of them match a token a single clear message is emitted:
[17 lines not shown]
RISCV: Fix VL optimizer crash on an undef VL operand (#216803)
Found by AI while working on something else.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
Fix transposed arguments in call to calloc(). Reported by GCC 15 warning.
No functional change intended.
Submitted by: Pedro Giffuni <pfg at freebsd.org>
MFC-after: 1 week
[CIR] Implement aligned-array-delete. (#216789)
This ends up being a pretty trivial implementation, since we just have
to add the additional i64 argument to the call. This patch adds that,
after threading the alignment through CIR.
Also, the type-aware and destroying deletes aren't valid on a array
delete, so replace those checks with 'assert' instead.
[Clang][CodeGen] Use ptrtoaddr for pointer diff (#210729)
We don't have to expose the provenance of pointers for pointer
subtraction, so use ptrtoaddr instead of ptrtoint if -fwrapv-pointer is
not set.
crash(8): Add support for `mach cpu N' on x86.
Requires core dump to have the registers saved on cpuN. This happens
with the ddb `sync' command, but not with the kern.dump_on_panic=1
ddb.onpanic=0 path yet -- TBD.
PR bin/58010: crash(8) doesn't support `mach cpu N' to examine
registers/stack of other CPUs
[CodeGen] Fix stale LiveIntervals regmask tables after MachineBasicBl… (#209610)
MachineBasicBlock::splitAt() moves the tail of a block -- including any
call instructions carrying register-mask operands -- into a newly
created block. When LiveIntervals is attached it calls
LIS->insertMBBInMaps() for the new block, which records the block with
zero regmask slots. That is only correct for a fresh, empty block:
because the tail (and its regmasks) was *moved* out of the original
block, the per-block RegMaskBlocks index for both blocks is left stale,
so checkRegMaskInterference() can miss a call clobber and the register
allocator can assign a live value to a clobbered physical register.
Add a LiveIntervals::splitAt(Orig, SplitBB) entry point that inserts
SplitBB into the SlotIndexes/regmask maps and then re-slices the moved
regmask slots out of Orig's RegMaskBlocks entry into SplitBB's
(RegMaskSlots is sorted, so the slots that moved are those at/after
SplitBB's start index). MachineBasicBlock::splitAt() now calls it in
place of insertMBBInMaps().
[13 lines not shown]
[flang][OpenACC] Fix crash on ATTACH/DETACH with an unresolved name (#216801)
`AccAttributeVisitor::EnsureAllocatableOrPointer()` passes the last name of the
designator to `IsAllocatableOrObjectPointer()`, which accepts a null `Symbol`
pointer and returns `false` for it. When the argument of an `ATTACH` or `DETACH`
clause fails name resolution -- for example a component reference whose derived
type could not be resolved -- that name's symbol is null, so control reaches the
error-reporting path, which then dereferences the same null symbol and crashes
the compiler.
Because the crash happens during name resolution, it precedes the point where
semantic diagnostics are emitted, so the compiler dies with no output at all
rather than reporting the errors that caused the name to be unresolved.
Reproducer:
```fortran
subroutine test_attach_unresolved
type :: ty
[13 lines not shown]
Hexagon: Fix early if-conversion crash on an undef PHI operand
Found by AI while working on something else.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[NFC][MemProf] Remove unused memprofraw test file (#216778)
`llvm/test/Transforms/PGOProfile/Inputs/memprof_loop_unroll.memprofraw`
was created in https://github.com/llvm/llvm-project/pull/79433 for the
`llvm/test/Transforms/PGOProfile/memprof_loop_unroll.ll` test, but the
usage was removed in https://github.com/llvm/llvm-project/pull/165338 in
favor of an inline `.yaml` file. Remove the `.memprofraw` file and the
generator script.