[lld] r211825 - Add utility to SimpleDefinedAtom to sort references
Nick Kledzik
kledzik at apple.com
Thu Jun 26 17:30:32 PDT 2014
Author: kledzik
Date: Thu Jun 26 19:30:31 2014
New Revision: 211825
URL: http://llvm.org/viewvc/llvm-project?rev=211825&view=rev
Log:
Add utility to SimpleDefinedAtom to sort references
Modified:
lld/trunk/include/lld/Core/Simple.h
Modified: lld/trunk/include/lld/Core/Simple.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Simple.h?rev=211825&r1=211824&r2=211825&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Simple.h (original)
+++ lld/trunk/include/lld/Core/Simple.h Thu Jun 26 19:30:31 2014
@@ -171,12 +171,27 @@ public:
_references.push_back(SimpleReference(ns, arch, kindValue, off, target, a));
}
+ /// Sort references in a canonical order (by offset, then by kind).
+ void sortReferences() const {
+ std::sort(_references.begin(), _references.end(),
+ [] (SimpleReference &lhs, SimpleReference &rhs) -> bool {
+ uint64_t lhsOffset = lhs.offsetInAtom();
+ uint64_t rhsOffset = rhs.offsetInAtom();
+ if (rhsOffset != lhsOffset)
+ return (lhsOffset < rhsOffset);
+ if (rhs.kindNamespace() != lhs.kindNamespace())
+ return (lhs.kindNamespace() < rhs.kindNamespace());
+ if (rhs.kindArch() != lhs.kindArch())
+ return (lhs.kindArch() < rhs.kindArch());
+ return (lhs.kindValue() < rhs.kindValue());
+ });
+ }
void setOrdinal(uint64_t ord) { _ordinal = ord; }
private:
const File &_file;
uint64_t _ordinal;
- std::vector<SimpleReference> _references;
+ mutable std::vector<SimpleReference> _references;
};
class SimpleUndefinedAtom : public UndefinedAtom {
More information about the llvm-commits
mailing list