[Attributor][NFC] Code cleanup to minimize follow up changes

This commit is contained in:
Johannes Doerfert 2022-04-12 16:05:32 -05:00
parent 2d8e7834b0
commit bd72acf4d8
2 changed files with 16 additions and 11 deletions

View File

@ -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 <typename MemberTy, typename KeyInfo = DenseMapInfo<MemberTy>>
struct PotentialValuesState : AbstractState {
using SetTy = DenseSet<MemberTy, KeyInfo>;
template <typename MemberTy> struct PotentialValuesState : AbstractState {
using SetTy = SmallSetVector<MemberTy, 8>;
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.

View File

@ -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<APInt> &LHSAAPVS = LHSAA.getAssumedSet();
const DenseSet<APInt> &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<APInt> &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<APInt> &LHSAAPVS = LHSAA.getAssumedSet();
const DenseSet<APInt> &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.