Skip to content

Commit e8283ec

Browse files
authored
[NFC] Apply clang-tidy fixes in Optimizer directories
1 parent 982e852 commit e8283ec

File tree

21 files changed

+357
-357
lines changed

21 files changed

+357
-357
lines changed

flang/include/flang/Optimizer/Analysis/IteratedDominanceFrontier.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,31 @@ namespace fir {
4545
template <class NodeTy, bool IsPostDom>
4646
class IDFCalculator {
4747
public:
48-
IDFCalculator(mlir::DominanceInfo &DT) : DT(DT), useLiveIn(false) {}
48+
IDFCalculator(mlir::DominanceInfo &dt) : dt(dt), useLiveIn(false) {}
4949

5050
/// Give the IDF calculator the set of blocks in which the value is
5151
/// defined. This is equivalent to the set of starting blocks it should be
5252
/// calculating the IDF for (though later gets pruned based on liveness).
5353
///
5454
/// Note: This set *must* live for the entire lifetime of the IDF calculator.
55-
void setDefiningBlocks(const llvm::SmallPtrSetImpl<NodeTy *> &Blocks) {
56-
DefBlocks = &Blocks;
55+
void setDefiningBlocks(const llvm::SmallPtrSetImpl<NodeTy *> &blocks) {
56+
defBlocks = &blocks;
5757
}
5858

5959
/// Give the IDF calculator the set of blocks in which the value is
6060
/// live on entry to the block. This is used to prune the IDF calculation to
6161
/// not include blocks where any phi insertion would be dead.
6262
///
6363
/// Note: This set *must* live for the entire lifetime of the IDF calculator.
64-
void setLiveInBlocks(const llvm::SmallPtrSetImpl<NodeTy *> &Blocks) {
65-
LiveInBlocks = &Blocks;
64+
void setLiveInBlocks(const llvm::SmallPtrSetImpl<NodeTy *> &blocks) {
65+
liveInBlocks = &blocks;
6666
useLiveIn = true;
6767
}
6868

6969
/// Reset the live-in block set to be empty, and tell the IDF
7070
/// calculator to not use liveness anymore.
7171
void resetLiveInBlocks() {
72-
LiveInBlocks = nullptr;
72+
liveInBlocks = nullptr;
7373
useLiveIn = false;
7474
}
7575

@@ -79,13 +79,13 @@ class IDFCalculator {
7979
/// the file-level comment. It performs DF->IDF pruning using the live-in
8080
/// set, to avoid computing the IDF for blocks where an inserted PHI node
8181
/// would be dead.
82-
void calculate(llvm::SmallVectorImpl<NodeTy *> &IDFBlocks);
82+
void calculate(llvm::SmallVectorImpl<NodeTy *> &idfBlocks);
8383

8484
private:
85-
mlir::DominanceInfo &DT;
85+
mlir::DominanceInfo &dt;
8686
bool useLiveIn;
87-
const llvm::SmallPtrSetImpl<NodeTy *> *LiveInBlocks;
88-
const llvm::SmallPtrSetImpl<NodeTy *> *DefBlocks;
87+
const llvm::SmallPtrSetImpl<NodeTy *> *liveInBlocks;
88+
const llvm::SmallPtrSetImpl<NodeTy *> *defBlocks;
8989
};
9090

9191
typedef IDFCalculator<mlir::Block, false> ForwardIDFCalculator;

flang/include/flang/Optimizer/Builder/BoxValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class ExtendedValue : public details::matcher<ExtendedValue> {
413413
template <typename A, typename = std::enable_if_t<
414414
!std::is_same_v<std::decay_t<A>, ExtendedValue>>>
415415
constexpr ExtendedValue(A &&a) : box{std::forward<A>(a)} {
416-
if (auto b = getUnboxed()) {
416+
if (const auto *b = getUnboxed()) {
417417
if (*b) {
418418
auto type = b->getType();
419419
if (type.template isa<fir::BoxCharType>())

flang/include/flang/Optimizer/Builder/Runtime/Assign.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Location;
1616

1717
namespace fir {
1818
class FirOpBuilder;
19-
}
19+
} // namespace fir
2020

2121
namespace fir::runtime {
2222

flang/include/flang/Optimizer/Builder/Runtime/Derived.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Location;
1616

1717
namespace fir {
1818
class FirOpBuilder;
19-
}
19+
} // namespace fir
2020

2121
namespace fir::runtime {
2222

flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct c_double_complex_t;
3434

3535
namespace Fortran::runtime {
3636
class Descriptor;
37-
}
37+
} // namespace Fortran::runtime
3838

3939
namespace fir::runtime {
4040

flang/include/flang/Optimizer/CodeGen/CodeGen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using LLVMIRLoweringPrinter =
4444
std::unique_ptr<mlir::Pass> createLLVMDialectToLLVMPass(
4545
llvm::raw_ostream &output,
4646
LLVMIRLoweringPrinter printer =
47-
[](llvm::Module &M, llvm::raw_ostream &out) { M.print(out, nullptr); });
47+
[](llvm::Module &m, llvm::raw_ostream &out) { m.print(out, nullptr); });
4848

4949
// declarative passes
5050
#define GEN_PASS_REGISTRATION

flang/include/flang/Optimizer/Support/FIRContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace mlir {
2424
class ModuleOp;
25-
}
25+
} // namespace mlir
2626

2727
namespace fir {
2828
class KindMapping;

flang/lib/Optimizer/Analysis/IteratedDominanceFrontier.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace fir {
2323

2424
template <class NodeTy, bool IsPostDom>
2525
void IDFCalculator<NodeTy, IsPostDom>::calculate(
26-
llvm::SmallVectorImpl<NodeTy *> &PHIBlocks) {
26+
llvm::SmallVectorImpl<NodeTy *> &phiBlocks) {
2727
// Use a priority queue keyed on dominator tree level so that inserted nodes
2828
// are handled from the bottom of the dominator tree upwards. We also augment
2929
// the level with a DFS number to ensure that the blocks are ordered in a
@@ -35,68 +35,68 @@ void IDFCalculator<NodeTy, IsPostDom>::calculate(
3535
std::priority_queue<DomTreeNodePair,
3636
llvm::SmallVector<DomTreeNodePair, 32>,
3737
llvm::less_second>;
38-
IDFPriorityQueue PQ;
38+
IDFPriorityQueue pq;
3939

40-
if (DefBlocks->empty())
40+
if (defBlocks->empty())
4141
return;
4242

43-
DT.updateDFSNumbers();
43+
dt.updateDFSNumbers();
4444

45-
for (NodeTy *BB : *DefBlocks) {
46-
if (DomTreeNode *Node = DT.getNode(BB))
47-
PQ.push({Node, std::make_pair(Node->getLevel(), Node->getDFSNumIn())});
45+
for (NodeTy *bb : *defBlocks) {
46+
if (DomTreeNode *node = dt.getNode(bb))
47+
pq.push({node, std::make_pair(node->getLevel(), node->getDFSNumIn())});
4848
}
4949

50-
llvm::SmallVector<DomTreeNode *, 32> Worklist;
51-
llvm::SmallPtrSet<DomTreeNode *, 32> VisitedPQ;
52-
llvm::SmallPtrSet<DomTreeNode *, 32> VisitedWorklist;
50+
llvm::SmallVector<DomTreeNode *, 32> worklist;
51+
llvm::SmallPtrSet<DomTreeNode *, 32> visitedpq;
52+
llvm::SmallPtrSet<DomTreeNode *, 32> visitedWorklist;
5353

54-
while (!PQ.empty()) {
55-
DomTreeNodePair RootPair = PQ.top();
56-
PQ.pop();
57-
DomTreeNode *Root = RootPair.first;
58-
unsigned RootLevel = RootPair.second.first;
54+
while (!pq.empty()) {
55+
DomTreeNodePair rootPair = pq.top();
56+
pq.pop();
57+
DomTreeNode *root = rootPair.first;
58+
unsigned rootLevel = rootPair.second.first;
5959

6060
// Walk all dominator tree children of Root, inspecting their CFG edges with
6161
// targets elsewhere on the dominator tree. Only targets whose level is at
6262
// most Root's level are added to the iterated dominance frontier of the
6363
// definition set.
6464

65-
Worklist.clear();
66-
Worklist.push_back(Root);
67-
VisitedWorklist.insert(Root);
65+
worklist.clear();
66+
worklist.push_back(root);
67+
visitedWorklist.insert(root);
6868

69-
while (!Worklist.empty()) {
70-
DomTreeNode *Node = Worklist.pop_back_val();
71-
NodeTy *BB = Node->getBlock();
69+
while (!worklist.empty()) {
70+
DomTreeNode *node = worklist.pop_back_val();
71+
NodeTy *bb = node->getBlock();
7272
// Succ is the successor in the direction we are calculating IDF, so it is
7373
// successor for IDF, and predecessor for Reverse IDF.
74-
auto DoWork = [&](NodeTy *Succ) {
75-
DomTreeNode *SuccNode = DT.getNode(Succ);
74+
auto doWork = [&](NodeTy *succ) {
75+
DomTreeNode *succNode = dt.getNode(succ);
7676

77-
const unsigned SuccLevel = SuccNode->getLevel();
78-
if (SuccLevel > RootLevel)
77+
const unsigned succLevel = succNode->getLevel();
78+
if (succLevel > rootLevel)
7979
return;
8080

81-
if (!VisitedPQ.insert(SuccNode).second)
81+
if (!visitedpq.insert(succNode).second)
8282
return;
8383

84-
NodeTy *SuccBB = SuccNode->getBlock();
85-
if (useLiveIn && !LiveInBlocks->count(SuccBB))
84+
NodeTy *succBB = succNode->getBlock();
85+
if (useLiveIn && !liveInBlocks->count(succBB))
8686
return;
8787

88-
PHIBlocks.emplace_back(SuccBB);
89-
if (!DefBlocks->count(SuccBB))
90-
PQ.push(std::make_pair(
91-
SuccNode, std::make_pair(SuccLevel, SuccNode->getDFSNumIn())));
88+
phiBlocks.emplace_back(succBB);
89+
if (!defBlocks->count(succBB))
90+
pq.push(std::make_pair(
91+
succNode, std::make_pair(succLevel, succNode->getDFSNumIn())));
9292
};
9393

94-
for (auto *Succ : BB->getSuccessors())
95-
DoWork(Succ);
94+
for (auto *succ : bb->getSuccessors())
95+
doWork(succ);
9696

97-
for (auto DomChild : *Node) {
98-
if (VisitedWorklist.insert(DomChild).second)
99-
Worklist.push_back(DomChild);
97+
for (auto domChild : *node) {
98+
if (visitedWorklist.insert(domChild).second)
99+
worklist.push_back(domChild);
100100
}
101101
}
102102
}

flang/lib/Optimizer/Builder/Character.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ LLVM_ATTRIBUTE_UNUSED static bool needToMaterialize(mlir::Value str) {
7070

7171
/// Unwrap integer constant from mlir::Value.
7272
static llvm::Optional<std::int64_t> getIntIfConstant(mlir::Value value) {
73-
if (auto definingOp = value.getDefiningOp())
73+
if (auto *definingOp = value.getDefiningOp())
7474
if (auto cst = mlir::dyn_cast<mlir::ConstantOp>(definingOp))
7575
if (auto intAttr = cst.getValue().dyn_cast<mlir::IntegerAttr>())
7676
return intAttr.getInt();
@@ -135,7 +135,7 @@ fir::factory::CharacterExprHelper::toExtendedValue(mlir::Value character,
135135
// If the embox is accessible, use its operand to avoid filling
136136
// the generated fir with embox/unbox.
137137
mlir::Value boxCharLen;
138-
if (auto definingOp = character.getDefiningOp()) {
138+
if (auto *definingOp = character.getDefiningOp()) {
139139
if (auto box = dyn_cast<fir::EmboxCharOp>(definingOp)) {
140140
base = box.memref();
141141
boxCharLen = box.len();

flang/lib/Optimizer/Builder/FIRBuilder.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,21 @@ mlir::Value
9292
fir::FirOpBuilder::createRealConstant(mlir::Location loc, mlir::Type fltTy,
9393
llvm::APFloat::integerPart val) {
9494
auto apf = [&]() -> llvm::APFloat {
95-
if (auto ty = fltTy.dyn_cast<fir::RealType>()) {
95+
if (auto ty = fltTy.dyn_cast<fir::RealType>())
9696
return llvm::APFloat(kindMap.getFloatSemantics(ty.getFKind()), val);
97-
} else {
98-
if (fltTy.isF16())
99-
return llvm::APFloat(llvm::APFloat::IEEEhalf(), val);
100-
if (fltTy.isBF16())
101-
return llvm::APFloat(llvm::APFloat::BFloat(), val);
102-
if (fltTy.isF32())
103-
return llvm::APFloat(llvm::APFloat::IEEEsingle(), val);
104-
if (fltTy.isF64())
105-
return llvm::APFloat(llvm::APFloat::IEEEdouble(), val);
106-
if (fltTy.isF80())
107-
return llvm::APFloat(llvm::APFloat::x87DoubleExtended(), val);
108-
if (fltTy.isF128())
109-
return llvm::APFloat(llvm::APFloat::IEEEquad(), val);
110-
llvm_unreachable("unhandled MLIR floating-point type");
111-
}
97+
if (fltTy.isF16())
98+
return llvm::APFloat(llvm::APFloat::IEEEhalf(), val);
99+
if (fltTy.isBF16())
100+
return llvm::APFloat(llvm::APFloat::BFloat(), val);
101+
if (fltTy.isF32())
102+
return llvm::APFloat(llvm::APFloat::IEEEsingle(), val);
103+
if (fltTy.isF64())
104+
return llvm::APFloat(llvm::APFloat::IEEEdouble(), val);
105+
if (fltTy.isF80())
106+
return llvm::APFloat(llvm::APFloat::x87DoubleExtended(), val);
107+
if (fltTy.isF128())
108+
return llvm::APFloat(llvm::APFloat::IEEEquad(), val);
109+
llvm_unreachable("unhandled MLIR floating-point type");
112110
};
113111
return createRealConstant(loc, fltTy, apf());
114112
}

0 commit comments

Comments
 (0)