[libc] Use a syscall wrapper for poll (#238266)
This PR move poll behind the centralized syscall wrappers, following
libc/docs/dev/syscall_wrapper_refactor.md.
---
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
[libc] Use a syscall wrapper for openat (#238264)
This PR move openat behind the centralized syscall wrappers, following
libc/docs/dev/syscall_wrapper_refactor.md.
---
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
[Hexagon] Enable SlotIndexes compaction by default
Opt Hexagon in to dropping dead SlotIndexes entries before greedy
allocation, as AMDGPU already does, so live range sizes count only
instructions that still exist.
The test updates are register allocation changes; two pipeliner tests
get back their original, shorter kernels.
RuntimeLibcalls: Add signatures for size returning new and GPU profiling
__size_returning_new and its variants return __sized_ptr_t, a pointer
and size pair. The GPU profiling functions use the compiler-rt
prototypes.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
libunwind: Use libgcc's function context layout for sjlj
Make call_site an i32 and the __data words pointer
sized. compiler-rt's SjLj_Function_Context was not defined in the same
way as libgcc.
This was broken for all 64-bit targets. Every field was i32, so the
exception pointer in __data[0] was truncated. It just happens that no
64-bit target defaults to SJLJ exceptions except VE. Instead of fixing
that, a VE special case was introduced in the libunwind sources and
SjLjEHPrepare, which had a special TargetMachine hook for this data
size. In reality it should just be a uintptr_t which we can already
infer from the DataLayout.
This is an ABI break for 64-bit targets other than VE when using
libunwind built for SjLj: the __data, personality, lsda and jbuf
offsets move, so compiled code and libunwind must be updated
together. That configuration was already broken by the pointer
truncation and is not the default anywhere. 32-bit targets are
[4 lines not shown]
[Hexagon] Enable SlotIndexes compaction by default
Opt Hexagon in to dropping dead SlotIndexes entries before greedy
allocation, as AMDGPU already does, so live range sizes count only
instructions that still exist.
The test updates are register allocation changes; two pipeliner tests
get back their original, shorter kernels.
RuntimeLibcalls: Add a signature for __llvm_deoptimize
llvm.experimental.deoptimize is lowered to a call to __llvm_deoptimize
with the intrinsic's arguments and return type, which vary between
calls, so declare it as void (...). No actual output change because
this happens to be the filler signature used for unhandled functions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add signatures for size returning new and GPU profiling
__size_returning_new and its variants return __sized_ptr_t, a pointer
and size pair. The GPU profiling functions use the compiler-rt
prototypes.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang][NFC] Explain the -Waix-compat suppression in real-value.h (#238635)
Follow-up to 238605, which suppressed `-Waix-compat` on
`RealValue::opaque_` without saying why the warning does not point at a
real problem.
The warning flags a by-value struct with a 16-byte-aligned member as not
binary compatible with IBM XL C/C++ for AIX 16.1.0 or older. Here the
alignment is required: it is that of `RealValueImpl`, which comes from
`Real<>::word_`, and `real.h` already suppresses the same warning there.
Those older compilers cannot compile flang's C++17 code, so there is no
compatibility to preserve. This adds a comment saying so; no functional
change.
Assisted-by: AI
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
[BPF] Promote i32 stack arguments to i64 with ALU32 (#238315)
Without ALU32, `CC_BPF64` promotes i32 arguments to i64, so the caller
sign- or zero-extends `signext`/`zeroext` arguments to the full 64-bit
stack slot and the callee relies on that.
With ALU32, `CC_BPF32` assigns i32 stack arguments as is, with
`CCValAssign::Full`. The caller any-extends them to the 64-bit slot, but
the callee reads the slot as i64 and the generic argument lowering still
asserts it is sign/zero-extended, so it is used without extending (`llc
-mcpu=v3`):
```
declare i64 @ext(i64, i64, i64, i64, i64, i32 zeroext, i32 signext)
... call i64 @ext(..., i32 zeroext %t, i32 signext %t)
caller: *(u64 *)(r11 - 8) = r1 ; %t not extended
*(u64 *)(r11 - 16) = r1
callee: r1 = *(u64 *)(r11 + 8) ; assumed extended
r0 = *(u64 *)(r11 + 16)
[25 lines not shown]
[ProfCheck] Wire up enable-profcheck-in-pipeline to CodeGen
This patch wires up the enable-profcheck-in-pipeline flag to the CodeGen
pipeline (NewPM only because it's complete enough for testing and should
become the default soonish). This enables catching issues in the IR
section of the CodeGen pipeline.
From attempting a bootstrap of LLVM, it seems like there are many such
issues to dig through.
Reviewers: mtrofin, aeubanks
Pull Request: https://github.com/llvm/llvm-project/pull/238608
[sanitizer_common] Fix strlcpy shadow handling (#238598)
The `strlcpy` interceptor passes `internal_strlen(dst) + 1` to
`COMMON_INTERCEPTOR_COPY_STRING`, which already unpoisons the next byte.
Use the copied length instead of `internal_strlen(dst) + 1 `, and skip
the update when `size` is zero.
Follow-up to #236414.
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
[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 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, ld64 writes that bind as an
authenticated bind with the IA key and no diversity, although the object
asks for a plain pointer. Do the same.
Assisted-by: Claude Code
[lld-macho] List arm64e __auth_got entries in the map file
The map file printed the entries of __got but not those of arm64e's
__auth_got, which held the targets of the stubs and the personalities.
Print them in the same way.
Assisted-by: Claude Code
[lld-macho] Call through authenticated stubs on arm64e (#234003)
Call dylib functions from arm64e code through `__auth_stubs` rather than
`__stubs`, as ld64 does. Each stub is four instructions instead of
three:
```
adrp x17, slot at page
add x17, x17, slot at pageoff
ldr x16, [x17]
braa x16, x17
```
where the slot is in `__auth_got` and holds a pointer that dyld signs
with the IA key, blended with the slot's address. The raw target is only
ever held in x16 and x17, so a stub never branches through an
unauthenticated pointer loaded from writable memory. On arm64e, name the
stubs section `__auth_stubs`, make stubs 16 bytes, and put stub targets
in `__auth_got`. Fast ObjC stubs load `_objc_msgSend` from `__auth_got`
[10 lines not shown]
[X86][APX] Save R16-R31 in interrupt and no_caller_saved_registers functions (#237109)
x86_intrcc, "no_caller_saved_registers" and anyregcc functions must
preserve every register they modify. With EGPR their save lists
(CSR_64_AllRegs*) did not include R16-R31, so a handler that uses, or
calls something that clobbers, an extended GPR silently corrupts the
interrupted context. For example, a handler reading its interrupt frame
loads it into r16/r17 and returns with iretq without restoring them.
Add CSR_64_APX_AllRegs{,_NoSSE,_AVX,_AVX512}, the AllRegs lists plus
R16-R31, and use them as the save lists when the subtarget has EGPR. The
call-preserved masks are unchanged, so callers keep treating R16-R31 as
clobbered. This stays correct for callees built without EGPR or by other
or older compilers.
Assisted-by: Claude Opus 5.5 <noreply at anthropic.com>
[CodeGen] Make ExecutionDomainFix Generic
Rather than having targets create their own subclass just to override
the register class, push the register class into TRI and have the pass
query that, similar to what we did for BreakFalseDeps.
This makes it easier to port to the NewPM.
Reviewers: arsenm, davemgreen, RKSimon
Pull Request: https://github.com/llvm/llvm-project/pull/238536
[X86][SEH] Emit epilog SEH_Push2Regs in PUSH2 order for unwind v3 (#237829)
For Win64 unwind v3, the .seh_push2regs emitted before an epilog POP2
named the registers in POP2 order. Epilog ops are interpreted like the
prolog PUSH2 they undo, so unwinding from inside the epilog restored the
pair swapped. Emit them in PUSH2 order, matching the prolog (and the
assembler's .pop2reg handling); the epilog can now share the prolog
WODs.
Fixes #231762.
Assisted-by: Claude Opus 5.5
[X86] Port X86IndirectThunks to NewPM
Standard NewPM pass porting. Although we hold the inserters inside the
class given they have state we need to manage appropriately. Inside
unique_ptr given the class definition is local to the implementation.
Reviewers: aeubanks, RKSimon, arsenm
Pull Request: https://github.com/llvm/llvm-project/pull/238487