[llvm-dev] Difference between "byval" and actually passing by value?

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 23 01:06:33 PDT 2018


On 22 April 2018 at 15:29, edA-qa mort-ora-y <eda-qa at disemia.com> wrote:
> If I understood correctly, when llvm sees a struct like `foo = { i8,
> i64, float }` and then a function like `bar( %foo )` it is the same as
> the function `bar( i8, i64, float )`?  Is the call guaranteed to be byte
> compatible, or should I not rely on it (I don't of course).

I don't think it's really a guarantee, just an implementation detail.
I would always use functions with self-consistent prototypes.

> What is the reason that `byval` requires a pointer type, as opposed to
> being able to take a value type?

Non-pointers are intrinsically passed by value. I can see there might
be a use for an "align" tag there too, but no-one has proposed or
implemented it.

Cheers.

Tim.


More information about the llvm-dev mailing list