<html>
<head>
<base href="http://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 --- - AsmMatcherEmitter's ClassInfo comparator not transitive"
href="http://llvm.org/bugs/show_bug.cgi?id=17419">17419</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>AsmMatcherEmitter's ClassInfo comparator not transitive
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>normal
</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>willdtz@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Similar to the recent fix posted for the sorting predicate used in
DAGISelEmitter[1], the sorting predicate used in AsmMatcherEmitter for
ClassInfo objects is also non-transitive.
This results in unspecified sorting behavior and in particular
breaks tests relying on a particular match ordering
(possibly producing inferior assembly or other problems).
The comparison operator is in AsmMatcherEmitter.cpp:265.
Examples of lack of transitivity are:
class A subclass B, B.Kind < A.Kind.
when a class 'C' has a kind between B and A, this breaks:
A < B (A subclass B)
B < C (unrelated classes, B.Kind < C.Kind)
C < A (unrelated classes, C.Kind < A.Kind)
And a similar failure with ValueName causing the failure
instead of the Kind comparison.
I've seen both of these failures happen when emitting the AsmMatcher for X86,
I haven't tested other platforms. These were detected while debugging building
LLVM w/an alternative C++ implementation, with the following sanity check added
to std::sort():
--------------
for (_RandomAccessIterator cur = first; cur != last; ++cur)
for (_RandomAccessIterator before = first; before != cur; ++before)
assert((comp(*before, *cur) || !comp(*cur, *before)) &&
"Bad sort predicate");
--------------
Perhaps a preprocessing pass over the ClassInfo's that builds a numbering would
work? A postorder traversal of the class heirarchy should provide a reasonable
such numbering, I believe, and can use Kind/ValueName as we presently do to
break ties amongst children for output that's as deterministic as what we have
today.
Regardless if someone could take a look that'd be great. Thanks! :)
[1]
<a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130930/189318.html">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130930/189318.html</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>