
The static chain parameter is a special parameter that is not passed in the usual argument registers or stack space. For example, in x64 System V ABI it is always passed in R10. Although the ABI of RISCV does not assign a register for this purpose, GCC had support for it on RISC-V a long time ago, and it is exposed via `__builtin_call_with_static_chain` intrinsic, and assign t2 for static chain parameters. This patch also chose t2 for compatibility. In LLVM, static chain parameters are handled by the `nest` attribute of an argument to a function ([D6332](https://reviews.llvm.org/D6332)), so tests are added to ensure `nest` arguments are handled correctly. Reviewed By: kito-cheng, MaskRay Differential Revision: https://reviews.llvm.org/D129106
14 lines
517 B
LLVM
14 lines
517 B
LLVM
; RUN: not --crash llc -mtriple=riscv64 -mattr=+f,+d -verify-machineinstrs -filetype=null < %s 2>&1 | FileCheck %s
|
|
; RUN: not --crash llc -mtriple=riscv32 -mattr=+f,+d -verify-machineinstrs -filetype=null < %s 2>&1 | FileCheck %s
|
|
|
|
define ghccc ptr @nest_receiver(ptr nest %arg) nounwind {
|
|
ret ptr %arg
|
|
}
|
|
|
|
define ghccc ptr @nest_caller(ptr %arg) nounwind {
|
|
%result = call ghccc ptr @nest_receiver(ptr nest %arg)
|
|
ret ptr %result
|
|
}
|
|
|
|
; CHECK: LLVM ERROR: Attribute 'nest' is not supported in GHC calling convention
|