diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2020-05-29 12:25:27 +0100 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2020-05-29 12:25:43 +0100 |
commit | b9826c10866997a8869a7356a37aade759338b08 (patch) | |
tree | a67fc811976c33d256a741d47e315b468520454a /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 1f4ba66ecc877562e75059e32d4c95a67e1fd483 (diff) | |
download | llvm-b9826c10866997a8869a7356a37aade759338b08.zip llvm-b9826c10866997a8869a7356a37aade759338b08.tar.gz llvm-b9826c10866997a8869a7356a37aade759338b08.tar.bz2 |
[CGP] Ensure address scaled offset is representable as int64_t
AddressingModeMatcher::matchScaledValue was calling getSExtValue for a constant before ensuring that we can actually represent the value as int64_t
Fixes OSSFuzz#22723 which is a followup to rGc479052a74b2 (PR46004 / OSSFuzz#22357)
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index ee4b434..c22cf5f 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -3715,10 +3715,11 @@ bool AddressingModeMatcher::matchScaledValue(Value *ScaleReg, int64_t Scale, // X*Scale + C*Scale to addr mode. ConstantInt *CI = nullptr; Value *AddLHS = nullptr; if (isa<Instruction>(ScaleReg) && // not a constant expr. - match(ScaleReg, m_Add(m_Value(AddLHS), m_ConstantInt(CI)))) { + match(ScaleReg, m_Add(m_Value(AddLHS), m_ConstantInt(CI))) && + CI->getValue().isSignedIntN(64)) { TestAddrMode.InBounds = false; TestAddrMode.ScaledReg = AddLHS; - TestAddrMode.BaseOffs += CI->getSExtValue()*TestAddrMode.Scale; + TestAddrMode.BaseOffs += CI->getSExtValue() * TestAddrMode.Scale; // If this addressing mode is legal, commit it and remember that we folded // this instruction. |