@@ -1449,7 +1449,7 @@ bool LLParser::parseGlobal(const std::string &Name, unsigned NameID,
14491449 return true ;
14501450 } else if (Lex.getKind () == lltok::kw_align) {
14511451 MaybeAlign Alignment;
1452- if (parseOptionalAlignment (Alignment))
1452+ if (parseOptionalAlignment (lltok::kw_align, Alignment))
14531453 return true ;
14541454 if (Alignment)
14551455 GV->setAlignment (*Alignment);
@@ -1548,7 +1548,7 @@ bool LLParser::parseEnumAttribute(Attribute::AttrKind Attr, AttrBuilder &B,
15481548 return true ;
15491549 Alignment = Align (Value);
15501550 } else {
1551- if (parseOptionalAlignment (Alignment, true ))
1551+ if (parseOptionalAlignment (lltok::kw_align, Alignment, true ))
15521552 return true ;
15531553 }
15541554 B.addAlignmentAttr (Alignment);
@@ -2382,10 +2382,11 @@ bool LLParser::parseOptionalFunctionMetadata(Function &F) {
23822382
23832383// / parseOptionalAlignment
23842384// / ::= /* empty */
2385- // / ::= 'align' 4
2386- bool LLParser::parseOptionalAlignment (MaybeAlign &Alignment, bool AllowParens) {
2385+ // / ::= KW 4
2386+ bool LLParser::parseOptionalAlignment (lltok::Kind KW, MaybeAlign &Alignment,
2387+ bool AllowParens) {
23872388 Alignment = std::nullopt ;
2388- if (!EatIfPresent (lltok::kw_align ))
2389+ if (!EatIfPresent (KW ))
23892390 return false ;
23902391 LocTy AlignLoc = Lex.getLoc ();
23912392 uint64_t Value = 0 ;
@@ -2695,7 +2696,7 @@ bool LLParser::parseOptionalCommaAlign(MaybeAlign &Alignment,
26952696 if (Lex.getKind () != lltok::kw_align)
26962697 return error (Lex.getLoc (), " expected metadata or 'align'" );
26972698
2698- if (parseOptionalAlignment (Alignment))
2699+ if (parseOptionalAlignment (lltok::kw_align, Alignment))
26992700 return true ;
27002701 }
27012702
@@ -6705,7 +6706,7 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine,
67056706 LocTy BuiltinLoc;
67066707 std::string Section;
67076708 std::string Partition;
6708- MaybeAlign Alignment;
6709+ MaybeAlign Alignment, PrefAlignment ;
67096710 std::string GC;
67106711 GlobalValue::UnnamedAddr UnnamedAddr = GlobalValue::UnnamedAddr::None;
67116712 unsigned AddrSpace = 0 ;
@@ -6722,7 +6723,8 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine,
67226723 (EatIfPresent (lltok::kw_section) && parseStringConstant (Section)) ||
67236724 (EatIfPresent (lltok::kw_partition) && parseStringConstant (Partition)) ||
67246725 parseOptionalComdat (FunctionName, C) ||
6725- parseOptionalAlignment (Alignment) ||
6726+ parseOptionalAlignment (lltok::kw_align, Alignment) ||
6727+ parseOptionalAlignment (lltok::kw_prefalign, PrefAlignment) ||
67266728 (EatIfPresent (lltok::kw_gc) && parseStringConstant (GC)) ||
67276729 (EatIfPresent (lltok::kw_prefix) && parseGlobalTypeAndValue (Prefix)) ||
67286730 (EatIfPresent (lltok::kw_prologue) && parseGlobalTypeAndValue (Prologue)) ||
@@ -6824,6 +6826,7 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine,
68246826 Fn->setUnnamedAddr (UnnamedAddr);
68256827 if (Alignment)
68266828 Fn->setAlignment (*Alignment);
6829+ Fn->setPreferredAlignment (PrefAlignment);
68276830 Fn->setSection (Section);
68286831 Fn->setPartition (Partition);
68296832 Fn->setComdat (C);
@@ -8446,7 +8449,7 @@ int LLParser::parseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
84468449 bool AteExtraComma = false ;
84478450 if (EatIfPresent (lltok::comma)) {
84488451 if (Lex.getKind () == lltok::kw_align) {
8449- if (parseOptionalAlignment (Alignment))
8452+ if (parseOptionalAlignment (lltok::kw_align, Alignment))
84508453 return true ;
84518454 if (parseOptionalCommaAddrSpace (AddrSpace, ASLoc, AteExtraComma))
84528455 return true ;
@@ -8461,7 +8464,7 @@ int LLParser::parseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
84618464 return true ;
84628465 if (EatIfPresent (lltok::comma)) {
84638466 if (Lex.getKind () == lltok::kw_align) {
8464- if (parseOptionalAlignment (Alignment))
8467+ if (parseOptionalAlignment (lltok::kw_align, Alignment))
84658468 return true ;
84668469 if (parseOptionalCommaAddrSpace (AddrSpace, ASLoc, AteExtraComma))
84678470 return true ;
0 commit comments