[LLVMdev] Exact meaning of byval

Matthijs Kooijman matthijs at stdin.nl
Thu Jul 10 01:48:04 PDT 2008


Hi All,

> > I'm particularly confused by the "between the caller and the callee" part. The
> > way I see this, the responsibility for the copying should be with either the
> > caller or the callee, not somewhere in between. In particular, I think byval
> > could either mean:
> > 	a) The callee is not allowed to modify the argument. If the original code
> > 	modifies the argument, the callee should make a copy and modify that
> > 	instead.
> > 	b) The caller will always pass in a copy of the object, which the callee is
> > 	free to modify and will be thrown away afterwards.
> >   
> Or it could mean:
> 
> c) Either a) or b) where the choice is determined by the target when 
> lowering calls and arguments. This allows the different targets to do 
> different things with this attribute to satisfy their ABI.
Any definitive comment on this one?

The main problem I see with option c), is that different languages want
different semantics, so it's not really target ABI dependent but language ABI
dependent. Which would require the frontend to explicitely add the copying,
because byval can't be reliably used for non-internal functions. Does that
make sense?

Also, I think that an implicit requirement of the byval attribute is that the
pointer it is attached to must always be valid. Ie, a load from it is
guaranteed to be valid (which is what argpromotion seems to assume). Not sure
if the current frontends fully comply with this, though...

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080710/7459f9af/attachment.sig>


More information about the llvm-dev mailing list