Skip to content

Commit 6a343d8

Browse files
author
git apple-llvm automerger
committed
Merge commit 'a1eeb5902723' from llvm.org/main into next
2 parents 8b33c65 + a1eeb59 commit 6a343d8

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,14 +1497,11 @@ void ModuleBitcodeWriter::writeModuleInfo() {
14971497
// compute the maximum alignment value.
14981498
std::map<std::string, unsigned> SectionMap;
14991499
std::map<std::string, unsigned> GCMap;
1500-
MaybeAlign MaxAlignment;
1500+
MaybeAlign MaxGVarAlignment;
15011501
unsigned MaxGlobalType = 0;
1502-
const auto UpdateMaxAlignment = [&MaxAlignment](const MaybeAlign A) {
1503-
if (A)
1504-
MaxAlignment = !MaxAlignment ? *A : std::max(*MaxAlignment, *A);
1505-
};
15061502
for (const GlobalVariable &GV : M.globals()) {
1507-
UpdateMaxAlignment(GV.getAlign());
1503+
if (MaybeAlign A = GV.getAlign())
1504+
MaxGVarAlignment = !MaxGVarAlignment ? *A : std::max(*MaxGVarAlignment, *A);
15081505
MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
15091506
if (GV.hasSection()) {
15101507
// Give section names unique ID's.
@@ -1517,7 +1514,6 @@ void ModuleBitcodeWriter::writeModuleInfo() {
15171514
}
15181515
}
15191516
for (const Function &F : M) {
1520-
UpdateMaxAlignment(F.getAlign());
15211517
if (F.hasSection()) {
15221518
// Give section names unique ID's.
15231519
unsigned &Entry = SectionMap[std::string(F.getSection())];
@@ -1553,10 +1549,10 @@ void ModuleBitcodeWriter::writeModuleInfo() {
15531549
//| constant
15541550
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer.
15551551
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // Linkage.
1556-
if (!MaxAlignment) // Alignment.
1552+
if (!MaxGVarAlignment) // Alignment.
15571553
Abbv->Add(BitCodeAbbrevOp(0));
15581554
else {
1559-
unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1555+
unsigned MaxEncAlignment = getEncodedAlign(MaxGVarAlignment);
15601556
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
15611557
Log2_32_Ceil(MaxEncAlignment+1)));
15621558
}

0 commit comments

Comments
 (0)