[lld] r339083 - [ELF] Use MathExtras.h llvm::SignExtend64
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 6 16:50:26 PDT 2018
Author: maskray
Date: Mon Aug 6 16:50:26 2018
New Revision: 339083
URL: http://llvm.org/viewvc/llvm-project?rev=339083&view=rev
Log:
[ELF] Use MathExtras.h llvm::SignExtend64
Summary: To be consistent with other files where only SignExtend64 is used.
Reviewers: ruiu, espindola
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D50366
Modified:
lld/trunk/ELF/Target.h
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=339083&r1=339082&r2=339083&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Mon Aug 6 16:50:26 2018
@@ -13,6 +13,7 @@
#include "InputSection.h"
#include "lld/Common/ErrorHandler.h"
#include "llvm/Object/ELF.h"
+#include "llvm/Support/MathExtras.h"
namespace lld {
std::string toString(elf::RelType Type);
@@ -189,14 +190,9 @@ static inline void reportRangeError(uint
Twine(Max).str() + "]" + Hint);
}
-// Sign-extend Nth bit all the way to MSB.
-inline int64_t signExtend(uint64_t V, int N) {
- return int64_t(V << (64 - N)) >> (64 - N);
-}
-
// Make sure that V can be represented as an N bit signed integer.
inline void checkInt(uint8_t *Loc, int64_t V, int N, RelType Type) {
- if (V != signExtend(V, N))
+ if (V != llvm::SignExtend64(V, N))
reportRangeError(Loc, Type, Twine(V), llvm::minIntN(N), llvm::maxIntN(N));
}
@@ -210,7 +206,7 @@ inline void checkUInt(uint8_t *Loc, uint
inline void checkIntUInt(uint8_t *Loc, uint64_t V, int N, RelType Type) {
// For the error message we should cast V to a signed integer so that error
// messages show a small negative value rather than an extremely large one
- if (V != (uint64_t)signExtend(V, N) && (V >> N) != 0)
+ if (V != (uint64_t)llvm::SignExtend64(V, N) && (V >> N) != 0)
reportRangeError(Loc, Type, Twine((int64_t)V), llvm::minIntN(N),
llvm::maxIntN(N));
}
More information about the llvm-commits
mailing list