diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2025-08-26 11:22:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-26 11:22:33 -0700 |
commit | a1eeb5902723116cf23e7d52380d1acca5b5530d (patch) | |
tree | 53deb7d94a6f404884519640c04eee09ef1e3f7b /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | 4a4b810c27bf293cf5e32d2801e598c0922d0675 (diff) | |
download | llvm-a1eeb5902723116cf23e7d52380d1acca5b5530d.zip llvm-a1eeb5902723116cf23e7d52380d1acca5b5530d.tar.gz llvm-a1eeb5902723116cf23e7d52380d1acca5b5530d.tar.bz2 |
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: https://github.com/llvm/llvm-project/pull/155341
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index a3f8254..a1d5b36 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1495,14 +1495,11 @@ void ModuleBitcodeWriter::writeModuleInfo() { // compute the maximum alignment value. std::map<std::string, unsigned> SectionMap; std::map<std::string, unsigned> GCMap; - MaybeAlign MaxAlignment; + MaybeAlign MaxGVarAlignment; unsigned MaxGlobalType = 0; - const auto UpdateMaxAlignment = [&MaxAlignment](const MaybeAlign A) { - if (A) - MaxAlignment = !MaxAlignment ? *A : std::max(*MaxAlignment, *A); - }; for (const GlobalVariable &GV : M.globals()) { - UpdateMaxAlignment(GV.getAlign()); + if (MaybeAlign A = GV.getAlign()) + MaxGVarAlignment = !MaxGVarAlignment ? *A : std::max(*MaxGVarAlignment, *A); MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType())); if (GV.hasSection()) { // Give section names unique ID's. @@ -1515,7 +1512,6 @@ void ModuleBitcodeWriter::writeModuleInfo() { } } for (const Function &F : M) { - UpdateMaxAlignment(F.getAlign()); if (F.hasSection()) { // Give section names unique ID's. unsigned &Entry = SectionMap[std::string(F.getSection())]; @@ -1551,10 +1547,10 @@ void ModuleBitcodeWriter::writeModuleInfo() { //| constant Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer. Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // Linkage. - if (!MaxAlignment) // Alignment. + if (!MaxGVarAlignment) // Alignment. Abbv->Add(BitCodeAbbrevOp(0)); else { - unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment); + unsigned MaxEncAlignment = getEncodedAlign(MaxGVarAlignment); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(MaxEncAlignment+1))); } |