diff options
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 8304e2e..56cb2cc 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -713,6 +713,12 @@ void SCCP::visitLoadInst(LoadInst &I) { if (PtrVal.isUndefined()) return; // The pointer is not resolved yet! if (PtrVal.isConstant() && !I.isVolatile()) { Value *Ptr = PtrVal.getConstant(); + if (isa<ConstantPointerNull>(Ptr)) { + // load null -> null + markConstant(IV, &I, Constant::getNullValue(I.getType())); + return; + } + if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Ptr)) Ptr = CPR->getValue(); |