[clang] [llvm] [Clang][BPF] Allow sign/zero extension for call parameters with int/uint types (PR #84874)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 17:43:03 PDT 2024


efriedma-quic wrote:

> My understanding is that you refer to the following part of the [specification](https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf):

Yes.  For example, on RISC-V, the function `long f(unsigned g) { return (int)g; }` compiles to just a "ret".

> clang would now guarantee sign or zero extension for all integral function parameters.

clang would guarantee sign-extension for signed parameters, and zero-extension for unsigned parameters. Which is not the same as the RISCV ABI rules.

> That is, we will do zero extension for uint argument here. This will guarantee correct value if 'foo' is a kernel function.

A kernel function will expect the uint to be sign-extended, not zero-extended.

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


More information about the cfe-commits mailing list