[LLVMdev] struct as a function argument
Zvonimir Rakamaric
zrakamar at gmail.com
Tue Oct 2 19:25:23 PDT 2007
Thanks Chris!
Your suggestion helps....
-- Zvonimir
On 10/2/07, Chris Lattner <sabre at nondot.org> wrote:
> On Oct 2, 2007, at 1:03 AM, Domagoj Babic wrote:
> > Hi all,
> >
> > I have the same problem. My guess is that when a structure
> > is passed as a parameter, you cast it into an array for optimization
> > reasons (less parameters, less stack space).
>
> This is not an optimization. This behavior is to be ABI complaint
> when emitting code for your OS.
>
> That said, this is not a very good way to do this. Rafael is working
> on adding the 'byref' attribute which will support this much more
> gracefully in the future.
>
> > This is, certainly, a reasonable optimization, but makes
> > inter-procedural static analysis more complex. Is there a way to
> > disable it (my guess is that this should be doable by passing
> > some parameter to llvm-gcc)?
>
> The easiest way to disable this is to hack it out of llvm-gcc.
> Change this (gcc/llvm-abi.h):
>
> #ifndef LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS
> #define LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(X) \
> !isSingleElementStructOrArray(type)
> #endif
>
> to:
>
> #undef LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS
> #define LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(X) 0
>
> Note that you won't be able to mix and match .o files with GCC where
> structs are passed by value.
>
> -Chris
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list