[Analysis] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.
This commit is contained in:
Kazu Hirata 2022-01-23 20:32:56 -08:00
parent f63a9cd99d
commit b752eb887f
21 changed files with 73 additions and 87 deletions

View File

@ -31,17 +31,15 @@ namespace llvm {
class AAResults;
class AAEvaluator : public PassInfoMixin<AAEvaluator> {
int64_t FunctionCount;
int64_t NoAliasCount, MayAliasCount, PartialAliasCount, MustAliasCount;
int64_t NoModRefCount, ModCount, RefCount, ModRefCount;
int64_t MustCount, MustRefCount, MustModCount, MustModRefCount;
int64_t FunctionCount = 0;
int64_t NoAliasCount = 0, MayAliasCount = 0, PartialAliasCount = 0;
int64_t MustAliasCount = 0;
int64_t NoModRefCount = 0, ModCount = 0, RefCount = 0, ModRefCount = 0;
int64_t MustCount = 0, MustRefCount = 0, MustModCount = 0;
int64_t MustModRefCount = 0;
public:
AAEvaluator()
: FunctionCount(), NoAliasCount(), MayAliasCount(), PartialAliasCount(),
MustAliasCount(), NoModRefCount(), ModCount(), RefCount(),
ModRefCount(), MustCount(), MustRefCount(), MustModCount(),
MustModRefCount() {}
AAEvaluator() = default;
AAEvaluator(AAEvaluator &&Arg)
: FunctionCount(Arg.FunctionCount), NoAliasCount(Arg.NoAliasCount),
MayAliasCount(Arg.MayAliasCount),

View File

@ -74,12 +74,8 @@ namespace llvm {
Dependence &operator=(Dependence &&) = default;
public:
Dependence(Instruction *Source,
Instruction *Destination) :
Src(Source),
Dst(Destination),
NextPredecessor(nullptr),
NextSuccessor(nullptr) {}
Dependence(Instruction *Source, Instruction *Destination)
: Src(Source), Dst(Destination) {}
virtual ~Dependence() {}
/// Dependence::DVEntry - Each level in the distance/direction vector
@ -99,9 +95,10 @@ namespace llvm {
bool PeelFirst : 1; // Peeling the first iteration will break dependence.
bool PeelLast : 1; // Peeling the last iteration will break the dependence.
bool Splitable : 1; // Splitting the loop will break dependence.
const SCEV *Distance; // NULL implies no distance available.
DVEntry() : Direction(ALL), Scalar(true), PeelFirst(false),
PeelLast(false), Splitable(false), Distance(nullptr) { }
const SCEV *Distance = nullptr; // NULL implies no distance available.
DVEntry()
: Direction(ALL), Scalar(true), PeelFirst(false), PeelLast(false),
Splitable(false) {}
};
/// getSrc - Returns the source instruction for this dependence.
@ -200,7 +197,7 @@ namespace llvm {
private:
Instruction *Src, *Dst;
const Dependence *NextPredecessor, *NextSuccessor;
const Dependence *NextPredecessor = nullptr, *NextSuccessor = nullptr;
friend class DependenceInfo;
};

View File

@ -146,7 +146,7 @@ class DivergenceInfo {
// analysis can run indefinitely. We set ContainsIrreducible and no
// analysis is actually performed on the function. All values in
// this function are conservatively reported as divergent instead.
bool ContainsIrreducible;
bool ContainsIrreducible = false;
std::unique_ptr<SyncDependenceAnalysis> SDA;
std::unique_ptr<DivergenceAnalysisImpl> DA;

View File

@ -121,7 +121,7 @@ struct IRInstructionData
/// and is used when checking when two instructions are considered similar.
/// If either instruction is not legal, the instructions are automatically not
/// considered similar.
bool Legal;
bool Legal = false;
/// This is only relevant if we are wrapping a CmpInst where we needed to
/// change the predicate of a compare instruction from a greater than form

View File

@ -63,7 +63,7 @@ class Value;
/// results if the users specified it is safe to use.
struct InstrInfoQuery {
InstrInfoQuery(bool UMD) : UseInstrInfo(UMD) {}
InstrInfoQuery() : UseInstrInfo(true) {}
InstrInfoQuery() = default;
bool UseInstrInfo = true;
MDNode *getMetadata(const Instruction *I, unsigned KindID) const {

View File

@ -33,8 +33,7 @@ template <typename FunctionT, typename BranchProbabilityInfoPassT,
typename LoopInfoT, typename BlockFrequencyInfoT>
class LazyBlockFrequencyInfo {
public:
LazyBlockFrequencyInfo()
: Calculated(false), F(nullptr), BPIPass(nullptr), LI(nullptr) {}
LazyBlockFrequencyInfo() = default;
/// Set up the per-function input.
void setAnalysis(const FunctionT *F, BranchProbabilityInfoPassT *BPIPass,
@ -67,10 +66,10 @@ public:
private:
BlockFrequencyInfoT BFI;
bool Calculated;
const FunctionT *F;
BranchProbabilityInfoPassT *BPIPass;
const LoopInfoT *LI;
bool Calculated = false;
const FunctionT *F = nullptr;
BranchProbabilityInfoPassT *BPIPass = nullptr;
const LoopInfoT *LI = nullptr;
};
/// This is an alternative analysis pass to

View File

@ -57,7 +57,7 @@ class LazyBranchProbabilityInfoPass : public FunctionPass {
public:
LazyBranchProbabilityInfo(const Function *F, const LoopInfo *LI,
const TargetLibraryInfo *TLI)
: Calculated(false), F(F), LI(LI), TLI(TLI) {}
: F(F), LI(LI), TLI(TLI) {}
/// Retrieve the BPI with the branch probabilities computed.
BranchProbabilityInfo &getCalculated() {
@ -75,7 +75,7 @@ class LazyBranchProbabilityInfoPass : public FunctionPass {
private:
BranchProbabilityInfo BPI;
bool Calculated;
bool Calculated = false;
const Function *F;
const LoopInfo *LI;
const TargetLibraryInfo *TLI;

View File

@ -169,10 +169,7 @@ public:
};
MemoryDepChecker(PredicatedScalarEvolution &PSE, const Loop *L)
: PSE(PSE), InnermostLoop(L), AccessIdx(0), MaxSafeDepDistBytes(0),
MaxSafeVectorWidthInBits(-1U),
FoundNonConstantDistanceDependence(false),
Status(VectorizationSafetyStatus::Safe), RecordDependences(true) {}
: PSE(PSE), InnermostLoop(L) {}
/// Register the location (instructions are given increasing numbers)
/// of a write access.
@ -264,30 +261,30 @@ private:
SmallVector<Instruction *, 16> InstMap;
/// The program order index to be used for the next instruction.
unsigned AccessIdx;
unsigned AccessIdx = 0;
// We can access this many bytes in parallel safely.
uint64_t MaxSafeDepDistBytes;
uint64_t MaxSafeDepDistBytes = 0;
/// Number of elements (from consecutive iterations) that are safe to
/// operate on simultaneously, multiplied by the size of the element in bits.
/// The size of the element is taken from the memory access that is most
/// restrictive.
uint64_t MaxSafeVectorWidthInBits;
uint64_t MaxSafeVectorWidthInBits = -1U;
/// If we see a non-constant dependence distance we can still try to
/// vectorize this loop with runtime checks.
bool FoundNonConstantDistanceDependence;
bool FoundNonConstantDistanceDependence = false;
/// Result of the dependence checks, indicating whether the checked
/// dependences are safe for vectorization, require RT checks or are known to
/// be unsafe.
VectorizationSafetyStatus Status;
VectorizationSafetyStatus Status = VectorizationSafetyStatus::Safe;
//// True if Dependences reflects the dependences in the
//// loop. If false we exceeded MaxDependences and
//// Dependences is invalid.
bool RecordDependences;
bool RecordDependences = true;
/// Memory dependences collected during the analysis. Only valid if
/// RecordDependences is true.
@ -395,7 +392,7 @@ public:
AliasSetId(AliasSetId), Expr(Expr) {}
};
RuntimePointerChecking(ScalarEvolution *SE) : Need(false), SE(SE) {}
RuntimePointerChecking(ScalarEvolution *SE) : SE(SE) {}
/// Reset the state of the pointer runtime information.
void reset() {
@ -444,7 +441,7 @@ public:
unsigned Depth = 0) const;
/// This flag indicates if we need to add the runtime check.
bool Need;
bool Need = false;
/// Information about the pointers that may require checking.
SmallVector<PointerInfo, 2> Pointers;
@ -620,17 +617,17 @@ private:
Loop *TheLoop;
unsigned NumLoads;
unsigned NumStores;
unsigned NumLoads = 0;
unsigned NumStores = 0;
uint64_t MaxSafeDepDistBytes;
uint64_t MaxSafeDepDistBytes = -1;
/// Cache the result of analyzeLoop.
bool CanVecMem;
bool HasConvergentOp;
bool CanVecMem = false;
bool HasConvergentOp = false;
/// Indicator that there are non vectorizable stores to a uniform address.
bool HasDependenceInvolvingLoopInvariantAddress;
bool HasDependenceInvolvingLoopInvariantAddress = false;
/// The diagnostics report generated for the analysis. E.g. why we
/// couldn't analyze the loop.

View File

@ -87,7 +87,7 @@ typedef InnerAnalysisManagerProxy<LoopAnalysisManager, Function>
template <> class LoopAnalysisManagerFunctionProxy::Result {
public:
explicit Result(LoopAnalysisManager &InnerAM, LoopInfo &LI)
: InnerAM(&InnerAM), LI(&LI), MSSAUsed(false) {}
: InnerAM(&InnerAM), LI(&LI) {}
Result(Result &&Arg)
: InnerAM(std::move(Arg.InnerAM)), LI(Arg.LI), MSSAUsed(Arg.MSSAUsed) {
// We have to null out the analysis manager in the moved-from state
@ -136,7 +136,7 @@ public:
private:
LoopAnalysisManager *InnerAM;
LoopInfo *LI;
bool MSSAUsed;
bool MSSAUsed = false;
};
/// Provide a specialized run method for the \c LoopAnalysisManagerFunctionProxy

View File

@ -865,7 +865,7 @@ private:
AccessList *getOrCreateAccessList(const BasicBlock *);
DefsList *getOrCreateDefsList(const BasicBlock *);
void renumberBlock(const BasicBlock *) const;
AliasAnalysis *AA;
AliasAnalysis *AA = nullptr;
DominatorTree *DT;
Function &F;
@ -892,7 +892,7 @@ private:
std::unique_ptr<ClobberWalkerBase<AliasAnalysis>> WalkerBase;
std::unique_ptr<CachingWalker<AliasAnalysis>> Walker;
std::unique_ptr<SkipSelfWalker<AliasAnalysis>> SkipWalker;
unsigned NextID;
unsigned NextID = 0;
};
/// Enables verification of MemorySSA.

View File

@ -40,7 +40,7 @@ class PHITransAddr {
const DataLayout &DL;
/// TLI - The target library info if known, otherwise null.
const TargetLibraryInfo *TLI;
const TargetLibraryInfo *TLI = nullptr;
/// A cache of \@llvm.assume calls used by SimplifyInstruction.
AssumptionCache *AC;
@ -50,7 +50,7 @@ class PHITransAddr {
public:
PHITransAddr(Value *addr, const DataLayout &DL, AssumptionCache *AC)
: Addr(addr), DL(DL), TLI(nullptr), AC(AC) {
: Addr(addr), DL(DL), AC(AC) {
// If the address is an instruction, the whole thing is considered an input.
if (Instruction *I = dyn_cast<Instruction>(Addr))
InstInputs.push_back(I);

View File

@ -1364,10 +1364,12 @@ public:
/// Flags describing the kind of vector reduction.
struct ReductionFlags {
ReductionFlags() : IsMaxOp(false), IsSigned(false), NoNaN(false) {}
bool IsMaxOp; ///< If the op a min/max kind, true if it's a max operation.
bool IsSigned; ///< Whether the operation is a signed int reduction.
bool NoNaN; ///< If op is an fp min/max, whether NaNs may be present.
ReductionFlags() = default;
bool IsMaxOp =
false; ///< If the op a min/max kind, true if it's a max operation.
bool IsSigned = false; ///< Whether the operation is a signed int reduction.
bool NoNaN =
false; ///< If op is an fp min/max, whether NaNs may be present.
};
/// \returns True if the target prefers reductions in loop.

View File

@ -75,7 +75,7 @@ bool CaptureTracker::isDereferenceableOrNull(Value *O, const DataLayout &DL) {
namespace {
struct SimpleCaptureTracker : public CaptureTracker {
explicit SimpleCaptureTracker(bool ReturnCaptures)
: ReturnCaptures(ReturnCaptures), Captured(false) {}
: ReturnCaptures(ReturnCaptures) {}
void tooManyUses() override { Captured = true; }
@ -89,7 +89,7 @@ namespace {
bool ReturnCaptures;
bool Captured;
bool Captured = false;
};
/// Only find pointer captures which happen before the given instruction. Uses
@ -101,7 +101,7 @@ namespace {
CapturesBefore(bool ReturnCaptures, const Instruction *I,
const DominatorTree *DT, bool IncludeI, const LoopInfo *LI)
: BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures),
IncludeI(IncludeI), Captured(false), LI(LI) {}
IncludeI(IncludeI), LI(LI) {}
void tooManyUses() override { Captured = true; }
@ -139,7 +139,7 @@ namespace {
bool ReturnCaptures;
bool IncludeI;
bool Captured;
bool Captured = false;
const LoopInfo *LI;
};
@ -155,7 +155,7 @@ namespace {
struct EarliestCaptures : public CaptureTracker {
EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT)
: DT(DT), ReturnCaptures(ReturnCaptures), Captured(false), F(F) {}
: DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}
void tooManyUses() override {
Captured = true;
@ -199,7 +199,7 @@ namespace {
bool ReturnCaptures;
bool Captured;
bool Captured = false;
Function &F;
};

View File

@ -50,7 +50,7 @@ namespace {
public:
static char ID; // Class identification, replacement for typeinfo
CostModelAnalysis() : FunctionPass(ID), F(nullptr), TTI(nullptr) {
CostModelAnalysis() : FunctionPass(ID) {
initializeCostModelAnalysisPass(
*PassRegistry::getPassRegistry());
}
@ -69,9 +69,9 @@ namespace {
void print(raw_ostream &OS, const Module*) const override;
/// The function that we analyze.
Function *F;
Function *F = nullptr;
/// Target information.
const TargetTransformInfo *TTI;
const TargetTransformInfo *TTI = nullptr;
};
} // End of anonymous namespace

View File

@ -348,7 +348,7 @@ DivergenceInfo::DivergenceInfo(Function &F, const DominatorTree &DT,
const PostDominatorTree &PDT, const LoopInfo &LI,
const TargetTransformInfo &TTI,
bool KnownReducible)
: F(F), ContainsIrreducible(false) {
: F(F) {
if (!KnownReducible) {
using RPOTraversal = ReversePostOrderTraversal<const Function *>;
RPOTraversal FuncRPOT(&F);

View File

@ -62,7 +62,7 @@ void IRInstructionData::initializeInstruction() {
}
IRInstructionData::IRInstructionData(IRInstructionDataList &IDList)
: Inst(nullptr), Legal(false), IDL(&IDList) {}
: IDL(&IDList) {}
void IRInstructionData::setBranchSuccessors(
DenseMap<BasicBlock *, unsigned> &BasicBlockToInteger) {

View File

@ -361,10 +361,10 @@ protected:
/// Model the elimination of repeated loads that is expected to happen
/// whenever we simplify away the stores that would otherwise cause them to be
/// loads.
bool EnableLoadElimination;
bool EnableLoadElimination = true;
/// Whether we allow inlining for recursive call.
bool AllowRecursiveCall;
bool AllowRecursiveCall = false;
SmallPtrSet<Value *, 16> LoadAddrSet;
@ -455,8 +455,7 @@ public:
OptimizationRemarkEmitter *ORE = nullptr)
: TTI(TTI), GetAssumptionCache(GetAssumptionCache), GetBFI(GetBFI),
PSI(PSI), F(Callee), DL(F.getParent()->getDataLayout()), ORE(ORE),
CandidateCall(Call), EnableLoadElimination(true),
AllowRecursiveCall(false) {}
CandidateCall(Call) {}
InlineResult analyze();

View File

@ -519,8 +519,7 @@ public:
AccessAnalysis(Loop *TheLoop, AAResults *AA, LoopInfo *LI,
MemoryDepChecker::DepCandidates &DA,
PredicatedScalarEvolution &PSE)
: TheLoop(TheLoop), AST(*AA), LI(LI), DepCands(DA),
IsRTCheckAnalysisNeeded(false), PSE(PSE) {}
: TheLoop(TheLoop), AST(*AA), LI(LI), DepCands(DA), PSE(PSE) {}
/// Register a load and whether it is only read from.
void addLoad(MemoryLocation &Loc, bool IsReadOnly) {
@ -620,7 +619,7 @@ private:
/// memcheck analysis without dependency checking
/// (i.e. FoundNonConstantDistanceDependence), isDependencyCheckNeeded is
/// cleared while this remains set if we have potentially dependent accesses.
bool IsRTCheckAnalysisNeeded;
bool IsRTCheckAnalysisNeeded = false;
/// The SCEV predicate containing all the SCEV-related assumptions.
PredicatedScalarEvolution &PSE;
@ -2244,10 +2243,7 @@ LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
DominatorTree *DT, LoopInfo *LI)
: PSE(std::make_unique<PredicatedScalarEvolution>(*SE, *L)),
PtrRtChecking(std::make_unique<RuntimePointerChecking>(SE)),
DepChecker(std::make_unique<MemoryDepChecker>(*PSE, L)), TheLoop(L),
NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1), CanVecMem(false),
HasConvergentOp(false),
HasDependenceInvolvingLoopInvariantAddress(false) {
DepChecker(std::make_unique<MemoryDepChecker>(*PSE, L)), TheLoop(L) {
if (canAnalyzeLoop())
analyzeLoop(AA, LI, TLI, DT);
}

View File

@ -695,11 +695,10 @@ class UnloopUpdater {
// Flag the presence of an irreducible backedge whose destination is a block
// directly contained by the original unloop.
bool FoundIB;
bool FoundIB = false;
public:
UnloopUpdater(Loop *UL, LoopInfo *LInfo)
: Unloop(*UL), LI(LInfo), DFS(UL), FoundIB(false) {}
UnloopUpdater(Loop *UL, LoopInfo *LInfo) : Unloop(*UL), LI(LInfo), DFS(UL) {}
void updateBlockParents();

View File

@ -1265,8 +1265,8 @@ void MemorySSA::markUnreachableAsLiveOnEntry(BasicBlock *BB) {
}
MemorySSA::MemorySSA(Function &Func, AliasAnalysis *AA, DominatorTree *DT)
: AA(nullptr), DT(DT), F(Func), LiveOnEntryDef(nullptr), Walker(nullptr),
SkipWalker(nullptr), NextID(0) {
: DT(DT), F(Func), LiveOnEntryDef(nullptr), Walker(nullptr),
SkipWalker(nullptr) {
// Build MemorySSA using a batch alias analysis. This reuses the internal
// state that AA collects during an alias()/getModRefInfo() call. This is
// safe because there are no CFG changes while building MemorySSA and can

View File

@ -28,8 +28,7 @@ ReplayInlineAdvisor::ReplayInlineAdvisor(
std::unique_ptr<InlineAdvisor> OriginalAdvisor,
const ReplayInlinerSettings &ReplaySettings, bool EmitRemarks)
: InlineAdvisor(M, FAM), OriginalAdvisor(std::move(OriginalAdvisor)),
HasReplayRemarks(false), ReplaySettings(ReplaySettings),
EmitRemarks(EmitRemarks) {
ReplaySettings(ReplaySettings), EmitRemarks(EmitRemarks) {
auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(ReplaySettings.ReplayFile);
std::error_code EC = BufferOrErr.getError();