diff options
author | Alex Bradbury <asb@lowrisc.org> | 2019-07-18 04:02:58 +0000 |
---|---|---|
committer | Alex Bradbury <asb@lowrisc.org> | 2019-07-18 04:02:58 +0000 |
commit | 8aba95d64cf315d45b5d2faf2c809b7bd7f4e8e7 (patch) | |
tree | ba39f320d311ef4e423ad67ecede9ef7237e936b /llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp | |
parent | ad73a436dc3bd9a6da0645872b3e9efe95e45e71 (diff) | |
download | bcm5719-llvm-8aba95d64cf315d45b5d2faf2c809b7bd7f4e8e7.tar.gz bcm5719-llvm-8aba95d64cf315d45b5d2faf2c809b7bd7f4e8e7.zip |
[RISCV] Avoid signed integer overflow UB in RISCVMatInt::generateInstSeq
Found by UBSan.
llvm-svn: 366398
Diffstat (limited to 'llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp')
-rw-r--r-- | llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp b/llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp index 2504df5ef9b..f390ddb89e3 100644 --- a/llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp +++ b/llvm/lib/Target/RISCV/Utils/RISCVMatInt.cpp @@ -64,7 +64,7 @@ void generateInstSeq(int64_t Val, bool IsRV64, InstSeq &Res) { // performed when the recursion returns. int64_t Lo12 = SignExtend64<12>(Val); - int64_t Hi52 = (Val + 0x800) >> 12; + int64_t Hi52 = ((uint64_t)Val + 0x800ull) >> 12; int ShiftAmount = 12 + findFirstSet((uint64_t)Hi52); Hi52 = SignExtend64(Hi52 >> (ShiftAmount - 12), 64 - ShiftAmount); |