Skip to content

Commit e04dd68

Browse files
authored
[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 bda0514 commit e04dd68

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)