Skip to content

Commit 4c1e41c

Browse files
author
eugenezelenko
committed
[CodeGen] Fix some Clang-tidy modernize-use-default-member-init and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314046 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 37edc52 commit 4c1e41c

10 files changed

+322
-182
lines changed

lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- AtomicExpandPass.cpp - Expand atomic instructions -------===//
1+
//===- AtomicExpandPass.cpp - Expand atomic instructions ------------------===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -15,31 +15,54 @@
1515
//
1616
//===----------------------------------------------------------------------===//
1717

18+
#include "llvm/ADT/ArrayRef.h"
19+
#include "llvm/ADT/STLExtras.h"
20+
#include "llvm/ADT/SmallVector.h"
1821
#include "llvm/CodeGen/AtomicExpandUtils.h"
19-
#include "llvm/CodeGen/Passes.h"
22+
#include "llvm/CodeGen/RuntimeLibcalls.h"
2023
#include "llvm/CodeGen/TargetPassConfig.h"
24+
#include "llvm/CodeGen/ValueTypes.h"
25+
#include "llvm/IR/Attributes.h"
26+
#include "llvm/IR/BasicBlock.h"
27+
#include "llvm/IR/Constant.h"
28+
#include "llvm/IR/Constants.h"
29+
#include "llvm/IR/DataLayout.h"
30+
#include "llvm/IR/DerivedTypes.h"
2131
#include "llvm/IR/Function.h"
2232
#include "llvm/IR/IRBuilder.h"
2333
#include "llvm/IR/InstIterator.h"
34+
#include "llvm/IR/Instruction.h"
2435
#include "llvm/IR/Instructions.h"
25-
#include "llvm/IR/Intrinsics.h"
2636
#include "llvm/IR/Module.h"
37+
#include "llvm/IR/Type.h"
38+
#include "llvm/IR/User.h"
39+
#include "llvm/IR/Value.h"
40+
#include "llvm/Pass.h"
41+
#include "llvm/Support/AtomicOrdering.h"
42+
#include "llvm/Support/Casting.h"
2743
#include "llvm/Support/Debug.h"
44+
#include "llvm/Support/ErrorHandling.h"
2845
#include "llvm/Support/raw_ostream.h"
2946
#include "llvm/Target/TargetLowering.h"
3047
#include "llvm/Target/TargetMachine.h"
3148
#include "llvm/Target/TargetSubtargetInfo.h"
49+
#include <cassert>
50+
#include <cstdint>
51+
#include <iterator>
3252

3353
using namespace llvm;
3454

3555
#define DEBUG_TYPE "atomic-expand"
3656

3757
namespace {
58+
3859
class AtomicExpand: public FunctionPass {
39-
const TargetLowering *TLI;
60+
const TargetLowering *TLI = nullptr;
61+
4062
public:
4163
static char ID; // Pass identification, replacement for typeid
42-
AtomicExpand() : FunctionPass(ID), TLI(nullptr) {
64+
65+
AtomicExpand() : FunctionPass(ID) {
4366
initializeAtomicExpandPass(*PassRegistry::getPassRegistry());
4467
}
4568

@@ -92,39 +115,41 @@ namespace {
92115
llvm::expandAtomicRMWToCmpXchg(AtomicRMWInst *AI,
93116
CreateCmpXchgInstFun CreateCmpXchg);
94117
};
95-
}
118+
119+
} // end anonymous namespace
96120

97121
char AtomicExpand::ID = 0;
122+
98123
char &llvm::AtomicExpandID = AtomicExpand::ID;
124+
99125
INITIALIZE_PASS(AtomicExpand, DEBUG_TYPE, "Expand Atomic instructions",
100126
false, false)
101127

102128
FunctionPass *llvm::createAtomicExpandPass() { return new AtomicExpand(); }
103129

104-
namespace {
105130
// Helper functions to retrieve the size of atomic instructions.
106-
unsigned getAtomicOpSize(LoadInst *LI) {
131+
static unsigned getAtomicOpSize(LoadInst *LI) {
107132
const DataLayout &DL = LI->getModule()->getDataLayout();
108133
return DL.getTypeStoreSize(LI->getType());
109134
}
110135

111-
unsigned getAtomicOpSize(StoreInst *SI) {
136+
static unsigned getAtomicOpSize(StoreInst *SI) {
112137
const DataLayout &DL = SI->getModule()->getDataLayout();
113138
return DL.getTypeStoreSize(SI->getValueOperand()->getType());
114139
}
115140

116-
unsigned getAtomicOpSize(AtomicRMWInst *RMWI) {
141+
static unsigned getAtomicOpSize(AtomicRMWInst *RMWI) {
117142
const DataLayout &DL = RMWI->getModule()->getDataLayout();
118143
return DL.getTypeStoreSize(RMWI->getValOperand()->getType());
119144
}
120145

121-
unsigned getAtomicOpSize(AtomicCmpXchgInst *CASI) {
146+
static unsigned getAtomicOpSize(AtomicCmpXchgInst *CASI) {
122147
const DataLayout &DL = CASI->getModule()->getDataLayout();
123148
return DL.getTypeStoreSize(CASI->getCompareOperand()->getType());
124149
}
125150

126151
// Helper functions to retrieve the alignment of atomic instructions.
127-
unsigned getAtomicOpAlign(LoadInst *LI) {
152+
static unsigned getAtomicOpAlign(LoadInst *LI) {
128153
unsigned Align = LI->getAlignment();
129154
// In the future, if this IR restriction is relaxed, we should
130155
// return DataLayout::getABITypeAlignment when there's no align
@@ -133,7 +158,7 @@ unsigned getAtomicOpAlign(LoadInst *LI) {
133158
return Align;
134159
}
135160

136-
unsigned getAtomicOpAlign(StoreInst *SI) {
161+
static unsigned getAtomicOpAlign(StoreInst *SI) {
137162
unsigned Align = SI->getAlignment();
138163
// In the future, if this IR restriction is relaxed, we should
139164
// return DataLayout::getABITypeAlignment when there's no align
@@ -142,15 +167,15 @@ unsigned getAtomicOpAlign(StoreInst *SI) {
142167
return Align;
143168
}
144169

145-
unsigned getAtomicOpAlign(AtomicRMWInst *RMWI) {
170+
static unsigned getAtomicOpAlign(AtomicRMWInst *RMWI) {
146171
// TODO(PR27168): This instruction has no alignment attribute, but unlike the
147172
// default alignment for load/store, the default here is to assume
148173
// it has NATURAL alignment, not DataLayout-specified alignment.
149174
const DataLayout &DL = RMWI->getModule()->getDataLayout();
150175
return DL.getTypeStoreSize(RMWI->getValOperand()->getType());
151176
}
152177

153-
unsigned getAtomicOpAlign(AtomicCmpXchgInst *CASI) {
178+
static unsigned getAtomicOpAlign(AtomicCmpXchgInst *CASI) {
154179
// TODO(PR27168): same comment as above.
155180
const DataLayout &DL = CASI->getModule()->getDataLayout();
156181
return DL.getTypeStoreSize(CASI->getCompareOperand()->getType());
@@ -160,14 +185,12 @@ unsigned getAtomicOpAlign(AtomicCmpXchgInst *CASI) {
160185
// and is of appropriate alignment, to be passed through for target
161186
// lowering. (Versus turning into a __atomic libcall)
162187
template <typename Inst>
163-
bool atomicSizeSupported(const TargetLowering *TLI, Inst *I) {
188+
static bool atomicSizeSupported(const TargetLowering *TLI, Inst *I) {
164189
unsigned Size = getAtomicOpSize(I);
165190
unsigned Align = getAtomicOpAlign(I);
166191
return Align >= Size && Size <= TLI->getMaxAtomicSizeInBitsSupported() / 8;
167192
}
168193

169-
} // end anonymous namespace
170-
171194
bool AtomicExpand::runOnFunction(Function &F) {
172195
auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
173196
if (!TPC)
@@ -556,6 +579,7 @@ struct PartwordMaskValues {
556579
Value *Mask;
557580
Value *Inv_Mask;
558581
};
582+
559583
} // end anonymous namespace
560584

561585
/// This is a helper function which builds instructions to provide
@@ -574,7 +598,6 @@ struct PartwordMaskValues {
574598
/// include only the part that would've been loaded from Addr.
575599
///
576600
/// Inv_Mask: The inverse of Mask.
577-
578601
static PartwordMaskValues createMaskInstrs(IRBuilder<> &Builder, Instruction *I,
579602
Type *ValueType, Value *Addr,
580603
unsigned WordSize) {
@@ -680,7 +703,6 @@ static Value *performMaskedAtomicOp(AtomicRMWInst::BinOp Op,
680703
/// part of the value.
681704
void AtomicExpand::expandPartwordAtomicRMW(
682705
AtomicRMWInst *AI, TargetLoweringBase::AtomicExpansionKind ExpansionKind) {
683-
684706
assert(ExpansionKind == TargetLoweringBase::AtomicExpansionKind::CmpXChg);
685707

686708
AtomicOrdering MemOpOrder = AI->getOrdering();
@@ -937,7 +959,6 @@ AtomicCmpXchgInst *AtomicExpand::convertCmpXchgToIntegerType(AtomicCmpXchgInst *
937959
return NewCI;
938960
}
939961

940-
941962
bool AtomicExpand::expandAtomicCmpXchg(AtomicCmpXchgInst *CI) {
942963
AtomicOrdering SuccessOrder = CI->getSuccessOrdering();
943964
AtomicOrdering FailureOrder = CI->getFailureOrdering();

lib/CodeGen/DwarfEHPrepare.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- DwarfEHPrepare - Prepare exception handling for code generation ---===//
1+
//===- DwarfEHPrepare - Prepare exception handling for code generation ----===//
22
//
33
// The LLVM Compiler Infrastructure
44
//
@@ -13,33 +13,43 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#include "llvm/ADT/BitVector.h"
16+
#include "llvm/ADT/SmallVector.h"
1617
#include "llvm/ADT/Statistic.h"
1718
#include "llvm/Analysis/CFG.h"
1819
#include "llvm/Analysis/EHPersonalities.h"
1920
#include "llvm/Analysis/TargetTransformInfo.h"
20-
#include "llvm/CodeGen/Passes.h"
21+
#include "llvm/CodeGen/RuntimeLibcalls.h"
2122
#include "llvm/CodeGen/TargetPassConfig.h"
23+
#include "llvm/IR/BasicBlock.h"
24+
#include "llvm/IR/Constants.h"
25+
#include "llvm/IR/DerivedTypes.h"
2226
#include "llvm/IR/Dominators.h"
2327
#include "llvm/IR/Function.h"
2428
#include "llvm/IR/Instructions.h"
2529
#include "llvm/IR/Module.h"
30+
#include "llvm/IR/Type.h"
2631
#include "llvm/Pass.h"
32+
#include "llvm/Support/Casting.h"
2733
#include "llvm/Target/TargetLowering.h"
34+
#include "llvm/Target/TargetMachine.h"
2835
#include "llvm/Target/TargetSubtargetInfo.h"
2936
#include "llvm/Transforms/Utils/Local.h"
37+
#include <cstddef>
38+
3039
using namespace llvm;
3140

3241
#define DEBUG_TYPE "dwarfehprepare"
3342

3443
STATISTIC(NumResumesLowered, "Number of resume calls lowered");
3544

3645
namespace {
46+
3747
class DwarfEHPrepare : public FunctionPass {
3848
// RewindFunction - _Unwind_Resume or the target equivalent.
39-
Constant *RewindFunction;
49+
Constant *RewindFunction = nullptr;
4050

41-
DominatorTree *DT;
42-
const TargetLowering *TLI;
51+
DominatorTree *DT = nullptr;
52+
const TargetLowering *TLI = nullptr;
4353

4454
bool InsertUnwindResumeCalls(Function &Fn);
4555
Value *GetExceptionObject(ResumeInst *RI);
@@ -51,9 +61,7 @@ namespace {
5161
public:
5262
static char ID; // Pass identification, replacement for typeid.
5363

54-
DwarfEHPrepare()
55-
: FunctionPass(ID), RewindFunction(nullptr), DT(nullptr), TLI(nullptr) {
56-
}
64+
DwarfEHPrepare() : FunctionPass(ID) {}
5765

5866
bool runOnFunction(Function &Fn) override;
5967

@@ -68,9 +76,11 @@ namespace {
6876
return "Exception handling preparation";
6977
}
7078
};
79+
7180
} // end anonymous namespace
7281

7382
char DwarfEHPrepare::ID = 0;
83+
7484
INITIALIZE_PASS_BEGIN(DwarfEHPrepare, DEBUG_TYPE,
7585
"Prepare DWARF exceptions", false, false)
7686
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)

0 commit comments

Comments
 (0)