diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index 207c9bb5b785..e8edf5747e3d 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -4293,9 +4293,8 @@ struct AAValueConstantRange /// that the target position can take). That never happens naturally, we only /// force it. As for the conditions under which we force it, see /// AAPotentialConstantValues. -template > -struct PotentialValuesState : AbstractState { - using SetTy = DenseSet; +template struct PotentialValuesState : AbstractState { + using SetTy = SmallSetVector; PotentialValuesState() : IsValidState(true), UndefIsContained(false) {} @@ -4354,7 +4353,7 @@ struct PotentialValuesState : AbstractState { return PotentialValuesState(true); } - static PotentialValuesState getBestState(PotentialValuesState &PVS) { + static PotentialValuesState getBestState(const PotentialValuesState &PVS) { return getBestState(); } @@ -4385,6 +4384,12 @@ struct PotentialValuesState : AbstractState { return *this; } +protected: + SetTy &getAssumedSet() { + assert(isValidState() && "This set shoud not be used when it is invalid!"); + return Set; + } + private: /// Check the size of this set, and invalidate when the size is no /// less than \p MaxPotentialValues threshold. diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 79118fd6899f..5b9dea2a3fa1 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -11,8 +11,6 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ADT/SetVector.h" -#include "llvm/IR/GlobalValue.h" #include "llvm/Transforms/IPO/Attributor.h" #include "llvm/ADT/APInt.h" @@ -20,6 +18,7 @@ #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetOperations.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" @@ -37,6 +36,7 @@ #include "llvm/IR/Assumptions.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" @@ -9125,8 +9125,8 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl { if (!RHSAA.isValidState()) return indicatePessimisticFixpoint(); - const DenseSet &LHSAAPVS = LHSAA.getAssumedSet(); - const DenseSet &RHSAAPVS = RHSAA.getAssumedSet(); + const SetTy &LHSAAPVS = LHSAA.getAssumedSet(); + const SetTy &RHSAAPVS = RHSAA.getAssumedSet(); // TODO: make use of undef flag to limit potential values aggressively. bool MaybeTrue = false, MaybeFalse = false; @@ -9265,7 +9265,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl { *this, IRPosition::value(*Src), DepClassTy::REQUIRED); if (!SrcAA.isValidState()) return indicatePessimisticFixpoint(); - const DenseSet &SrcAAPVS = SrcAA.getAssumedSet(); + const SetTy &SrcAAPVS = SrcAA.getAssumedSet(); if (SrcAA.undefIsContained()) unionAssumedWithUndef(); else { @@ -9316,8 +9316,8 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl { if (!RHSAA.isValidState()) return indicatePessimisticFixpoint(); - const DenseSet &LHSAAPVS = LHSAA.getAssumedSet(); - const DenseSet &RHSAAPVS = RHSAA.getAssumedSet(); + const SetTy &LHSAAPVS = LHSAA.getAssumedSet(); + const SetTy &RHSAAPVS = RHSAA.getAssumedSet(); const APInt Zero = APInt(LHS->getType()->getIntegerBitWidth(), 0); // TODO: make use of undef flag to limit potential values aggressively.