[all-commits] [llvm/llvm-project] 19e915: [LoongArch] Fix musttail with indirect arguments b...

hev via All-commits all-commits at lists.llvm.org
Tue May 26 01:48:17 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 19e915fc5c91645ccc4050180e9daabec30358c4
      https://github.com/llvm/llvm-project/commit/19e915fc5c91645ccc4050180e9daabec30358c4
  Author: hev <wangrui at loongson.cn>
  Date:   2026-05-26 (Tue, 26 May 2026)

  Changed paths:
    M llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
    M llvm/lib/Target/LoongArch/LoongArchMachineFunctionInfo.h
    A llvm/test/CodeGen/LoongArch/musttail-call.ll
    A llvm/test/CodeGen/LoongArch/musttail-indirect-args.ll

  Log Message:
  -----------
  [LoongArch] Fix musttail with indirect arguments by forwarding incoming pointers (#198965)

When a `musttail` call passes arguments indirectly (fp128 on LA32, i128
on LA32), the backend allocates a stack temporary and hands the callee a
pointer. The tail call deallocates the caller's frame, and the pointer
dangles.

Fix by forwarding the incoming indirect pointers instead. They point to
the caller's caller's frame, which stays valid after the tail call.
Forwarded formal parameters reuse the pointer directly; computed values
get stored into the incoming buffer first.

The pointers are saved in virtual registers (`CopyToReg`/`CopyFromReg`)
rather than SDValues. The SelectionDAG is cleared between basic blocks
and musttail calls can appear in non-entry blocks, so storing raw
SDValues across BBs is unsound (this was the bug that led to the revert
in 501417baa60f). The vreg save only fires when the function has
musttail calls; other functions see no codegen change.

Non-musttail tail calls with indirect args are still rejected.

This uses the same strategy as the corresponding RISC-V fix (#185094).



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