<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 - clang allocates a stack variable for each function call that returns a struct"
href="https://bugs.llvm.org/show_bug.cgi?id=34173">34173</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang allocates a stack variable for each function call that returns a struct
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>OpenBSD
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>release blocker
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mail@patrick-wildt.de
</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=18974" name="attach_18974" title="test case">attachment 18974</a> <a href="attachment.cgi?id=18974&action=edit" title="test case">[details]</a></span>
test case
When compiling the Linux Radeon KMS Driver with -Wframe-larger-than=2047 the
radeon_combios.c file cannot be compiled.
As it turns out, if you do
struct a b;
b = test();
b = test();
b = test();
b = test();
every call to test() will allocate space on the stack instead of reusing the
single allocation there should be. This can be seen in the LLVM IR as
%6 = alloca %struct.a, align 4
%7 = alloca %struct.a, align 4
%8 = alloca %struct.a, align 4
%9 = alloca %struct.a, align 4
%10 = alloca %struct.a, align 4
%11 = alloca %struct.a, align 4
...
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %35, i8* %36, i64 68, i32 4, i1
false)
call void @test(%struct.a* sret %9)
%37 = bitcast %struct.a* %6 to i8*
%38 = bitcast %struct.a* %9 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %37, i8* %38, i64 68, i32 4, i1
false)
call void @test(%struct.a* sret %10)
%39 = bitcast %struct.a* %6 to i8*
%40 = bitcast %struct.a* %10 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %39, i8* %40, i64 68, i32 4, i1
false)
call void @test(%struct.a* sret %11)
...
With clang 4.0.0 this issue does not exist.</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>