diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index eb40b291b0053..a6a8eaac2f943 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -611,7 +611,7 @@ Constant *Constant::replaceUndefsWith(Constant *C, Constant *Replacement) { SmallVector NewC(NumElts); for (unsigned i = 0; i != NumElts; ++i) { Constant *EltC = C->getAggregateElement(i); - assert(EltC->getType() == Replacement->getType() && + assert((!EltC || EltC->getType() == Replacement->getType()) && "Expected matching types"); NewC[i] = EltC && match(EltC, m_Undef()) ? Replacement : EltC; }