aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/MergeFunctions.cpp
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2022-12-12 13:06:56 +0000
committerGuillaume Chatelet <gchatelet@google.com>2022-12-12 14:50:39 +0000
commitf3f15ca27fbb433ad5a65b1a1e0a071d2e9af505 (patch)
tree7d3dbf5f2971de47edd4d4ff3807de8524566cf7 /llvm/lib/Transforms/IPO/MergeFunctions.cpp
parentdabda23f1991f7c4e5a840ee6cf1290e18fa2e88 (diff)
downloadllvm-f3f15ca27fbb433ad5a65b1a1e0a071d2e9af505.zip
llvm-f3f15ca27fbb433ad5a65b1a1e0a071d2e9af505.tar.gz
llvm-f3f15ca27fbb433ad5a65b1a1e0a071d2e9af505.tar.bz2
[Alignment][NFC] Remove deprecated GlobalObject::getAlignment
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;