<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 - IfConversion creating bad CFG when merging triangle"
href="https://bugs.llvm.org/show_bug.cgi?id=32721">32721</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>IfConversion creating bad CFG when merging triangle
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>mikael.holmen@ericsson.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=18319" name="attach_18319" title="Reproducer">attachment 18319</a> <a href="attachment.cgi?id=18319&action=edit" title="Reproducer">[details]</a></span>
Reproducer
Repriduce with
llc -mtriple thumbv7-apple-ios ifcvt_triangle_false_return.mir
-run-pass=if-converter -o - -debug
This yields
bb.0:
successors: %bb.1(0x80000000)
bb.1:
successors: %bb.2(0x40000000), %bb.1(0x00000000)
BX_RET 14, _, implicit killed %r0
bb.2:
Looking at bb.1, we have a single unconditional return, but bb.1 still has two
successors? This seems wrong to me.
The situation occurs since BX_RET is a return instruction that ARM's
analyzeBranch
implementation returns true for so the IfConversion call to
RemoveExtraEdges(BBI)
won't do anything, and thus leave the CFG is a bad state.
There are some calls to removeSuccessor() here and there in IfConversion.cpp:
// RemoveExtraEdges won't work if the block has an unanalyzable branch, so
// explicitly remove CvtBBI as a successor.
BBI.BB->removeSuccessor(&CvtMBB, true);
but none of them catch this case.
(Originally found when compiling for my out-of-tree backend, so I created a MIR
test case and modified it to expose the problem also on ARM.)</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>