@@ -775,12 +775,7 @@ void MergeFunctions::writeAlias(Function *F, Function *G) {
775775 auto *GA = GlobalAlias::create (G->getValueType (), PtrType->getAddressSpace (),
776776 G->getLinkage (), " " , BitcastF, G->getParent ());
777777
778- const MaybeAlign FAlign = F->getAlign ();
779- const MaybeAlign GAlign = G->getAlign ();
780- if (FAlign || GAlign)
781- F->setAlignment (std::max (FAlign.valueOrOne (), GAlign.valueOrOne ()));
782- else
783- F->setAlignment (std::nullopt );
778+ F->setAlignment (MaybeAlign (std::max (F->getAlignment (), G->getAlignment ())));
784779 GA->takeName (G);
785780 GA->setVisibility (G->getVisibility ());
786781 GA->setUnnamedAddr (GlobalValue::UnnamedAddr::Global);
@@ -827,15 +822,12 @@ void MergeFunctions::mergeTwoFunctions(Function *F, Function *G) {
827822 removeUsers (F);
828823 F->replaceAllUsesWith (NewF);
829824
825+ MaybeAlign MaxAlignment (std::max (G->getAlignment (), NewF->getAlignment ()));
826+
830827 writeThunkOrAlias (F, G);
831828 writeThunkOrAlias (F, NewF);
832829
833- const MaybeAlign NewFAlign = NewF->getAlign ();
834- const MaybeAlign GAlign = G->getAlign ();
835- if (NewFAlign || GAlign)
836- F->setAlignment (std::max (NewFAlign.valueOrOne (), GAlign.valueOrOne ()));
837- else
838- F->setAlignment (std::nullopt );
830+ F->setAlignment (MaxAlignment);
839831 F->setLinkage (GlobalValue::PrivateLinkage);
840832 ++NumDoubleWeak;
841833 ++NumFunctionsMerged;
0 commit comments