[cfe-dev] Passing structs byval
Chris Lattner
clattner at apple.com
Tue Apr 29 08:10:17 PDT 2008
On Apr 28, 2008, at 2:11 AM, Matthijs Kooijman wrote:
> I'm looking at the argpromotion optimizer pass in LLVM, but it
> doesn't seem to
> reliably work right now in combination with clang (didn't try with
> llvm-gcc).
Ok. Most optimization stuff has only been looked at with llvm-gcc.
> When passing a struct to a function, clang currently generates a
> call to
> memcpy and passes the pointer to the (temp copy of the) struct to the
> function. ArgPromotion can succesfully promote this struct argument
> (i.e.,
> replace it by multiple scalar arguments) but only if the called
> function does
> not modify the struct.
I don't think there is any specific reason for this, it is just what
was easiest to do at the time. We should follow llvm-gcc's lead and
generate byval.
> Any suggestions on how and where to implement this byval passing of
> structs?
> I'm still digging around in the source code, following call paths to
> see what
> actually happens right now :-)
CodeGen/CGExprAgg.cpp and friends is the most relevant. Thanks for
working on this!
-Chris
More information about the cfe-dev
mailing list