[all-commits] [llvm/llvm-project] 333edd: [BPF] Return small aggregates directly in register...
yonghong-song via All-commits
all-commits at lists.llvm.org
Tue Jul 7 22:29:18 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 333edde4e80e02d6fe5e866abf317969b66c0b8e
https://github.com/llvm/llvm-project/commit/333edde4e80e02d6fe5e866abf317969b66c0b8e
Author: yonghong-song <yhs at fb.com>
Date: 2026-07-07 (Tue, 07 Jul 2026)
Changed paths:
M clang/lib/CodeGen/Targets/BPF.cpp
A clang/test/CodeGen/bpf-struct-return-regs.c
A clang/test/CodeGen/bpf-struct-return.c
A llvm/test/CodeGen/BPF/aggr_ret_regs.ll
Log Message:
-----------
[BPF] Return small aggregates directly in registers (#206876)
Previously the BPF ABI always returned aggregate (struct/union) types
indirectly through an sret pointer, regardless of size. This is
inconsistent with how classifyArgumentType() already passes small
aggregates: arguments up to 128 bits are coerced into one or two 64-bit
registers, while only larger aggregates use an indirect reference.
Make classifyReturnType() mirror that convention by factoring the shared
aggregate handling into a classifyAggregateType() helper used by both:
- empty aggregates (0 bits) are ignored;
- aggregates up to 64 bits are returned directly, coerced to an integer
of the padded size;
- aggregates of 65..128 bits are returned directly as [2 x i64];
- aggregates larger than 128 bits are returned indirectly via sret.
This keeps each returned value within the backend's two-register return
convention and avoids an unnecessary memory round-trip for small
structs.
This also aligns BPF with the general-purpose C ABIs of other targets:
both x86-64 (System V, RAX:RDX) and AArch64 (AAPCS64, X0:X1) return
aggregates up to 16 bytes in a pair of registers and only fall back to
an indirect sret pointer for larger ones.
Co-authored-by: Yonghong Song <yonghong.song at linux.dev>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list