diff --git a/llvm/lib/Analysis/AssumeBundleQueries.cpp b/llvm/lib/Analysis/AssumeBundleQueries.cpp --- a/llvm/lib/Analysis/AssumeBundleQueries.cpp +++ b/llvm/lib/Analysis/AssumeBundleQueries.cpp @@ -152,10 +152,6 @@ const CallBase::BundleOpInfo *)> Filter) { if (AC) { -#ifndef NDEBUG - RetainedKnowledge RKCheck = - getKnowledgeForValue(V, AttrKinds, nullptr, Filter); -#endif for (AssumptionCache::ResultElem &Elem : AC->assumptionsFor(V)) { IntrinsicInst *II = cast_or_null(Elem.Assume); if (!II || Elem.Index == AssumptionCache::ExprResultIdx) @@ -163,12 +159,9 @@ if (RetainedKnowledge RK = getKnowledgeFromBundle( *II, II->bundle_op_info_begin()[Elem.Index])) if (is_contained(AttrKinds, RK.AttrKind) && - Filter(RK, II, &II->bundle_op_info_begin()[Elem.Index])) { - assert(!!RKCheck && "invalid Assumption cache"); + Filter(RK, II, &II->bundle_op_info_begin()[Elem.Index])) return RK; - } } - assert(!RKCheck && "invalid Assumption cache"); return RetainedKnowledge::none(); } for (auto &U : V->uses()) { diff --git a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp --- a/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp +++ b/llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp @@ -202,7 +202,7 @@ void llvm::salvageKnowledge(Instruction *I, AssumptionCache *AC, DominatorTree *DT) { - if (!EnableKnowledgeRetention) + if (!EnableKnowledgeRetention || I->isTerminator()) return; AssumeBuilderState Builder(I->getModule(), I, AC, DT); Builder.addInstruction(I);