Index: llvm/include/llvm/Transforms/Utils/PredicateInfo.h =================================================================== --- llvm/include/llvm/Transforms/Utils/PredicateInfo.h +++ llvm/include/llvm/Transforms/Utils/PredicateInfo.h @@ -85,13 +85,13 @@ // The original operand before we renamed it. // This can be use by passes, when destroying predicateinfo, to know // whether they can just drop the intrinsic, or have to merge metadata. - Value *OriginalOp; + WeakVH OriginalOp; // The renamed operand in the condition used for this predicate. For nested // predicates, this is different to OriginalOp which refers to the initial // operand. - Value *RenamedOp; + WeakVH RenamedOp; // The condition associated with this predicate. - Value *Condition; + WeakVH Condition; PredicateBase(const PredicateBase &) = delete; PredicateBase &operator=(const PredicateBase &) = delete; Index: llvm/lib/Transforms/Utils/PredicateInfo.cpp =================================================================== --- llvm/lib/Transforms/Utils/PredicateInfo.cpp +++ llvm/lib/Transforms/Utils/PredicateInfo.cpp @@ -792,6 +792,9 @@ } Optional PredicateBase::getConstraint() const { + if (!OriginalOp || !RenamedOp || !Condition) + return None; + switch (Type) { case PT_Assume: case PT_Branch: { @@ -909,6 +912,8 @@ void emitInstructionAnnot(const Instruction *I, formatted_raw_ostream &OS) override { if (const auto *PI = PredInfo->getPredicateInfoFor(I)) { + if (!PI->OriginalOp || !PI->RenamedOp || !PI->Condition) + return; OS << "; Has predicate info\n"; if (const auto *PB = dyn_cast(PI)) { OS << "; branch predicate info { TrueEdge: " << PB->TrueEdge