ELFRelocationEntry::operator<(): Try to stabilize the order. r_offset was insufficien...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Wed, 15 May 2013 02:16:23 +0000 (02:16 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Wed, 15 May 2013 02:16:23 +0000 (02:16 +0000)
It should fix llvm/test/CodeGen/ARM/ehabi-mc-compact-pr*.ll on some hosts.

  RELOCATION RECORDS FOR [.ARM.exidx]:
  0 R_ARM_PREL31 .text
  0 R_ARM_NONE __aeabi_unwind_cpp_pr0

FIXME: I am not sure of the directions of extra comparators, in Type and Index.
For now, they are different from the direction in r_offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181864 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCELFObjectWriter.h

index a59776d5cdaac31656ebcd159e08bb6bbadbe489..65dd1e8998cc657474f0e89a7c2dca12de4302e5 100644 (file)
@@ -45,7 +45,14 @@ struct ELFRelocationEntry {
 
   // Support lexicographic sorting.
   bool operator<(const ELFRelocationEntry &RE) const {
-    return RE.r_offset < r_offset;
+    if (RE.r_offset != r_offset)
+      return RE.r_offset < r_offset;
+    if (Type != RE.Type)
+      return Type < RE.Type;
+    if (Index != RE.Index)
+      return Index < RE.Index;
+    llvm_unreachable("ELFRelocs might be unstable!");
+    return 0;
   }
 };