diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 40beb7fd69809c..fd68152468737e 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -4121,14 +4121,19 @@ struct AAIsDeadFloating : public AAIsDeadValueImpl { if (SI.isVolatile()) return false; + // If we are collecting assumes to be deleted we are in the manifest stage. + // It's problematic to collect the potential copies again now so we use the + // cached ones. bool UsedAssumedInformation = false; - SmallSetVector PotentialCopies; - if (!AA::getPotentialCopiesOfStoredValue(A, SI, PotentialCopies, *this, - UsedAssumedInformation)) { - LLVM_DEBUG( - dbgs() - << "[AAIsDead] Could not determine potential copies of store!\n"); - return false; + if (!AssumeOnlyInst) { + PotentialCopies.clear(); + if (!AA::getPotentialCopiesOfStoredValue(A, SI, PotentialCopies, *this, + UsedAssumedInformation)) { + LLVM_DEBUG( + dbgs() + << "[AAIsDead] Could not determine potential copies of store!\n"); + return false; + } } LLVM_DEBUG(dbgs() << "[AAIsDead] Store has " << PotentialCopies.size() << " potential copies.\n"); @@ -4217,6 +4222,10 @@ struct AAIsDeadFloating : public AAIsDeadValueImpl { void trackStatistics() const override { STATS_DECLTRACK_FLOATING_ATTR(IsDead) } + +private: + // The potential copies of a dead store, used for deletion during manifest. + SmallSetVector PotentialCopies; }; struct AAIsDeadArgument : public AAIsDeadFloating {