<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Return of structs in C calling convention is done on stack, incompatible with avr-gcc usually using registers"
href="https://bugs.llvm.org/show_bug.cgi?id=39251">39251</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Return of structs in C calling convention is done on stack, incompatible with avr-gcc usually using registers
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: AVR
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>me@dylanmckay.io
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=20989" name="attach_20989" title="the test C file I wrote containing structures of different sizes">attachment 20989</a> <a href="attachment.cgi?id=20989&action=edit" title="the test C file I wrote containing structures of different sizes">[details]</a></span>
the test C file I wrote containing structures of different sizes
The AVR-GCC documentation states that
| Return values with a size of 1 byte up to and including a size of
| 8 bytes will be returned in registers. Return values whose size
| is outside that range will be returned in memory.
<a href="https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention">https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention</a>
However, this does not seem to be the case when the return value is a struct.
>From experimental tests, I've seen that avr-gcc will return the struct via
registers if and only if the struct is less than or equal to four bytes in
size. Any struct with sizeof(self) > 5 will be returned on the stack with
AVR-GCC.
Currently, AVR-LLVM does not place ANY struct return values in registers. They
all go to the stack.
We need to modify the AVR backend so that it matches AVR-GCC's behaviour -
structures of four bytes or less should be assigned to registers, whereas
structures larger than this should be relegated to stack.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>