[LLVMdev] Question about 'byval'

Yuan Lin yulin at nvidia.com
Fri Sep 10 16:24:22 PDT 2010


Hello, I am seeking a clarification of the semantics of 'byval' parameter attribute in llvm IR.

Let's assume the ABI says the caller should create the 'hidden copy' of the pointee. My question is which part of the compiler chain should generate the alloca and copy code. My understanding is that it is the target code generator, not the provider of the llvm IR.

But given the following simple test case,

typedef struct {
    int a;
    int b[1000];
} A;

void bar(A s) {
    s.a = 1;
}

void foo(void) {
    A s;
    s.a = 100;
    bar(s);
}

I see 'clang' generates an extra copy in foo() and the parameter for bar() also has the 'byval' attribute.

Running the generated bc file through various backends , I see different behaviors,
- x86 and ppc32 create yet another copy on the caller site, while
- arm, sparc, and mips do not.

What am I missing? Thanks.

-- Yuan




-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100910/30c0ed22/attachment.html>


More information about the llvm-dev mailing list