Skip to content

Commit b7e157c

Browse files
authored
[Transforms][NFC] Tiny fixes in SplitModule (llvm#95903)
Fix repeated map lookup, variable name, formatting and a missing space.
1 parent 9a9546e commit b7e157c

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

llvm/lib/Transforms/Utils/SplitModule.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ static void findPartitions(Module &M, ClusterIDMapType &ClusterIDMap,
105105
// At this point module should have the proper mix of globals and locals.
106106
// As we attempt to partition this module, we must not change any
107107
// locals to globals.
108-
LLVM_DEBUG(dbgs() << "Partition module with (" << M.size() << ")functions\n");
108+
LLVM_DEBUG(dbgs() << "Partition module with (" << M.size()
109+
<< ") functions\n");
109110
ClusterMapType GVtoClusterMap;
110111
ComdatMembersType ComdatMembers;
111112

@@ -164,10 +165,10 @@ static void findPartitions(Module &M, ClusterIDMapType &ClusterIDMap,
164165
std::priority_queue<std::pair<unsigned, unsigned>,
165166
std::vector<std::pair<unsigned, unsigned>>,
166167
decltype(CompareClusters)>
167-
BalancinQueue(CompareClusters);
168+
BalancingQueue(CompareClusters);
168169
// Pre-populate priority queue with N slot blanks.
169170
for (unsigned i = 0; i < N; ++i)
170-
BalancinQueue.push(std::make_pair(i, 0));
171+
BalancingQueue.push(std::make_pair(i, 0));
171172

172173
using SortType = std::pair<unsigned, ClusterMapType::iterator>;
173174

@@ -177,11 +178,13 @@ static void findPartitions(Module &M, ClusterIDMapType &ClusterIDMap,
177178
// To guarantee determinism, we have to sort SCC according to size.
178179
// When size is the same, use leader's name.
179180
for (ClusterMapType::iterator I = GVtoClusterMap.begin(),
180-
E = GVtoClusterMap.end(); I != E; ++I)
181+
E = GVtoClusterMap.end();
182+
I != E; ++I)
181183
if (I->isLeader())
182184
Sets.push_back(
183185
std::make_pair(std::distance(GVtoClusterMap.member_begin(I),
184-
GVtoClusterMap.member_end()), I));
186+
GVtoClusterMap.member_end()),
187+
I));
185188

186189
llvm::sort(Sets, [](const SortType &a, const SortType &b) {
187190
if (a.first == b.first)
@@ -191,9 +194,9 @@ static void findPartitions(Module &M, ClusterIDMapType &ClusterIDMap,
191194
});
192195

193196
for (auto &I : Sets) {
194-
unsigned CurrentClusterID = BalancinQueue.top().first;
195-
unsigned CurrentClusterSize = BalancinQueue.top().second;
196-
BalancinQueue.pop();
197+
unsigned CurrentClusterID = BalancingQueue.top().first;
198+
unsigned CurrentClusterSize = BalancingQueue.top().second;
199+
BalancingQueue.pop();
197200

198201
LLVM_DEBUG(dbgs() << "Root[" << CurrentClusterID << "] cluster_size("
199202
<< I.first << ") ----> " << I.second->getData()->getName()
@@ -211,7 +214,7 @@ static void findPartitions(Module &M, ClusterIDMapType &ClusterIDMap,
211214
CurrentClusterSize++;
212215
}
213216
// Add this set size to the number of entries in this cluster.
214-
BalancinQueue.push(std::make_pair(CurrentClusterID, CurrentClusterSize));
217+
BalancingQueue.push(std::make_pair(CurrentClusterID, CurrentClusterSize));
215218
}
216219
}
217220

@@ -275,8 +278,8 @@ void llvm::SplitModule(
275278
ValueToValueMapTy VMap;
276279
std::unique_ptr<Module> MPart(
277280
CloneModule(M, VMap, [&](const GlobalValue *GV) {
278-
if (ClusterIDMap.count(GV))
279-
return (ClusterIDMap[GV] == I);
281+
if (auto It = ClusterIDMap.find(GV); It != ClusterIDMap.end())
282+
return It->second == I;
280283
else
281284
return isInPartition(GV, I, N);
282285
}));

0 commit comments

Comments
 (0)