Subzero: Fix a potential null-pointer dereference.
BUG= none
R=jpp@chromium.org, manasijm@google.com
Review URL: https://codereview.chromium.org/2103613002 .
diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h
index 1dcb9a3..0cd2789 100644
--- a/src/IceTargetLoweringX86BaseImpl.h
+++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -5327,14 +5327,17 @@
}
} else if (VarDef->getOp() == InstArithmetic::Mul) {
SizeT PowerOfTwo = 0;
- ConstantInteger32 *MultConst =
- llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(0));
- if (llvm::isPowerOf2_32(MultConst->getValue())) {
- PowerOfTwo += MultConst->getValue();
+ if (auto *MultConst =
+ llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(0))) {
+ if (llvm::isPowerOf2_32(MultConst->getValue())) {
+ PowerOfTwo += MultConst->getValue();
+ }
}
- MultConst = llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(1));
- if (llvm::isPowerOf2_32(MultConst->getValue())) {
- PowerOfTwo += MultConst->getValue();
+ if (auto *MultConst =
+ llvm::dyn_cast<ConstantInteger32>(VarDef->getSrc(1))) {
+ if (llvm::isPowerOf2_32(MultConst->getValue())) {
+ PowerOfTwo += MultConst->getValue();
+ }
}
ZeroesAvailable = llvm::Log2_32(PowerOfTwo) + 1;
}