Skip to content

Commit a1eeb59

Browse files
authored
Bitcode: Stop combining function alignments into MaxAlignment.
MaxAlignment is used to produce the abbreviation for MODULE_CODE_GLOBALVAR and is not used for anything related to function alignments, so stop combining function alignments and rename it to make its purpose clearer. Reviewers: teresajohnson Reviewed By: teresajohnson Pull Request: llvm#155341
1 parent 4a4b810 commit a1eeb59

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
@@ -1495,14 +1495,11 @@ void ModuleBitcodeWriter::writeModuleInfo() {
14951495
// compute the maximum alignment value.
14961496
std::map<std::string, unsigned> SectionMap;
14971497
std::map<std::string, unsigned> GCMap;
1498-
MaybeAlign MaxAlignment;
1498+
MaybeAlign MaxGVarAlignment;
14991499
unsigned MaxGlobalType = 0;
1500-
const auto UpdateMaxAlignment = [&MaxAlignment](const MaybeAlign A) {
1501-
if (A)
1502-
MaxAlignment = !MaxAlignment ? *A : std::max(*MaxAlignment, *A);
1503-
};
15041500
for (const GlobalVariable &GV : M.globals()) {
1505-
UpdateMaxAlignment(GV.getAlign());
1501+
if (MaybeAlign A = GV.getAlign())
1502+
MaxGVarAlignment = !MaxGVarAlignment ? *A : std::max(*MaxGVarAlignment, *A);
15061503
MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
15071504
if (GV.hasSection()) {
15081505
// Give section names unique ID's.
@@ -1515,7 +1512,6 @@ void ModuleBitcodeWriter::writeModuleInfo() {
15151512
}
15161513
}
15171514
for (const Function &F : M) {
1518-
UpdateMaxAlignment(F.getAlign());
15191515
if (F.hasSection()) {
15201516
// Give section names unique ID's.
15211517
unsigned &Entry = SectionMap[std::string(F.getSection())];
@@ -1551,10 +1547,10 @@ void ModuleBitcodeWriter::writeModuleInfo() {
15511547
//| constant
15521548
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer.
15531549
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // Linkage.
1554-
if (!MaxAlignment) // Alignment.
1550+
if (!MaxGVarAlignment) // Alignment.
15551551
Abbv->Add(BitCodeAbbrevOp(0));
15561552
else {
1557-
unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1553+
unsigned MaxEncAlignment = getEncodedAlign(MaxGVarAlignment);
15581554
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
15591555
Log2_32_Ceil(MaxEncAlignment+1)));
15601556
}

0 commit comments

Comments
 (0)