<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri, sans-serif" size="2">
<div>Hello, I am seeking a clarification of the semantics of ‘byval’ parameter attribute in llvm IR.</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>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.</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>But given the following simple test case, </div>
<div><font face="Times New Roman, serif"> </font></div>
<div>typedef struct {</div>
<div> int a;</div>
<div> int b[1000];</div>
<div>} A;</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>void bar(A s) {</div>
<div> s.a = 1;</div>
<div>}</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>void foo(void) {</div>
<div> A s;</div>
<div> s.a = 100;</div>
<div> bar(s);</div>
<div>}</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>I see ‘clang’ generates an extra copy in foo() and the parameter for bar() also has the ‘byval’ attribute.</div>
<div> </div>
<div>Running the generated bc file through various backends , I see different behaviors,</div>
<div>- x86 and ppc32 create yet another copy on the caller site, while</div>
<div>- arm, sparc, and mips do not. </div>
<div><font face="Times New Roman, serif"> </font></div>
<div>What am I missing? Thanks.</div>
<div> </div>
<div>-- Yuan</div>
<div> </div>
<div><font face="Times New Roman, serif"> </font></div>
<div><font face="Times New Roman, serif"> </font></div>
</font>
<DIV>
<HR>
</DIV>
<DIV>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. </DIV>
<DIV>
<HR>
</DIV>
<P></P>
</body>
</html>