[clang] [llvm] [BPF] Support Stack Arguments (PR #189060)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 09:58:52 PDT 2026


yonghong-song wrote:

> > > if JIT did 'sp -=' just before the call then it's broken. The code cannot store into sp - X before sp -=, since IRQ will corrupt it. Hence my earlier point that JIT has to insert 'sp -=' before the actual stores.
> > 
> > 
> > Ya. I should clarify. 'before the call' is not precise. The extra stack is allocated before the main loop (going through all insns). So we should be okay.
> 
> so what are you saying? yes or no to explicit r12 adjustment?

Probably not. As you mentioned earlier with case
  r1 = *(u64 *)(r12 + 16)
  *(u64 *)(r12 - 8) = r1
  r1 = *(u64 *)(r12 + 8)
  *(u64 *)(r12 - 16) = r1
In such cases, if we want to adjust, we will have to adjust per insn base and it is not efficient.

But if all loads are before stores, we could do some adjustment. Currently for load, there is no need to do adjustment as the arch offset already matches r12 offset. For store, we could do
  hit the first store, do adjustment 'r12 += <offset>'
  then for the rest stores, there is no need for adjustment
  hit a call. In this case, do 'r12 -= <offset>'.

My current thinking is there is no need to do explicit 12 adjustments, e.g., to accommodate with code sequences like the above. Second, for each store for x86, the offset adjustment is done in jit time. So at runtime, we have no overhead at all.

https://github.com/llvm/llvm-project/pull/189060


More information about the llvm-commits mailing list