[llvm-commits] [llvm] r144731 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp

Eric Christopher echristo at apple.com
Tue Nov 15 15:37:17 PST 2011


Author: echristo
Date: Tue Nov 15 17:37:17 2011
New Revision: 144731

URL: http://llvm.org/viewvc/llvm-project?rev=144731&view=rev
Log:
Stabilize the output of the dwarf accelerator tables. Fixes a comparison
failure during bootstrap with it turned on.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp?rev=144731&r1=144730&r2=144731&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp Tue Nov 15 17:37:17 2011
@@ -60,7 +60,7 @@
   uniques.resize(Data.size());
   for (size_t i = 0, e = Data.size(); i < e; ++i)
     uniques[i] = Data[i]->HashValue;
-  std::sort(uniques.begin(), uniques.end());
+  std::stable_sort(uniques.begin(), uniques.end());
   std::vector<uint32_t>::iterator p =
     std::unique(uniques.begin(), uniques.end());
   uint32_t num = std::distance(uniques.begin(), p);
@@ -73,6 +73,15 @@
   Header.hashes_count = num;
 }
 
+namespace {
+  // DIESorter - comparison predicate that sorts DIEs by their offset.
+  struct DIESorter {
+    bool operator()(DIE *A, DIE *B) const {
+      return A->getOffset() < B->getOffset();
+    }
+  };
+}
+
 void DwarfAccelTable::FinalizeTable(AsmPrinter *Asm, const char *Prefix) {
   // Create the individual hash data outputs.
   for (StringMap<DIEArray>::iterator
@@ -80,7 +89,7 @@
     struct HashData *Entry = new HashData((*EI).getKeyData());
 
     // Unique the entries.
-    std::sort((*EI).second.begin(), (*EI).second.end());
+    std::stable_sort((*EI).second.begin(), (*EI).second.end(), DIESorter());
     (*EI).second.erase(std::unique((*EI).second.begin(), (*EI).second.end()),
                        (*EI).second.end());
 





More information about the llvm-commits mailing list