IT lexicon › Programming › byval

byval

Programming På svenska → Updated: 2026-11-07

The LLVM attribute declaring that a pointer parameter is really a struct passed by value — a hidden copy goes into the call's argument area on the stack.

LLVM IR has no idea how C passes a struct; that's the ABI's business, and every platform does it differently. So the frontend has to classify each argument itself and spell the outcome out in IR. Small structs are split into registers; large ones on x86-64 System V go to memory and are marked byval, telling the backend to copy them to the right stack slot. The return-value counterpart is sret.

The upshot is that Clang, rustc, Swift and every other frontend that wants to talk to C carries its own copy of the same classification rules. When two of them disagree about a struct, you get FFI bugs where every argument after the bad one arrives shifted — with no warning anywhere.

← Back to the lexicon