@@ -1497,14 +1497,11 @@ void ModuleBitcodeWriter::writeModuleInfo() {
1497
1497
// compute the maximum alignment value.
1498
1498
std::map<std::string, unsigned > SectionMap;
1499
1499
std::map<std::string, unsigned > GCMap;
1500
- MaybeAlign MaxAlignment ;
1500
+ MaybeAlign MaxGVarAlignment ;
1501
1501
unsigned MaxGlobalType = 0 ;
1502
- const auto UpdateMaxAlignment = [&MaxAlignment](const MaybeAlign A) {
1503
- if (A)
1504
- MaxAlignment = !MaxAlignment ? *A : std::max (*MaxAlignment, *A);
1505
- };
1506
1502
for (const GlobalVariable &GV : M.globals ()) {
1507
- UpdateMaxAlignment (GV.getAlign ());
1503
+ if (MaybeAlign A = GV.getAlign ())
1504
+ MaxGVarAlignment = !MaxGVarAlignment ? *A : std::max (*MaxGVarAlignment, *A);
1508
1505
MaxGlobalType = std::max (MaxGlobalType, VE.getTypeID (GV.getValueType ()));
1509
1506
if (GV.hasSection ()) {
1510
1507
// Give section names unique ID's.
@@ -1517,7 +1514,6 @@ void ModuleBitcodeWriter::writeModuleInfo() {
1517
1514
}
1518
1515
}
1519
1516
for (const Function &F : M) {
1520
- UpdateMaxAlignment (F.getAlign ());
1521
1517
if (F.hasSection ()) {
1522
1518
// Give section names unique ID's.
1523
1519
unsigned &Entry = SectionMap[std::string (F.getSection ())];
@@ -1553,10 +1549,10 @@ void ModuleBitcodeWriter::writeModuleInfo() {
1553
1549
// | constant
1554
1550
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // Initializer.
1555
1551
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 5 )); // Linkage.
1556
- if (!MaxAlignment) // Alignment.
1552
+ if (!MaxGVarAlignment) // Alignment.
1557
1553
Abbv->Add (BitCodeAbbrevOp (0 ));
1558
1554
else {
1559
- unsigned MaxEncAlignment = getEncodedAlign (MaxAlignment );
1555
+ unsigned MaxEncAlignment = getEncodedAlign (MaxGVarAlignment );
1560
1556
Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed,
1561
1557
Log2_32_Ceil (MaxEncAlignment+1 )));
1562
1558
}
0 commit comments