[clang] [llvm] [Clang][BPF] Allow sign extension for int type call parameters (PR #84874)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 12 10:56:40 PDT 2024


efriedma-quic wrote:

The way LLVM backend works in general is that if an integer is smaller than a register, when type legalization converts that to a larger integer, the high bits are undefined.  This generally doesn't cause any issues because nothing can actually observe those bits.  Your analysis that concludes "int" is special is probably wrong; I think you're just getting lucky with heuristics for lowering constants.

Some backends explicitly zero-extend or sign-extend function arguments to match ABI conventions, at least in some cases.  The BPF backend is one of those backends: BPFTargetLowering::LowerCall will sign-extend arguments marked "signext".

Sign-extending 32-bit integers is a choice you can make, I guess, but if you're not trying to conform to an external ABI specification, it doesn't really solve anything.

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


More information about the cfe-commits mailing list