[LLVMdev] Info on byval attributes

Duncan Sands baldrick at free.fr
Sun May 13 06:00:52 PDT 2012


Hi Santosh,

> I was wondering if the program would still be safe if I strip the
> byval attributes from the parameters in the entire bitcode.

no.  For example, any writes performed by the callee to the byval
argument can't be seen by the caller when the call returns, but that
would no longer be true if you drop byval.

> LLVM language reference manual states that "The attribute implies that
> a hidden copy of the pointee is made between the caller and the
> callee, so the callee is unable to modify the value in the callee.
> This attribute is only valid on LLVM pointer arguments."
>
> Is there a way I can avoid the byval attribute by a custom
> transformation? I was thinking of a custom transformation that
> introduces an alloca and maintains the hidden copy of the pointee?

This would change the ABI so is only possible if the function is not externally
visible (has internal linkage and does not have its address taken).

Ciao, Duncan.



More information about the llvm-dev mailing list