The contiguous-stack varargs walk depends on SelectionDAGBuilder's
argument-copy elision making &last_fixed the incoming stack slot. The
elision requires the fixed object and the parameter alloca to have equal
size, so an i8/i16 anchor silently stays a private local and the walk
reads the wrong slot. Reject a variadic definition unless its last fixed
argument is i32 or a pointer, and pin the i32 anchor's FP-64 slot and the
first variadic at one slot below in m4-varargs-anchor.ll.
Support the contiguous-stack varargs form termtris' compat.c sprintf
needs, promote i8/i16 fixed arguments to one i32 slot, and select i1 and
any-extending narrow loads. Recursively emit nested array initializers,
keep divide-by-constant on DIVS/DIVU (MULHS/SMUL_LOHI are unsupported),
and disable jump tables. Add a vector setcc result type so O2's <3 x i32>
struct copy legalizes. The termtris gate exposed all of these.
Add the one-word indirect call CALL Rs (0000 1001 001R DDDD, 0x0920) and
extend LowerCall to accept a function-pointer callee alongside the existing
direct CALLA path. The indirect callee is a 32-bit bit address: a constant or
non-function global becomes MOVI and any other value is copied into an
allocatable ARegs virtual register after the argument pushes, so the pushes
cannot clobber the target. The old-STK save, argument order, FS0/FS1
re-establishment and A8 return are unchanged.
GSPA 2.00 accepts CALL A0 (not CALL $A0); dis34 prints it as call aN. The new
m4-fnptr lit test covers a callback argument, a memory-loaded pointer, an
absolute ROM address and a no-argument callback. The obsolete
m2-reject-call-indirect test is removed.
Add the register-file multiply and divide encodings and restrict their tied
destination to the odd allocatable A registers, so the instruction uses the
single-register 32-bit form instead of a Rd:Rd+1 pair. MPYS covers the low
32 bits of a 32x32 product, MPYU the masked 16x16 unsigned product, and
DIVS/DIVU the 32/32 quotients. SREM/UREM expand to dividend - quotient *
divisor because the odd-destination divide does not return a remainder.
Sign-extension in register (which DAGCombine forms from ordinary short
arithmetic) selects SEXT8/SEXT16 and expands to the verified SLL/SRA pair.
Test the 32-bit and 16-bit store paths (MOVE ..., 1 / ..., 0) and take
the shared register-file bit from the store data source (src{4}) with
the same-file invariant documented. Gate the lit directory on the
TMS34010 target being built, and run the no-stack frame test at -O2
with an escaping alloca.
emitGlobalVariable handled only zero-initialized .bss objects and let
initialized globals, string literals and constant/private data fall
through to the generic ELF .data/.rodata/.asciz printer, which GSPA
rejects. Reject every non-null initializer and private/constant data
with a fatal error, and add m1-data/m1-string negative tests.
Validate the IR signature before legalization can split i64/aggregate
parameters into i32 pieces, and reject varargs plus sret/byval/inreg/
nest/returned argument flags. CanLowerReturn no longer returns false
for an unsupported return type (which silently demoted it to sret);
it reports a fatal error instead. Add negative lit tests at -O0/-O2.
GSPA 2.00 has no .section/.type/.size/.ident/.p2align directives, so
use the base MCAsmInfo and switch sections with bare .text/.data/.bss.
Zero-initialized globals become one .bss line (sizes in bits), and a
global address (including the +bit-addend constant-GEP form) selects to
a single MOVI relocation.
M1 has no stack, so the fast register allocator's spill/reload path
cannot work at -O0; use the greedy allocator there while still skipping
the IR pipeline. Add m1-o0.ll and m1-global.ll.
When a global is requested for definition but a definition with the same
mangled name already exists, return it as is instead of creating a fresh
global and erasing the defined one, even if its type differs from the
requested type.
The type can legitimately differ when the initializer folded to a
different (e.g. anonymous) type, as happens with unions. Erasing the
defined global dangles pointers held by callers, e.g. the
`AssociatedData` of entries in `llvm.global_ctors`, leading to a
use-after-free crash during `EmitCtorList`. This also keeps the
deferred-decls "already emitted" check sound, since it queries with
`IsForDefinition`, which must be non-destructive.
Add a header-unit regression test: an inline variable with an
anonymous-union member, constant-initialized but requiring dynamic
destructor registration, must be emitted exactly once when imported from
header units. The folded initializer has an anonymous type that differs
from the declared type; a second emission used to replace (and erase)
the already-defined global, leaving a dangling pointer in
`llvm.global_ctors` (use-after-free, observable as a crash under ASan).
Assisted-By: Meta Muse 1.3
Co-authored-by: Michael Park <mcypark@gmail.com>
(cherry picked from commit 2a6fdac960de3a6bae854474f12e8f1edfcd9a04)
This follows up to https://github.com/llvm/llvm-project/pull/207966 in order to transforms type
constraints with a ForConstraintSubstitution flag.
Assisted-by: Codex
(cherry-picked from 93c463319ebcb57e82f0c87c813a9ead536fb952)
Each execution of an alloca creates a new allocation, distinct from the
allocations of all other executions. They must not be merged, either by
CSE or via isUniformAcrossVFsAndUFs.
Update those to explicitly handle Alloca recipes.
Fixes https://github.com/llvm/llvm-project/issues/229389.
PR: https://github.com/llvm/llvm-project/pull/229929
(cherry picked from commit 95ea23b7d5b06c60c513c575577d5b7d0ed15721)
The OpenBSD Host code used FreeBSD-style sysctl MIBs, which don't
match OpenBSD's interface, so process lookups failed.
- GetOpenBSDProcessArgs: use {CTL_KERN, KERN_PROC_ARGS, pid,
KERN_PROC_ARGV}. OpenBSD returns a NULL-terminated argv array
whose pointers point into the returned buffer, so iterate it
directly.
- GetOpenBSDProcessUserAndGroup, FindProcessesImpl: KERN_PROC
takes a 6-element MIB on OpenBSD, with the kinfo_proc element
size and element count as the last two entries.
(cherry picked from commit b880f44cbad751b0784a5fbbfbdaacea25e167f8)
Fixes#233318
Before this change, we were restoring some callee-saved registers twice
when using save/restore libcalls with shadow call stack (SCS), and the
second restore was happening after the stack was deallocated using the
wrong register and offset calculation, which was causing lots of access
problems.
The problems were:
- We were using the entire list of Callee Saves rather than just the
subset that would have been restored by the libcall. This caused
duplicate restores because of how the CSI subsetting works.
- We were not using the correct offset calculation in
eliminateFrameIndex, which was causing us to calculate the wrong
address for the saves/restores.
Assisted-by: AI
Co-authored-by: Mitch Briles <mitchbriles@gmail.com>
This primarliy applies to the save-restore case, which was using
`__riscv_restore_<N>` incorrectly, entirely circumventing the software
shadow call stack.
This fix keeps the code size improvements of `__riscv_save_<N>` when
there is a shadow call stack, but it avoids the incorrect use of
`__riscv_restore_<N>`, instead emitting the correct sequence inline.
In the future, when there are better versions of `__riscv_save_<N>` and
`__riscv_restore_<N>` which support the shadow call stack variants (both
hardware and software), then we can revisit this approach and use the
correct pairs in all cases.
`TargetLowering::expandABD` expands `abd(a, b)` to `abs(sub(a, b))` when
`willNotOverflowSub` says the sub can't overflow. For `abdu` without
known
non-negative operands, this checks for unsigned overflow, which only
proves
`a >= b (unsigned)`, so `abdu(a, b) == sub(a, b)`. adding abs around it
is wrong, when the
difference is greater than INT_MAX, e.g. `abdu(lshr(x, 1), or(y,
INT_MIN))`.
Keep abs(sub) for the signed check (abds, or abdu with non-negative
operands) and use just sub when abdu and `a >= b`.
Fixes#233087.
(cherry picked from commit f16dbe0ec4b653736148c78bebdefcfe1c88198e)
alignof(std::max_align_t) is 4 on NetBSD/i386, whose <stddef.h> defines
max_align_t as a union of void *, long double, and long long.
Fix#230782
(cherry picked from commit 0b6b6ed806536c1b170101061ff3eeed91c8f061)
The OpenMP spec has a bug: the restriction should read
> If linear-modifier is ref, list items must not be polymorphic variables,
> assumed-shape arrays, or variables with the ALLOCATABLE attribute.
---------
Co-authored-by: Markus Mützel <markus.muetzel@gmx.de>
(cherry picked from commit 53d096bbf31d12fddbbe2508b7f80bab9628430d)
`clang++` defaults to `-stdlib=libc++` on OpenBSD. When building with both
`clang` and `libcxx` included, the freshly built `clang++` uses the system
version of the `libc++` headers. However, this is from the bundled `libc++`
22.1.8, thus inconsistent with the `libc++` being built.
OpenBSD has its own version of addLibCxxIncludePaths which just includes
`/usr/include/c++/v1`.
This patch removes OpenBSD::addLibCxxIncludePaths in favour of the generic
version in `Gnu.cpp`.
(cherry picked from commit 1204f6b4e9d6bef8ec319d121942dca5cbf94a26)