OSDN Git Service
(root)
/
android-x86
/
external-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b670311
)
[RISCV] Avoid signed integer overflow UB in RISCVMatInt::generateInstSeq
author
Alex Bradbury
<asb@lowrisc.org>
Thu, 18 Jul 2019 04:02:58 +0000
(
04:02
+0000)
committer
Alex Bradbury
<asb@lowrisc.org>
Thu, 18 Jul 2019 04:02:58 +0000
(
04:02
+0000)
Found by UBSan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366398
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/Target/RISCV/Utils/RISCVMatInt.cpp
patch
|
blob
|
history
diff --git
a/lib/Target/RISCV/Utils/RISCVMatInt.cpp
b/lib/Target/RISCV/Utils/RISCVMatInt.cpp
index
2504df5
..
f390ddb
100644
(file)
--- a/
lib/Target/RISCV/Utils/RISCVMatInt.cpp
+++ b/
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);