Skip to content

Commit 8defa12

Browse files
toppercchencha3
authored andcommitted
[GlobalMerge] Use vector::assign in place of fill+resize. NFC (llvm#85723)
Noticed while reviewing the code. If the resize causes a new allocation, this will fill the new allocation with zeroes directly. Previously, we would fill the old allocation with zeroes, then copy them to the new allocation before filling the additional space with zeros.
1 parent 6cc7bfe commit 8defa12

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/lib/CodeGen/GlobalMerge.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,9 @@ bool GlobalMergeImpl::doMerge(SmallVectorImpl<GlobalVariable *> &Globals,
309309
for (size_t GI = 0, GE = Globals.size(); GI != GE; ++GI) {
310310
GlobalVariable *GV = Globals[GI];
311311

312-
// Reset the encountered sets for this global...
313-
std::fill(EncounteredUGS.begin(), EncounteredUGS.end(), 0);
314-
// ...and grow it in case we created new sets for the previous global.
315-
EncounteredUGS.resize(UsedGlobalSets.size());
312+
// Reset the encountered sets for this global and grow it in case we created
313+
// new sets for the previous global.
314+
EncounteredUGS.assign(UsedGlobalSets.size(), 0);
316315

317316
// We might need to create a set that only consists of the current global.
318317
// Keep track of its index into UsedGlobalSets.

0 commit comments

Comments
 (0)