Commit d615c861 by Jim Stichnoth

Subzero: Fix a potential null-pointer dereference.

BUG= none R=jpp@chromium.org, manasijm@google.com Review URL: https://codereview.chromium.org/2103613002 .
parent fe2caab8
...@@ -5327,15 +5327,18 @@ const Inst *AddressOptimizer::matchOffsetIndexOrBase( ...@@ -5327,15 +5327,18 @@ const Inst *AddressOptimizer::matchOffsetIndexOrBase(
} }
} else if (VarDef->getOp() == InstArithmetic::Mul) { } else if (VarDef->getOp() == InstArithmetic::Mul) {
SizeT PowerOfTwo = 0; SizeT PowerOfTwo = 0;
ConstantInteger32 *MultConst = if (auto *MultConst =
llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(0)); llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(0))) {
if (llvm::isPowerOf2_32(MultConst->getValue())) { if (llvm::isPowerOf2_32(MultConst->getValue())) {
PowerOfTwo += MultConst->getValue(); PowerOfTwo += MultConst->getValue();
} }
MultConst = llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(1)); }
if (auto *MultConst =
llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(1))) {
if (llvm::isPowerOf2_32(MultConst->getValue())) { if (llvm::isPowerOf2_32(MultConst->getValue())) {
PowerOfTwo += MultConst->getValue(); PowerOfTwo += MultConst->getValue();
} }
}
ZeroesAvailable = llvm::Log2_32(PowerOfTwo) + 1; ZeroesAvailable = llvm::Log2_32(PowerOfTwo) + 1;
} }
SizeT ZeroesNeeded = llvm::Log2_32(Const->getValue()) + 1; SizeT ZeroesNeeded = llvm::Log2_32(Const->getValue()) + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment