Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 46057fe

Browse files
committed
[Transforms] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316630 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 052d11c commit 46057fe

File tree

14 files changed

+364
-178
lines changed

14 files changed

+364
-178
lines changed

include/llvm/Transforms/Utils/Evaluator.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- Evaluator.h - LLVM IR evaluator -------------------------*- C++ -*-===//
1+
//===- Evaluator.h - LLVM IR evaluator --------------------------*- C++ -*-===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -18,9 +18,10 @@
1818
#include "llvm/ADT/SmallPtrSet.h"
1919
#include "llvm/ADT/SmallVector.h"
2020
#include "llvm/IR/BasicBlock.h"
21-
#include "llvm/IR/Constant.h"
2221
#include "llvm/IR/GlobalVariable.h"
23-
22+
#include "llvm/IR/Value.h"
23+
#include "llvm/Support/Casting.h"
24+
#include <cassert>
2425
#include <deque>
2526
#include <memory>
2627

@@ -114,6 +115,6 @@ class Evaluator {
114115
const TargetLibraryInfo *TLI;
115116
};
116117

117-
}
118+
} // end namespace llvm
118119

119-
#endif
120+
#endif // LLVM_TRANSFORMS_UTILS_EVALUATOR_H

include/llvm/Transforms/Utils/Mem2Reg.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
#ifndef LLVM_TRANSFORMS_UTILS_MEM2REG_H
1616
#define LLVM_TRANSFORMS_UTILS_MEM2REG_H
1717

18-
#include "llvm/IR/Function.h"
1918
#include "llvm/IR/PassManager.h"
2019

2120
namespace llvm {
21+
22+
class Function;
23+
2224
class PromotePass : public PassInfoMixin<PromotePass> {
2325
public:
2426
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
2527
};
26-
}
28+
29+
} // end namespace llvm
2730

2831
#endif // LLVM_TRANSFORMS_UTILS_MEM2REG_H

include/llvm/Transforms/Utils/SplitModule.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
namespace llvm {
2323

2424
class Module;
25-
class StringRef;
2625

2726
/// Splits the module M into N linkable partitions. The function ModuleCallback
2827
/// is called N times passing each individual partition as the MPart argument.
@@ -39,6 +38,6 @@ void SplitModule(
3938
function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback,
4039
bool PreserveLocals = false);
4140

42-
} // End llvm namespace
41+
} // end namespace llvm
4342

44-
#endif
43+
#endif // LLVM_TRANSFORMS_UTILS_SPLITMODULE_H

include/llvm/Transforms/Utils/UnrollLoop.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,22 @@
1616
#ifndef LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
1717
#define LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H
1818

19-
// Needed because we can't forward-declare the nested struct
20-
// TargetTransformInfo::UnrollingPreferences
19+
#include "llvm/ADT/DenseMap.h"
20+
#include "llvm/ADT/StringRef.h"
2121
#include "llvm/Analysis/TargetTransformInfo.h"
2222

2323
namespace llvm {
2424

25-
class StringRef;
2625
class AssumptionCache;
26+
class BasicBlock;
2727
class DominatorTree;
2828
class Loop;
2929
class LoopInfo;
30-
class LPPassManager;
3130
class MDNode;
32-
class Pass;
3331
class OptimizationRemarkEmitter;
3432
class ScalarEvolution;
3533

36-
typedef SmallDenseMap<const Loop *, Loop *, 4> NewLoopsMap;
34+
using NewLoopsMap = SmallDenseMap<const Loop *, Loop *, 4>;
3735

3836
const Loop* addClonedBlockToLoopInfo(BasicBlock *OriginalBB,
3937
BasicBlock *ClonedBB, LoopInfo *LI,
@@ -80,6 +78,7 @@ bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE,
8078
DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA);
8179

8280
MDNode *GetUnrollMetadata(MDNode *LoopID, StringRef Name);
83-
}
8481

85-
#endif
82+
} // end namespace llvm
83+
84+
#endif // LLVM_TRANSFORMS_UTILS_UNROLLLOOP_H

include/llvm/Transforms/Utils/ValueMapper.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@
2121

2222
namespace llvm {
2323

24-
class Value;
24+
class Constant;
25+
class Function;
26+
class GlobalAlias;
27+
class GlobalVariable;
2528
class Instruction;
26-
typedef ValueMap<const Value *, WeakTrackingVH> ValueToValueMapTy;
29+
class MDNode;
30+
class Metadata;
31+
class Type;
32+
class Value;
33+
34+
using ValueToValueMapTy = ValueMap<const Value *, WeakTrackingVH>;
2735

2836
/// This is a class that can be implemented by clients to remap types when
2937
/// cloning constants and instructions.
@@ -44,10 +52,10 @@ class ValueMaterializer {
4452
virtual void anchor(); // Out of line method.
4553

4654
protected:
47-
~ValueMaterializer() = default;
4855
ValueMaterializer() = default;
4956
ValueMaterializer(const ValueMaterializer &) = default;
5057
ValueMaterializer &operator=(const ValueMaterializer &) = default;
58+
~ValueMaterializer() = default;
5159

5260
public:
5361
/// This method can be implemented to generate a mapped Value on demand. For

lib/Transforms/Scalar/LoopVersioningLICM.cpp

Lines changed: 61 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===----------- LoopVersioningLICM.cpp - LICM Loop Versioning ------------===//
1+
//===- LoopVersioningLICM.cpp - LICM Loop Versioning ----------------------===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -60,41 +60,41 @@
6060
//
6161
//===----------------------------------------------------------------------===//
6262

63-
#include "llvm/ADT/MapVector.h"
64-
#include "llvm/ADT/SmallPtrSet.h"
65-
#include "llvm/ADT/Statistic.h"
66-
#include "llvm/ADT/StringExtras.h"
63+
#include "llvm/ADT/SmallVector.h"
64+
#include "llvm/ADT/StringRef.h"
6765
#include "llvm/Analysis/AliasAnalysis.h"
6866
#include "llvm/Analysis/AliasSetTracker.h"
69-
#include "llvm/Analysis/ConstantFolding.h"
7067
#include "llvm/Analysis/GlobalsModRef.h"
7168
#include "llvm/Analysis/LoopAccessAnalysis.h"
7269
#include "llvm/Analysis/LoopInfo.h"
7370
#include "llvm/Analysis/LoopPass.h"
7471
#include "llvm/Analysis/ScalarEvolution.h"
75-
#include "llvm/Analysis/ScalarEvolutionExpander.h"
76-
#include "llvm/Analysis/TargetLibraryInfo.h"
77-
#include "llvm/Analysis/ValueTracking.h"
78-
#include "llvm/Analysis/VectorUtils.h"
72+
#include "llvm/IR/CallSite.h"
73+
#include "llvm/IR/Constants.h"
7974
#include "llvm/IR/Dominators.h"
80-
#include "llvm/IR/IntrinsicInst.h"
75+
#include "llvm/IR/Instruction.h"
76+
#include "llvm/IR/Instructions.h"
77+
#include "llvm/IR/LLVMContext.h"
8178
#include "llvm/IR/MDBuilder.h"
82-
#include "llvm/IR/PatternMatch.h"
83-
#include "llvm/IR/PredIteratorCache.h"
79+
#include "llvm/IR/Metadata.h"
8480
#include "llvm/IR/Type.h"
81+
#include "llvm/IR/Value.h"
82+
#include "llvm/Pass.h"
83+
#include "llvm/Support/Casting.h"
84+
#include "llvm/Support/CommandLine.h"
8585
#include "llvm/Support/Debug.h"
8686
#include "llvm/Support/raw_ostream.h"
8787
#include "llvm/Transforms/Scalar.h"
88-
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
89-
#include "llvm/Transforms/Utils/Cloning.h"
9088
#include "llvm/Transforms/Utils/LoopUtils.h"
9189
#include "llvm/Transforms/Utils/LoopVersioning.h"
92-
#include "llvm/Transforms/Utils/ValueMapper.h"
90+
#include <cassert>
91+
#include <memory>
92+
93+
using namespace llvm;
9394

9495
#define DEBUG_TYPE "loop-versioning-licm"
95-
static const char *LICMVersioningMetaData = "llvm.loop.licm_versioning.disable";
9696

97-
using namespace llvm;
97+
static const char *LICMVersioningMetaData = "llvm.loop.licm_versioning.disable";
9898

9999
/// Threshold minimum allowed percentage for possible
100100
/// invariant instructions in a loop.
@@ -143,9 +143,16 @@ void llvm::addStringMetadataToLoop(Loop *TheLoop, const char *MDString,
143143
}
144144

145145
namespace {
146+
146147
struct LoopVersioningLICM : public LoopPass {
147148
static char ID;
148149

150+
LoopVersioningLICM()
151+
: LoopPass(ID), LoopDepthThreshold(LVLoopDepthThreshold),
152+
InvariantThreshold(LVInvarThreshold) {
153+
initializeLoopVersioningLICMPass(*PassRegistry::getPassRegistry());
154+
}
155+
149156
bool runOnLoop(Loop *L, LPPassManager &LPM) override;
150157

151158
void getAnalysisUsage(AnalysisUsage &AU) const override {
@@ -161,13 +168,6 @@ struct LoopVersioningLICM : public LoopPass {
161168
AU.addPreserved<GlobalsAAWrapperPass>();
162169
}
163170

164-
LoopVersioningLICM()
165-
: LoopPass(ID), AA(nullptr), SE(nullptr), LAA(nullptr), LAI(nullptr),
166-
CurLoop(nullptr), LoopDepthThreshold(LVLoopDepthThreshold),
167-
InvariantThreshold(LVInvarThreshold), LoadAndStoreCounter(0),
168-
InvariantCounter(0), IsReadOnlyLoop(true) {
169-
initializeLoopVersioningLICMPass(*PassRegistry::getPassRegistry());
170-
}
171171
StringRef getPassName() const override { return "Loop Versioning for LICM"; }
172172

173173
void reset() {
@@ -191,30 +191,49 @@ struct LoopVersioningLICM : public LoopPass {
191191
};
192192

193193
private:
194-
AliasAnalysis *AA; // Current AliasAnalysis information
195-
ScalarEvolution *SE; // Current ScalarEvolution
196-
LoopAccessLegacyAnalysis *LAA; // Current LoopAccessAnalysis
197-
const LoopAccessInfo *LAI; // Current Loop's LoopAccessInfo
194+
// Current AliasAnalysis information
195+
AliasAnalysis *AA = nullptr;
196+
197+
// Current ScalarEvolution
198+
ScalarEvolution *SE = nullptr;
199+
200+
// Current LoopAccessAnalysis
201+
LoopAccessLegacyAnalysis *LAA = nullptr;
202+
203+
// Current Loop's LoopAccessInfo
204+
const LoopAccessInfo *LAI = nullptr;
205+
206+
// The current loop we are working on.
207+
Loop *CurLoop = nullptr;
208+
209+
// AliasSet information for the current loop.
210+
std::unique_ptr<AliasSetTracker> CurAST;
198211

199-
Loop *CurLoop; // The current loop we are working on.
200-
std::unique_ptr<AliasSetTracker>
201-
CurAST; // AliasSet information for the current loop.
212+
// Maximum loop nest threshold
213+
unsigned LoopDepthThreshold;
202214

203-
unsigned LoopDepthThreshold; // Maximum loop nest threshold
204-
float InvariantThreshold; // Minimum invariant threshold
205-
unsigned LoadAndStoreCounter; // Counter to track num of load & store
206-
unsigned InvariantCounter; // Counter to track num of invariant
207-
bool IsReadOnlyLoop; // Read only loop marker.
215+
// Minimum invariant threshold
216+
float InvariantThreshold;
217+
218+
// Counter to track num of load & store
219+
unsigned LoadAndStoreCounter = 0;
220+
221+
// Counter to track num of invariant
222+
unsigned InvariantCounter = 0;
223+
224+
// Read only loop marker.
225+
bool IsReadOnlyLoop = true;
208226

209227
bool isLegalForVersioning();
210228
bool legalLoopStructure();
211229
bool legalLoopInstructions();
212230
bool legalLoopMemoryAccesses();
213231
bool isLoopAlreadyVisited();
214-
void setNoAliasToLoop(Loop *);
215-
bool instructionSafeForVersioning(Instruction *);
232+
void setNoAliasToLoop(Loop *VerLoop);
233+
bool instructionSafeForVersioning(Instruction *I);
216234
};
217-
}
235+
236+
} // end anonymous namespace
218237

219238
/// \brief Check loop structure and confirms it's good for LoopVersioningLICM.
220239
bool LoopVersioningLICM::legalLoopStructure() {
@@ -225,7 +244,7 @@ bool LoopVersioningLICM::legalLoopStructure() {
225244
return false;
226245
}
227246
// Loop should be innermost loop, if not return false.
228-
if (CurLoop->getSubLoops().size()) {
247+
if (!CurLoop->getSubLoops().empty()) {
229248
DEBUG(dbgs() << " loop is not innermost\n");
230249
return false;
231250
}
@@ -562,6 +581,7 @@ bool LoopVersioningLICM::runOnLoop(Loop *L, LPPassManager &LPM) {
562581
}
563582

564583
char LoopVersioningLICM::ID = 0;
584+
565585
INITIALIZE_PASS_BEGIN(LoopVersioningLICM, "loop-versioning-licm",
566586
"Loop Versioning For LICM", false, false)
567587
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)

0 commit comments

Comments
 (0)