aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/MergeFunctions.cpp
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2022-12-12 16:37:51 +0000
committerGuillaume Chatelet <gchatelet@google.com>2022-12-12 16:38:18 +0000
commit3bbfaee23d41c099547c652f87b252ab6e1f6c46 (patch)
tree58824c49cb66eabbfce741129704f562fb3f6110 /llvm/lib/Transforms/IPO/MergeFunctions.cpp
parent56fd846f370adf16bea333b12637038ea2f3c225 (diff)
downloadllvm-3bbfaee23d41c099547c652f87b252ab6e1f6c46.zip
llvm-3bbfaee23d41c099547c652f87b252ab6e1f6c46.tar.gz
llvm-3bbfaee23d41c099547c652f87b252ab6e1f6c46.tar.bz2
[reland][Alignment][NFC] Remove access to deprecated GlobalObject::getAlignment from llvm
Differential Revision: https://reviews.llvm.org/D139836
Diffstat (limited to 'llvm/lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index b850591..2c02a39 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -775,7 +775,12 @@ void MergeFunctions::writeAlias(Function *F, Function *G) {
auto *GA = GlobalAlias::create(G->getValueType(), PtrType->getAddressSpace(),
G->getLinkage(), "", BitcastF, G->getParent());
- F->setAlignment(MaybeAlign(std::max(F->getAlignment(), G->getAlignment())));
+ const MaybeAlign FAlign = F->getAlign();
+ const MaybeAlign GAlign = G->getAlign();
+ if (FAlign || GAlign)
+ F->setAlignment(std::max(FAlign.valueOrOne(), GAlign.valueOrOne()));
+ else
+ F->setAlignment(std::nullopt);
GA->takeName(G);
GA->setVisibility(G->getVisibility());
GA->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
@@ -822,12 +827,15 @@ void MergeFunctions::mergeTwoFunctions(Function *F, Function *G) {
removeUsers(F);
F->replaceAllUsesWith(NewF);
- MaybeAlign MaxAlignment(std::max(G->getAlignment(), NewF->getAlignment()));
-
writeThunkOrAlias(F, G);
writeThunkOrAlias(F, NewF);
- F->setAlignment(MaxAlignment);
+ const MaybeAlign NewFAlign = NewF->getAlign();
+ const MaybeAlign GAlign = G->getAlign();
+ if (NewFAlign || GAlign)
+ F->setAlignment(std::max(NewFAlign.valueOrOne(), GAlign.valueOrOne()));
+ else
+ F->setAlignment(std::nullopt);
F->setLinkage(GlobalValue::PrivateLinkage);
++NumDoubleWeak;
++NumFunctionsMerged;