diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 371500bc786..cdf7b76dd08 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -2444,7 +2444,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal, Constant *Val = getVal(Values, MSI->getValue()); Constant *DestVal = ComputeLoadResult(getVal(Values, Ptr), MutatedMemory); - if (Val->isNullValue() && DestVal->isNullValue()) { + if (Val->isNullValue() && DestVal && DestVal->isNullValue()) { // This memset is a no-op. ++CurInst; continue;