[llvm] r328935 - [DebugInfo] Change std::sort to llvm::sort in response to r327219

Mandeep Singh Grang via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 1 09:18:49 PDT 2018


Author: mgrang
Date: Sun Apr  1 09:18:49 2018
New Revision: 328935

URL: http://llvm.org/viewvc/llvm-project?rev=328935&view=rev
Log:
[DebugInfo] Change std::sort to llvm::sort in response to r327219

Summary:
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.

Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort.
Refer the comments section in D44363 for a list of all the required patches.

Reviewers: echristo, zturner, samsonov

Reviewed By: echristo

Subscribers: JDevlieghere, llvm-commits

Differential Revision: https://reviews.llvm.org/D45134

Modified:
    llvm/trunk/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Modified: llvm/trunk/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp?rev=328935&r1=328934&r2=328935&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp Sun Apr  1 09:18:49 2018
@@ -79,7 +79,7 @@ Error DebugCrossModuleImportsSubsection:
   for (const auto &M : Mappings)
     Ids.push_back(&M);
 
-  std::sort(Ids.begin(), Ids.end(), [this](const T &L1, const T &L2) {
+  llvm::sort(Ids.begin(), Ids.end(), [this](const T &L1, const T &L2) {
     return Strings.getIdForString(L1->getKey()) <
            Strings.getIdForString(L2->getKey());
   });

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=328935&r1=328934&r2=328935&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Sun Apr  1 09:18:49 2018
@@ -108,12 +108,12 @@ collectContributionData(DWARFContext::cu
   // Sort the contributions so that any invalid ones are placed at
   // the start of the contributions vector. This way they are reported
   // first.
-  std::sort(Contributions.begin(), Contributions.end(),
-            [](const Optional<StrOffsetsContributionDescriptor> &L,
-               const Optional<StrOffsetsContributionDescriptor> &R) {
-              if (L && R) return L->Base < R->Base;
-              return R.hasValue();
-            });
+  llvm::sort(Contributions.begin(), Contributions.end(),
+             [](const Optional<StrOffsetsContributionDescriptor> &L,
+                const Optional<StrOffsetsContributionDescriptor> &R) {
+               if (L && R) return L->Base < R->Base;
+               return R.hasValue();
+             });
 
   // Uniquify contributions, as it is possible that units (specifically
   // type units in dwo or dwp files) share contributions. We don't want

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp?rev=328935&r1=328934&r2=328935&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp Sun Apr  1 09:18:49 2018
@@ -80,7 +80,7 @@ void DWARFDebugAranges::appendRange(uint
 void DWARFDebugAranges::construct() {
   std::multiset<uint32_t> ValidCUs;  // Maintain the set of CUs describing
                                      // a current address range.
-  std::sort(Endpoints.begin(), Endpoints.end());
+  llvm::sort(Endpoints.begin(), Endpoints.end());
   uint64_t PrevAddress = -1ULL;
   for (const auto &E : Endpoints) {
     if (PrevAddress < E.Address && !ValidCUs.empty()) {

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=328935&r1=328934&r2=328935&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Sun Apr  1 09:18:49 2018
@@ -835,7 +835,7 @@ bool DWARFDebugLine::LineTable::parse(DW
 
   // Sort all sequences so that address lookup will work faster.
   if (!Sequences.empty()) {
-    std::sort(Sequences.begin(), Sequences.end(), Sequence::orderByLowPC);
+    llvm::sort(Sequences.begin(), Sequences.end(), Sequence::orderByLowPC);
     // Note: actually, instruction address ranges of sequences should not
     // overlap (in shared objects and executables). If they do, the address
     // lookup would still work, though, but result would be ambiguous.




More information about the llvm-commits mailing list