<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 - Passing struct by value instead of const& results in linear stack bloat"
href="https://bugs.llvm.org/show_bug.cgi?id=40226">40226</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Passing struct by value instead of const& results in linear stack bloat
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>glider@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21293" name="attach_21293" title="A small repro">attachment 21293</a> <a href="attachment.cgi?id=21293&action=edit" title="A small repro">[details]</a></span>
A small repro
Vladislav Kuzkokov has reported the following problem with trunk LLVM (it also
appears to date back to at least LLVM 4.0.1).
When the attached program is compiled with -DBY_VALUE (which results in Struct
being passed by value, as opposed to passing a const reference) Clang allocates
extra stack space for each Struct instance in bar():
$ clang++ byval.cc -c -fno-exceptions -O2 -DBY_VALUE && objdump -Sr byval.o
...
0000000000000000 <_Z3barv>:
0: 53 push %rbx
1: 48 83 ec 20 sub $0x20,%rsp
5: 48 8d 5c 24 18 lea 0x18(%rsp),%rbx
a: 48 89 df mov %rbx,%rdi
...
$ clang++ byval.cc -c -fno-exceptions -O2 -UBY_VALUE && objdump -Sr byval.o
...
0000000000000000 <_Z3barv>:
0: 53 push %rbx
1: 48 83 ec 10 sub $0x10,%rsp
5: 48 8d 5c 24 08 lea 0x8(%rsp),%rbx
Looking at the IR, perhaps the lifetime intrinsics are missing?</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>