<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - X86 cc11 tail calls can clobber the return address when adjusting the stack pointer"
href="https://llvm.org/bugs/show_bug.cgi?id=28124">28124</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>X86 cc11 tail calls can clobber the return address when adjusting the stack pointer
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>margnus1@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16536" name="attach_16536" title="Reproduces the bug on x86, segfaulting">attachment 16536</a> <a href="attachment.cgi?id=16536&action=edit" title="Reproduces the bug on x86, segfaulting">[details]</a></span>
Reproduces the bug on x86, segfaulting
Hi! I have, while working on bringing the LLVM backend of the HiPE optional
machine code compiler for the Erlang language up to date with the latest
changes to LLVM, discovered a miscompilation bug in LLVM, present in 3.8 as
well as current trunk.
In 3.7 and before, the tail call seqeunce generated is the following
addl $4, %esp
jmp tailcallee # TAILCALL
However, starting with 3.8, the following is generated instead
popl %edi
popl %edi
pushl %eax
jmp tailcallee # TAILCALL
Which clobbers the return address with undefined junk from $eax.
Please see the tail-clobber.ll attachment for a hand-written stand-alone
reproduction case for x86. It is supposed to be compiled with -tailcallopt
-stack-alignment=4
The bug can also be reproduced on x86_64, but due to pure luck, $rax is chosen
as the scratch registers for both pops and pushes, and so manages to not crash.
I have bisected the problem to revision r237977, as well as written a patch,
which I intend to submit for review shortly.</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>