<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 - The pruneeh pass seems to incorrectly add the nounwind attribute"
href="https://bugs.llvm.org/show_bug.cgi?id=36513">36513</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The pruneeh pass seems to incorrectly add the nounwind attribute
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>benoit.vey@etu.upmc.fr
</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=19953" name="attach_19953" title="IR and assembly files demonstrating the bug">attachment 19953</a> <a href="attachment.cgi?id=19953&action=edit" title="IR and assembly files demonstrating the bug">[details]</a></span>
IR and assembly files demonstrating the bug
The attachment is an archive containing an IR file and an x86 assembly file
demonstrating the bug.
In the IR file, there are two almost identical functions. `with_nounwind` is
marked `nounwind`, `without_nounwind` isn't. If you run
opt -pruneeh -S nounwind.ll
you'll observe that `without_nounwind` has been marked `nounwind`, making it
identical to `with_nounwind`.
The x86 assembly file is the result of the following command (the input is the
original file, not the output of the above command):
llc -o nounwind.s nounwind.ll
In the resulting assembly code for `with_nounwind`, it seems that the landing
pad isn't generated correctly. In particular, take a look at the following
parts of the code:
>From `without_nounwind`
.LBB0_1: # %throw
.Ltmp0:
callq throw_exception
.Ltmp1:
# BB#2: # %unreachable
.LBB0_3: # %landing
.Ltmp2:
popq %rax
retq
...
.long .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1
.long .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
And from `with_nounwind`
.LBB1_1: # %throw
pushq %rax
.Ltmp3:
callq throw_exception
.Ltmp4:
addq $8, %rsp
# BB#2: # %unreachable
.LBB1_3: # %landing
.Ltmp5:
retq
...
.long .Ltmp4-.Ltmp3 # Call between .Ltmp3 and .Ltmp4
.long .Ltmp5-.Lfunc_begin1 # jumps to .Ltmp5
As you can see, in `without_nounwind`, the landing pad is correctly setup so
that the stack space used for spilling is cleaned up in both the throwing and
the non-throwing cases. In `with_nounwind`, the landing pad is setup right
before the return instruction and the throwing case doesn't cleanup the stack.
At runtime, this results in a segmentation fault. I can provide the code for
`throw_exception` and `my_personality` in case anyone wants to try running the
code.
I'm not sure whether it is pruneeh that is incorrectly adding the `nounwind`
attribute or it is the machine code generation that doesn't handle `nounwind`
functions correctly so I included details for both parts.
This bug was originally found through a bug report to the Pony compiler. See
the following link for the full details:
<a href="https://github.com/ponylang/ponyc/issues/1186">https://github.com/ponylang/ponyc/issues/1186</a></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>