llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.59k stars 11.34k forks source link

riscv64 backend failed to perform tail call elimination on a call site marked musttail #56908

Open lqcd opened 2 years ago

lqcd commented 2 years ago

__attribute__((musttail)) crashes the RISCV backend in version 14.0.6 when running

$ clang -O3 --target=riscv64 -fomit-frame-pointer -Dregcall='' -S -c reg-args.c 

with reg-args.c in the attached tarball.

There is no /Users/avp/Library/Logs/DiagnosticReports/clang-14* files, report.crash is stderr clang-14-report.tar.gz

llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-risc-v

luxufan commented 2 years ago

For llvm's RISCV target, tail call is disabled if the stack is used for passing parameters. But it seems that if the stack offset of the parameter that passed by stack is consistent with the formal argument's stack offset, tail call optimization call be enabled. And ARM target does that. I am referencing arm's implementation to achieve this.