[PATCH] D18004: [ELF] - refactor of SymbolBody::compare()
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 10:54:22 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263144: [ELF] - Refactor of SymbolBody::compare() (authored by grimar).
Changed prior to commit:
http://reviews.llvm.org/D18004?vs=50249&id=50309#toc
Repository:
rL LLVM
http://reviews.llvm.org/D18004
Files:
lld/trunk/ELF/Symbols.cpp
Index: lld/trunk/ELF/Symbols.cpp
===================================================================
--- lld/trunk/ELF/Symbols.cpp
+++ lld/trunk/ELF/Symbols.cpp
@@ -106,10 +106,17 @@
return std::min(VA, VB);
}
+static int compareCommons(DefinedCommon *A, DefinedCommon *B) {
+ A->MaxAlignment = B->MaxAlignment =
+ std::max(A->MaxAlignment, B->MaxAlignment);
+ if (A->Size < B->Size)
+ return -1;
+ return 1;
+}
+
// Returns 1, 0 or -1 if this symbol should take precedence
// over the Other, tie or lose, respectively.
template <class ELFT> int SymbolBody::compare(SymbolBody *Other) {
- typedef typename ELFFile<ELFT>::uintX_t uintX_t;
assert(!isLazy() && !Other->isLazy());
std::tuple<bool, bool, bool> L(isDefined(), !isShared(), !isWeak());
std::tuple<bool, bool, bool> R(Other->isDefined(), !Other->isShared(),
@@ -134,24 +141,14 @@
if (L != R)
return -1;
- if (!std::get<0>(L) || !std::get<1>(L) || !std::get<2>(L))
- return 1;
- if (isCommon()) {
- if (!Other->isCommon())
- return -1;
- auto *ThisC = cast<DefinedCommon>(this);
- auto *OtherC = cast<DefinedCommon>(Other);
- uintX_t Align = std::max(ThisC->MaxAlignment, OtherC->MaxAlignment);
- if (ThisC->Size >= OtherC->Size) {
- ThisC->MaxAlignment = Align;
- return 1;
- }
- OtherC->MaxAlignment = Align;
- return -1;
- }
- if (Other->isCommon())
+ if (!isDefined() || isShared() || isWeak())
return 1;
- return 0;
+ if (!isCommon() && !Other->isCommon())
+ return 0;
+ if (isCommon() && Other->isCommon())
+ return compareCommons(cast<DefinedCommon>(this),
+ cast<DefinedCommon>(Other));
+ return isCommon() ? -1 : 1;
}
Defined::Defined(Kind K, StringRef Name, bool IsWeak, uint8_t Visibility,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18004.50309.patch
Type: text/x-patch
Size: 1790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160310/cf2f20de/attachment.bin>
More information about the llvm-commits
mailing list