<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 - [IPRA] wrong code"
href="https://bugs.llvm.org/show_bug.cgi?id=36587">36587</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[IPRA] wrong code
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</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>Register Allocator
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>paulsson@linux.vnet.ibm.com
</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=19992" name="attach_19992" title="reduced testcase">attachment 19992</a> <a href="attachment.cgi?id=19992&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase
It seems that enabling interprocedural register allocation with (reduced)
csmith program gives wrong code:
bin/llc -mtriple=s390x-linux-gnu -mcpu=z13 tc_ipra_reduced.ll -o tc.s
-enable-ipra
bin/clang -O3 -march=z13 tc.s -o a.out -w; ./a.out
checksum = 0
bin/llc -mtriple=s390x-linux-gnu -mcpu=z13 tc_ipra_reduced.ll -o tc.s
bin/clang -O3 -march=z13 tc.s -o a.out -w; ./a.out
checksum = 5
(checksum = 5 also with gcc -O0 and more)
At first glance, it seems that while fn2() actually uses %r0 (which is caller
saved), ipra (right) seems to result in %r0 being live accross the call to
fn2():
IPRA
lgrl %r0, q | llihl %r0, 0
lgrl %r1, o | stgrl %r1, n
larl %r13, a | stg %r1, 0(%r2)
lhi %r12, 0 <
stgrl %r0, n <
stg %r0, 0(%r1) <
brasl %r14, fn2@PL brasl %r14, fn2@PL
larl %r1, f larl %r1, f
chsi 0(%r1), 7 chsi 0(%r1), 7
lgrl %r1, m lgrl %r1, m
lochie %r12, 1 | lochhie %r0, 1
st %r12, 0(%r1) | stfh %r0, 0(%r1)
To the left, %r12 is used by first setting it to 0, then after fn2()
conditionally set it to 1, and then store it to @m.
To the right, %r0 is used the exact same way, which is incorrect since fn2()
changes its value.</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>