<div dir="ltr">This is a nit, but probably we should move the if statement to the very beginning of the function, so that we can save two function calls of file() if the two pointers are the same.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 31, 2015 at 9:06 PM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: davide<br>
Date: Sat Jan 31 23:06:45 2015<br>
New Revision: 227709<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227709&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227709&view=rev</a><br>
Log:<br>
[ELF] Don't compare an atom with itself in compareByPosition().<br>
<br>
This caused some tests to fail on FreeBSD, and Mac OS X.<br>
Some std::sort() implementations will check for strict-weak-ordering<br>
by comparing with the same element, or will compare an element to<br>
itself for 1-element sequence. Take care of this case. Thanks to<br>
chandlerc for explaning that to me.<br>
<br>
Reviewed by:    ruiu<br>
<br>
Modified:<br>
    lld/trunk/lib/Core/DefinedAtom.cpp<br>
<br>
Modified: lld/trunk/lib/Core/DefinedAtom.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=227709&r1=227708&r2=227709&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=227709&r1=227708&r2=227709&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Core/DefinedAtom.cpp (original)<br>
+++ lld/trunk/lib/Core/DefinedAtom.cpp Sat Jan 31 23:06:45 2015<br>
@@ -85,6 +85,10 @@ bool DefinedAtom::compareByPosition(cons<br>
                                     const DefinedAtom *rhs) {<br>
   const File *lhsFile = &lhs->file();<br>
   const File *rhsFile = &rhs->file();<br>
+<br>
+  if (lhs == rhs)<br>
+    return false;<br>
+<br>
   if (lhsFile->ordinal() != rhsFile->ordinal())<br>
     return lhsFile->ordinal() < rhsFile->ordinal();<br>
   assert(lhs->ordinal() != rhs->ordinal());<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>