Skip to content

Commit 22500e7

Browse files
committed
Update the coding style for all code moved in the previous commit.
Requested by gottesmm during review. Update the variable naming conventions to lower-camel. Run clang-format. I'm sure I missed some local variables somewhere--this was a best effort.
1 parent bddc69c commit 22500e7

File tree

11 files changed

+2014
-1990
lines changed

11 files changed

+2014
-1990
lines changed

include/swift/SIL/OptimizationRemark.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ class Emitter {
157157
using RemarkT = decltype(RemarkBuilder());
158158
// Avoid building the remark unless remarks are enabled.
159159
if (isEnabled<RemarkT>() || Module.getOptRecordStream()) {
160-
auto R = RemarkBuilder();
161-
R.setPassName(PassName);
162-
emit(R);
160+
auto rb = RemarkBuilder();
161+
rb.setPassName(PassName);
162+
emit(rb);
163163
}
164164
}
165165

include/swift/SILOptimizer/Utils/BasicBlockOptUtils.h

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ class BasicBlockCloner;
3232
class SILLoop;
3333
class SILLoopInfo;
3434

35-
/// Remove all instructions in the body of \p BB in safe manner by using
35+
/// Remove all instructions in the body of \p bb in safe manner by using
3636
/// undef.
37-
void clearBlockBody(SILBasicBlock *BB);
37+
void clearBlockBody(SILBasicBlock *bb);
3838

3939
/// Handle the mechanical aspects of removing an unreachable block.
40-
void removeDeadBlock(SILBasicBlock *BB);
40+
void removeDeadBlock(SILBasicBlock *bb);
4141

4242
/// Remove all unreachable blocks in a function.
43-
bool removeUnreachableBlocks(SILFunction &Fn);
43+
bool removeUnreachableBlocks(SILFunction &f);
4444

45-
/// Return true if there are any users of V outside the specified block.
46-
inline bool isUsedOutsideOfBlock(SILValue V) {
47-
auto *BB = V->getParentBlock();
48-
for (auto UI : V->getUses())
49-
if (UI->getUser()->getParent() != BB)
45+
/// Return true if there are any users of v outside the specified block.
46+
inline bool isUsedOutsideOfBlock(SILValue v) {
47+
auto *bb = v->getParentBlock();
48+
for (auto *use : v->getUses())
49+
if (use->getUser()->getParent() != bb)
5050
return true;
5151
return false;
5252
}
@@ -57,13 +57,13 @@ inline bool isUsedOutsideOfBlock(SILValue V) {
5757
/// rotated once. ShouldVerify specifies whether to perform verification after
5858
/// the transformation.
5959
/// Returns true if the loop could be rotated.
60-
bool rotateLoop(SILLoop *L, DominanceInfo *DT, SILLoopInfo *LI,
61-
bool RotateSingleBlockLoops, SILBasicBlock *UpTo,
62-
bool ShouldVerify);
60+
bool rotateLoop(SILLoop *loop, DominanceInfo *domInfo, SILLoopInfo *loopInfo,
61+
bool rotateSingleBlockLoops, SILBasicBlock *upToBB,
62+
bool shouldVerify);
6363

6464
/// Helper function to perform SSA updates in case of jump threading.
65-
void updateSSAAfterCloning(BasicBlockCloner &Cloner, SILBasicBlock *SrcBB,
66-
SILBasicBlock *DestBB);
65+
void updateSSAAfterCloning(BasicBlockCloner &cloner, SILBasicBlock *srcBB,
66+
SILBasicBlock *destBB);
6767

6868
/// Clone a single basic block and any required successor edges within the same
6969
/// function.
@@ -95,14 +95,14 @@ class BasicBlockCloner : public SILCloner<BasicBlockCloner> {
9595

9696
/// Clone the given branch instruction's destination block, splitting
9797
/// its successors, and rewrite the branch instruction.
98-
void cloneBranchTarget(BranchInst *BI) {
99-
assert(origBB == BI->getDestBB());
98+
void cloneBranchTarget(BranchInst *bi) {
99+
assert(origBB == bi->getDestBB());
100100

101-
cloneBlock(/*insertAfter*/BI->getParent());
101+
cloneBlock(/*insertAfter*/ bi->getParent());
102102

103-
SILBuilderWithScope(BI).createBranch(BI->getLoc(), getNewBB(),
104-
BI->getArgs());
105-
BI->eraseFromParent();
103+
SILBuilderWithScope(bi).createBranch(bi->getLoc(), getNewBB(),
104+
bi->getArgs());
105+
bi->eraseFromParent();
106106
}
107107

108108
/// Get the newly cloned block corresponding to `origBB`.
@@ -112,27 +112,27 @@ class BasicBlockCloner : public SILCloner<BasicBlockCloner> {
112112

113113
/// Call this after processing all instructions to fix the control flow
114114
/// graph. The branch cloner may have left critical edges.
115-
bool splitCriticalEdges(DominanceInfo *DT, SILLoopInfo *LI);
115+
bool splitCriticalEdges(DominanceInfo *domInfo, SILLoopInfo *loopInfo);
116116

117117
protected:
118118
// MARK: CRTP overrides.
119119

120120
/// Override getMappedValue to allow values defined outside the block to be
121121
/// cloned to be reused in the newly cloned block.
122-
SILValue getMappedValue(SILValue Value) {
123-
if (auto SI = Value->getDefiningInstruction()) {
124-
if (!isBlockCloned(SI->getParent()))
125-
return Value;
126-
} else if (auto BBArg = dyn_cast<SILArgument>(Value)) {
127-
if (!isBlockCloned(BBArg->getParent()))
128-
return Value;
122+
SILValue getMappedValue(SILValue value) {
123+
if (auto si = value->getDefiningInstruction()) {
124+
if (!isBlockCloned(si->getParent()))
125+
return value;
126+
} else if (auto bbArg = dyn_cast<SILArgument>(value)) {
127+
if (!isBlockCloned(bbArg->getParent()))
128+
return value;
129129
} else {
130-
assert(isa<SILUndef>(Value) && "Unexpected Value kind");
131-
return Value;
130+
assert(isa<SILUndef>(value) && "Unexpected Value kind");
131+
return value;
132132
}
133133
// `value` is not defined outside the cloned block, so consult the cloner's
134134
// map of cloned values.
135-
return SuperTy::getMappedValue(Value);
135+
return SuperTy::getMappedValue(value);
136136
}
137137

138138
void mapValue(SILValue origValue, SILValue mappedValue) {
@@ -150,26 +150,26 @@ class CloneCollector {
150150
typedef std::function<bool (SILInstruction *)> FilterType;
151151

152152
private:
153-
FilterType Filter;
153+
FilterType filter;
154154

155155
// Pairs of collected instructions; (new, old)
156-
llvm::SmallVector<value_type, 4> InstructionPairs;
156+
llvm::SmallVector<value_type, 4> instructionpairs;
157157

158-
void collect(SILInstruction *Old, SILInstruction *New) {
159-
if (Filter(New))
160-
InstructionPairs.push_back(std::make_pair(New, Old));
158+
void collect(SILInstruction *oldI, SILInstruction *newI) {
159+
if (filter(newI))
160+
instructionpairs.push_back(std::make_pair(newI, oldI));
161161
}
162162

163163
public:
164-
CloneCollector(FilterType Filter) : Filter(Filter) {}
164+
CloneCollector(FilterType filter) : filter(filter) {}
165165

166166
CallbackType getCallback() {
167167
return std::bind(&CloneCollector::collect, this, std::placeholders::_1,
168168
std::placeholders::_2);
169169
}
170170

171171
llvm::SmallVectorImpl<value_type> &getInstructionPairs() {
172-
return InstructionPairs;
172+
return instructionpairs;
173173
}
174174
};
175175

@@ -220,37 +220,37 @@ class StaticInitCloner : public SILCloner<StaticInitCloner> {
220220
friend class SILCloner<StaticInitCloner>;
221221

222222
/// The number of not yet cloned operands for each instruction.
223-
llvm::DenseMap<SILInstruction *, int> NumOpsToClone;
223+
llvm::DenseMap<SILInstruction *, int> numOpsToClone;
224224

225225
/// List of instructions for which all operands are already cloned (or which
226226
/// don't have any operands).
227-
llvm::SmallVector<SILInstruction *, 8> ReadyToClone;
227+
llvm::SmallVector<SILInstruction *, 8> readyToClone;
228228

229229
public:
230-
StaticInitCloner(SILGlobalVariable *GVar)
231-
: SILCloner<StaticInitCloner>(GVar) { }
230+
StaticInitCloner(SILGlobalVariable *gVar)
231+
: SILCloner<StaticInitCloner>(gVar) {}
232232

233233
/// Add \p InitVal and all its operands (transitively) for cloning.
234234
///
235235
/// Note: all init values must are added, before calling clone().
236-
void add(SILInstruction *InitVal);
236+
void add(SILInstruction *initVal);
237237

238238
/// Clone \p InitVal and all its operands into the initializer of the
239239
/// SILGlobalVariable.
240240
///
241241
/// \return Returns the cloned instruction in the SILGlobalVariable.
242-
SingleValueInstruction *clone(SingleValueInstruction *InitVal);
242+
SingleValueInstruction *clone(SingleValueInstruction *initVal);
243243

244244
/// Convenience function to clone a single \p InitVal.
245-
static void appendToInitializer(SILGlobalVariable *GVar,
246-
SingleValueInstruction *InitVal) {
247-
StaticInitCloner Cloner(GVar);
248-
Cloner.add(InitVal);
249-
Cloner.clone(InitVal);
245+
static void appendToInitializer(SILGlobalVariable *gVar,
246+
SingleValueInstruction *initVal) {
247+
StaticInitCloner cloner(gVar);
248+
cloner.add(initVal);
249+
cloner.clone(initVal);
250250
}
251251

252252
protected:
253-
SILLocation remapLocation(SILLocation Loc) {
253+
SILLocation remapLocation(SILLocation loc) {
254254
return ArtificialUnreachableLocation();
255255
}
256256
};

include/swift/SILOptimizer/Utils/CFGOptUtils.h

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ class SILLoopInfo;
3939
/// Adds a new argument to an edge between a branch and a destination
4040
/// block.
4141
///
42-
/// \param Branch The terminator to add the argument to.
43-
/// \param Dest The destination block of the edge.
44-
/// \param Val The value to the arguments of the branch.
42+
/// \param branch The terminator to add the argument to.
43+
/// \param dest The destination block of the edge.
44+
/// \param val The value to the arguments of the branch.
4545
/// \return The created branch. The old branch is deleted.
4646
/// The argument is appended at the end of the argument tuple.
47-
TermInst *addNewEdgeValueToBranch(TermInst *Branch, SILBasicBlock *Dest,
48-
SILValue Val);
47+
TermInst *addNewEdgeValueToBranch(TermInst *branch, SILBasicBlock *dest,
48+
SILValue val);
4949

5050
/// Changes the edge value between a branch and destination basic block
5151
/// at the specified index. Changes all edges from \p Branch to \p Dest to carry
5252
/// the value.
5353
///
54-
/// \param Branch The branch to modify.
55-
/// \param Dest The destination of the edge.
56-
/// \param Idx The index of the argument to modify.
57-
/// \param Val The new value to use.
54+
/// \param branch The branch to modify.
55+
/// \param dest The destination of the edge.
56+
/// \param idx The index of the argument to modify.
57+
/// \param val The new value to use.
5858
/// \return The new branch. Deletes the old one.
59-
TermInst *changeEdgeValue(TermInst *Branch, SILBasicBlock *Dest, size_t Idx,
60-
SILValue Val);
59+
TermInst *changeEdgeValue(TermInst *branch, SILBasicBlock *dest, size_t idx,
60+
SILValue val);
6161

6262
/// Deletes the edge value between a branch and a destination basic block at the
6363
/// specified index. Asserts internally that the argument along the edge does
@@ -73,76 +73,80 @@ void erasePhiArgument(SILBasicBlock *block, unsigned argIndex);
7373

7474
/// Replace a branch target.
7575
///
76-
/// \param T The terminating instruction to modify.
77-
/// \param OldDest The successor block that will be replaced.
78-
/// \param NewDest The new target block.
79-
/// \param PreserveArgs If set, preserve arguments on the replaced edge.
80-
void replaceBranchTarget(TermInst *T, SILBasicBlock *OldDest,
81-
SILBasicBlock *NewDest, bool PreserveArgs);
76+
/// \param t The terminating instruction to modify.
77+
/// \param oldDest The successor block that will be replaced.
78+
/// \param newDest The new target block.
79+
/// \param preserveArgs If set, preserve arguments on the replaced edge.
80+
void replaceBranchTarget(TermInst *t, SILBasicBlock *oldDest,
81+
SILBasicBlock *newDest, bool preserveArgs);
8282

8383
/// Check if the edge from the terminator is critical.
84-
bool isCriticalEdge(TermInst *T, unsigned EdgeIdx);
84+
bool isCriticalEdge(TermInst *t, unsigned edgeIdx);
8585

8686
/// Splits the edge from terminator if it is critical.
8787
///
8888
/// Updates dominance information and loop information if not null.
8989
/// Returns the newly created basic block on success or nullptr otherwise (if
9090
/// the edge was not critical).
91-
SILBasicBlock *splitCriticalEdge(TermInst *T, unsigned EdgeIdx,
92-
DominanceInfo *DT = nullptr,
93-
SILLoopInfo *LI = nullptr);
91+
SILBasicBlock *splitCriticalEdge(TermInst *, unsigned edgeIdx,
92+
DominanceInfo *domInfo = nullptr,
93+
SILLoopInfo *loopInfo = nullptr);
9494

9595
/// Splits the critical edges between from and to. This code assumes there is
9696
/// exactly one edge between the two basic blocks. It will return the wrong
9797
/// result if there are multiple edges and will assert if there are no edges in
9898
/// between the two blocks.
9999
///
100100
/// Updates dominance information and loop information if not null.
101-
SILBasicBlock *splitIfCriticalEdge(SILBasicBlock *From, SILBasicBlock *To,
102-
DominanceInfo *DT = nullptr,
103-
SILLoopInfo *LI = nullptr);
101+
SILBasicBlock *splitIfCriticalEdge(SILBasicBlock *from, SILBasicBlock *to,
102+
DominanceInfo *domInfo = nullptr,
103+
SILLoopInfo *loopInfo = nullptr);
104104

105105
/// Splits all critical edges originating from `fromBB`.
106-
bool splitCriticalEdgesFrom(SILBasicBlock *fromBB, DominanceInfo *DT = nullptr,
107-
SILLoopInfo *LI = nullptr);
106+
bool splitCriticalEdgesFrom(SILBasicBlock *fromBB,
107+
DominanceInfo *domInfo = nullptr,
108+
SILLoopInfo *loopInfo = nullptr);
108109

109110
/// Splits the edges between two basic blocks.
110111
///
111112
/// Updates dominance information and loop information if not null.
112-
void splitEdgesFromTo(SILBasicBlock *From, SILBasicBlock *To,
113-
DominanceInfo *DT = nullptr, SILLoopInfo *LI = nullptr);
113+
void splitEdgesFromTo(SILBasicBlock *from, SILBasicBlock *to,
114+
DominanceInfo *domInfo = nullptr,
115+
SILLoopInfo *loopInfo = nullptr);
114116

115117
/// Splits the basic block before the instruction with an unconditional branch
116118
/// and updates the dominator tree and loop info. Returns the new, branched to
117119
/// block that contains the end of \p SplitBeforeInst's block.
118-
SILBasicBlock *splitBasicBlockAndBranch(SILBuilder &B,
119-
SILInstruction *SplitBeforeInst,
120-
DominanceInfo *DT, SILLoopInfo *LI);
120+
SILBasicBlock *splitBasicBlockAndBranch(SILBuilder &builder,
121+
SILInstruction *splitBeforeInst,
122+
DominanceInfo *domInfo,
123+
SILLoopInfo *loopInfo);
121124

122125
/// Return true if the function has a critical edge, false otherwise.
123-
bool hasCriticalEdges(SILFunction &F, bool OnlyNonCondBr);
126+
bool hasCriticalEdges(SILFunction &f, bool onlyNonCondBr);
124127

125128
/// Split all critical edges in the given function, updating the
126129
/// dominator tree and loop information if they are provided.
127130
///
128131
/// FIXME: This should never be called! Fix passes that create critical edges.
129-
bool splitAllCriticalEdges(SILFunction &F, DominanceInfo *DT, SILLoopInfo *LI);
132+
bool splitAllCriticalEdges(SILFunction &F, DominanceInfo *domInfo,
133+
SILLoopInfo *loopInfo);
130134

131135
/// Split all cond_br critical edges with non-trivial arguments in the
132136
/// function updating the dominator tree and loop information (if they are not
133137
/// set to null).
134138
///
135139
/// A current invariant of Ownership SIL is that cond_br can only have critical
136140
/// edges with non-trivial arguments. This simplifies computation.
137-
bool splitAllCondBrCriticalEdgesWithNonTrivialArgs(SILFunction &Fn,
138-
DominanceInfo *DT,
139-
SILLoopInfo *LI);
141+
bool splitAllCondBrCriticalEdgesWithNonTrivialArgs(SILFunction &fn,
142+
DominanceInfo *domInfo,
143+
SILLoopInfo *loopInfo);
140144

141145
/// Merge a basic block ending in a branch with its successor
142146
/// if possible. If dominance information or loop info is non null update it.
143147
/// Return true if block was merged.
144-
bool mergeBasicBlockWithSuccessor(SILBasicBlock *BB, DominanceInfo *DT,
145-
SILLoopInfo *LI);
148+
bool mergeBasicBlockWithSuccessor(SILBasicBlock *bb, DominanceInfo *domInfo,
149+
SILLoopInfo *loopInfo);
146150

147151
/// Merge basic blocks in the given function by eliminating all unconditional
148152
/// branches to single-predecessor branch targets.
@@ -152,7 +156,7 @@ bool mergeBasicBlockWithSuccessor(SILBasicBlock *BB, DominanceInfo *DT,
152156
/// is not done on-the-fly after splitting blocks because merging is linear in
153157
/// the number of instructions, so interleaved merging and splitting is
154158
/// quadratic.
155-
bool mergeBasicBlocks(SILFunction *F);
159+
bool mergeBasicBlocks(SILFunction *f);
156160

157161
/// Given a list of \p UserBlocks and a list of \p DefBlocks, find a set of
158162
/// blocks that together with \p UserBlocks joint-postdominate \p
@@ -181,11 +185,11 @@ bool mergeBasicBlocks(SILFunction *F);
181185
///
182186
/// *NOTE* This completion may not be unique.
183187
void completeJointPostDominanceSet(
184-
ArrayRef<SILBasicBlock *> UserBlocks, ArrayRef<SILBasicBlock *> DefBlocks,
185-
llvm::SmallVectorImpl<SILBasicBlock *> &Completion);
188+
ArrayRef<SILBasicBlock *> userBlocks, ArrayRef<SILBasicBlock *> defBlocks,
189+
llvm::SmallVectorImpl<SILBasicBlock *> &completion);
186190

187-
/// Return true if we conservatively find all BB's that are non-failure exit
188-
/// basic blocks and place them in \p BBs. If we find something we don't
191+
/// Return true if we conservatively find all bb's that are non-failure exit
192+
/// basic blocks and place them in \p bbs. If we find something we don't
189193
/// understand, bail.
190194
///
191195
/// A non-failure exit BB is defined as a BB that:
@@ -202,8 +206,8 @@ void completeJointPostDominanceSet(
202206
/// implying in most cases this will be one element.
203207
///
204208
/// TODO:
205-
bool findAllNonFailureExitBBs(SILFunction *F,
206-
llvm::TinyPtrVector<SILBasicBlock *> &BBs);
209+
bool findAllNonFailureExitBBs(SILFunction *f,
210+
llvm::TinyPtrVector<SILBasicBlock *> &bbs);
207211

208212
} // end namespace swift
209213

0 commit comments

Comments
 (0)