[llvm] 8da1ac9 - [llvm] Use std::tie to implement operator< (NFC) (#143728)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 11 12:50:30 PDT 2025
Author: Kazu Hirata
Date: 2025-06-11T12:50:27-07:00
New Revision: 8da1ac98efa0d315824a92d8b563299eccc3e0f1
URL: https://github.com/llvm/llvm-project/commit/8da1ac98efa0d315824a92d8b563299eccc3e0f1
DIFF: https://github.com/llvm/llvm-project/commit/8da1ac98efa0d315824a92d8b563299eccc3e0f1.diff
LOG: [llvm] Use std::tie to implement operator< (NFC) (#143728)
std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.
Added:
Modified:
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
index 24b03a058981a..89b20978c40e6 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
@@ -202,15 +202,9 @@ class RelocationValueRef {
IsStubThumb == Other.IsStubThumb;
}
inline bool operator<(const RelocationValueRef &Other) const {
- if (SectionID != Other.SectionID)
- return SectionID < Other.SectionID;
- if (Offset != Other.Offset)
- return Offset < Other.Offset;
- if (Addend != Other.Addend)
- return Addend < Other.Addend;
- if (IsStubThumb != Other.IsStubThumb)
- return IsStubThumb < Other.IsStubThumb;
- return SymbolName < Other.SymbolName;
+ return std::tie(SectionID, Offset, Addend, IsStubThumb, SymbolName) <
+ std::tie(Other.SectionID, Other.Offset, Other.Addend,
+ Other.IsStubThumb, Other.SymbolName);
}
};
diff --git a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
index f38e7b879e5f0..5dde47ab3de57 100644
--- a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
@@ -253,7 +253,7 @@ namespace {
bool operator!=(Register R) const { return !operator==(R); }
bool operator<(Register R) const {
// For std::map.
- return Reg < R.Reg || (Reg == R.Reg && Sub < R.Sub);
+ return std::tie(Reg, Sub) < std::tie(R.Reg, R.Sub);
}
llvm::Register Reg;
unsigned Sub = 0;
@@ -298,11 +298,7 @@ namespace {
return !operator==(Ex);
}
bool operator<(const ExtExpr &Ex) const {
- if (Rs != Ex.Rs)
- return Rs < Ex.Rs;
- if (S != Ex.S)
- return S < Ex.S;
- return !Neg && Ex.Neg;
+ return std::tie(Rs, S, Neg) < std::tie(Ex.Rs, Ex.S, Ex.Neg);
}
};
More information about the llvm-commits
mailing list