Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -1309,6 +1309,8 @@ if (StoreBB == DestBB || OtherBB == DestBB) return false; + assert(OtherBB && "BasicBlock needs to be not NULL"); + // Verify that the other block ends in a branch and is not otherwise empty. BasicBlock::iterator BBI(OtherBB->getTerminator()); BranchInst *OtherBr = dyn_cast(BBI); Index: lib/Transforms/Scalar/ConstantHoisting.cpp =================================================================== --- lib/Transforms/Scalar/ConstantHoisting.cpp +++ lib/Transforms/Scalar/ConstantHoisting.cpp @@ -240,6 +240,7 @@ Instruction *ConstantHoisting:: findConstantInsertionPoint(const ConstantInfo &ConstInfo) const { assert(!ConstInfo.RebasedConstants.empty() && "Invalid constant info entry."); + assert(Entry && "Entry basic block cannot be NULL"); // Collect all basic blocks. SmallPtrSet BBs; for (auto const &RCI : ConstInfo.RebasedConstants) Index: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp =================================================================== --- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1007,6 +1007,7 @@ auto *BaseIE = cast(State.getBase()); auto *BdvIE = cast(BDV); auto UpdateOperand = [&](int OperandIdx) { + assert(BaseIE && "base InsertElementInst must not be NULL"); Value *InVal = BdvIE->getOperand(OperandIdx); Value *Base = getBaseForInput(InVal, BaseIE); BaseIE->setOperand(OperandIdx, Base); Index: lib/Transforms/Scalar/ScalarReplAggregates.cpp =================================================================== --- lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1986,6 +1986,7 @@ /// and recursively continue updating all of its uses. void SROA::RewriteBitCast(BitCastInst *BC, AllocaInst *AI, uint64_t Offset, SmallVectorImpl &NewElts) { + assert((BC && AI) && "BitCast and Alloca cannot be null" ); RewriteForScalarRepl(BC, AI, Offset, NewElts); if (BC->getOperand(0) != AI) return; Index: lib/Transforms/Scalar/StructurizeCFG.cpp =================================================================== --- lib/Transforms/Scalar/StructurizeCFG.cpp +++ lib/Transforms/Scalar/StructurizeCFG.cpp @@ -719,6 +719,8 @@ /// \brief Create a new or reuse the previous node as flow node BasicBlock *StructurizeCFG::needPrefix(bool NeedEmpty) { + assert(PrevNode && "cannot reuse null PrevNode as flow node"); + BasicBlock *Entry = PrevNode->getEntry(); if (!PrevNode->isSubRegion()) { Index: lib/Transforms/Scalar/TailRecursionElimination.cpp =================================================================== --- lib/Transforms/Scalar/TailRecursionElimination.cpp +++ lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -590,6 +590,7 @@ if (CI->isTailCall() && CannotTailCallElimCallsMarkedTail) return nullptr; + assert(F && "BasicBlock parent did not have an enclosing method"); // As a special case, detect code like this: // double fabs(double f) { return __builtin_fabs(f); } // a 'fabs' call // and disable this xform in this case, because the code generator will Index: lib/Transforms/Vectorize/SLPVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/SLPVectorizer.cpp +++ lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2818,6 +2818,7 @@ // instructions into different buckets based on the insert lane. SmallVector Visited; for (auto I = CSEWorkList.begin(), E = CSEWorkList.end(); I != E; ++I) { + assert((I && *I) && "worklist does not contain any reachable block"); assert((I == CSEWorkList.begin() || !DT->dominates(*I, *std::prev(I))) && "Worklist not sorted properly!"); BasicBlock *BB = (*I)->getBlock(); @@ -2919,6 +2920,7 @@ calculateDependencies(Bundle, true, SLP); + assert(Bundle && "is an empty instruction bundle"); // Now try to schedule the new bundle. As soon as the bundle is "ready" it // means that there are no cyclic dependencies and we can schedule it. // Note that's important that we don't "schedule" the bundle yet (see