[LLVMdev] comments on Bug 1521 (Revamp LLVM by-value structure passing)

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jun 26 09:57:21 PDT 2007


> > 2) add a "byref" mark in the pointer argument.
>
> I think you mean "bycopy" or "byval" here.
Yes, good catch.

> > 3) Have llvm-gcc create a copy before calling the function.
>
> Don't forget that the function may be called by code that
> was not compiled by LLVM.  That's why we have to pay attention
> to the ABI!  Solution (3) supposes we have control over both
> callers and callees, but we need to handle the situation in
> which we are calling code compiled by a different compiler,
> or code compiled by a different compiler is calling us.

I now noticed that I done a similar mistake as the current
implementation. I have assumed that passing a structure with an
implicit pointer is equivalent as passing it with an explicit one.
That is not the case. In x86_64 for example, the explicit pointer is
passed on rdi, and the implicit one is computed directly from the
stack pointer.

I would like to hide as much of the ABI  form llvm as possible, but
that would be a much bigger change then I thought.

So, I think that the only question left before I try to implement
Chris's solution is why it is better to have a "byval" attribute
instead of adding support for struct in arguments? That is, why

define void @f(%struct.cpp_num* %num byval)

is better then

define void @f(%struct cpp_num %num)

Just curious :-)

> Ciao,
>
> Duncan.
>

Thanks a lot,
Rafael



More information about the llvm-dev mailing list