mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-10 22:43:53 +00:00
![Mandeep Singh Grang](/assets/img/avatar_default.png)
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: JDevlieghere, zturner, echristo, dberris, friss Reviewed By: echristo Subscribers: gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D45141 llvm-svn: 328943
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
//===- NonRelocatableStringpool.cpp - A simple stringpool ----------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "NonRelocatableStringpool.h"
|
|
|
|
namespace llvm {
|
|
namespace dsymutil {
|
|
|
|
DwarfStringPoolEntryRef NonRelocatableStringpool::getEntry(StringRef S) {
|
|
if (S.empty() && !Strings.empty())
|
|
return EmptyString;
|
|
|
|
auto I = Strings.insert({S, DwarfStringPoolEntry()});
|
|
auto &Entry = I.first->second;
|
|
if (I.second || Entry.Index == -1U) {
|
|
Entry.Index = NumEntries++;
|
|
Entry.Offset = CurrentEndOffset;
|
|
Entry.Symbol = nullptr;
|
|
CurrentEndOffset += S.size() + 1;
|
|
}
|
|
return DwarfStringPoolEntryRef(*I.first);
|
|
}
|
|
|
|
StringRef NonRelocatableStringpool::internString(StringRef S) {
|
|
DwarfStringPoolEntry Entry{nullptr, 0, -1U};
|
|
auto InsertResult = Strings.insert({S, Entry});
|
|
return InsertResult.first->getKey();
|
|
}
|
|
|
|
std::vector<DwarfStringPoolEntryRef>
|
|
NonRelocatableStringpool::getEntries() const {
|
|
std::vector<DwarfStringPoolEntryRef> Result;
|
|
Result.reserve(Strings.size());
|
|
for (const auto &E : Strings)
|
|
Result.emplace_back(E);
|
|
llvm::sort(
|
|
Result.begin(), Result.end(),
|
|
[](const DwarfStringPoolEntryRef A, const DwarfStringPoolEntryRef B) {
|
|
return A.getIndex() < B.getIndex();
|
|
});
|
|
return Result;
|
|
}
|
|
|
|
} // namespace dsymutil
|
|
} // namespace llvm
|