[llvm] 26bd647 - Deprecate DataLayout::getPrefTypeAlignment
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 13 07:06:06 PST 2023
Author: Guillaume Chatelet
Date: 2023-01-13T15:05:24Z
New Revision: 26bd6476c61f08fc8c01895caa02b938d6a37221
URL: https://github.com/llvm/llvm-project/commit/26bd6476c61f08fc8c01895caa02b938d6a37221
DIFF: https://github.com/llvm/llvm-project/commit/26bd6476c61f08fc8c01895caa02b938d6a37221.diff
LOG: Deprecate DataLayout::getPrefTypeAlignment
Added:
Modified:
llvm/include/llvm/IR/DataLayout.h
llvm/lib/CodeGen/SjLjEHPrepare.cpp
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/lib/Target/Target.cpp
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h
index b869d2c047031..ff3f2b211fc2b 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -28,6 +28,7 @@
#include "llvm/IR/Type.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/TrailingObjects.h"
@@ -505,7 +506,7 @@ class DataLayout {
/// returns 12 or 16 for x86_fp80, depending on alignment.
TypeSize getTypeAllocSize(Type *Ty) const {
// Round up to the next alignment boundary.
- return alignTo(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
+ return alignTo(getTypeStoreSize(Ty), getABITypeAlign(Ty).value());
}
/// Returns the offset in bits between successive objects of the
@@ -522,6 +523,7 @@ class DataLayout {
/// Returns the minimum ABI-required alignment for the specified type.
/// FIXME: Deprecate this function once migration to Align is over.
+ LLVM_DEPRECATED("use getABITypeAlign instead", "getABITypeAlign")
uint64_t getABITypeAlignment(Type *Ty) const;
/// Returns the minimum ABI-required alignment for the specified type.
diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
index fc69739f20208..3fed707a9eb15 100644
--- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp
+++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp
@@ -183,7 +183,7 @@ Value *SjLjEHPrepare::setupFunctionContext(Function &F,
// that needs to be restored on all exits from the function. This is an alloca
// because the value needs to be added to the global context list.
auto &DL = F.getParent()->getDataLayout();
- const Align Alignment(DL.getPrefTypeAlignment(FunctionContextTy));
+ const Align Alignment = DL.getPrefTypeAlign(FunctionContextTy);
FuncCtx = new AllocaInst(FunctionContextTy, DL.getAllocaAddrSpace(), nullptr,
Alignment, "fn_context", &EntryBB->front());
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index dbf4bf4815eaf..83786281a05ce 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -1112,7 +1112,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
if (MaybeAlign A = GVar->getAlign())
O << " .align " << A->value();
else
- O << " .align " << (int)DL.getPrefTypeAlignment(ETy);
+ O << " .align " << (int)DL.getPrefTypeAlign(ETy).value();
if (ETy->isFloatingPointTy() || ETy->isPointerTy() ||
(ETy->isIntegerTy() && ETy->getScalarSizeInBits() <= 64)) {
@@ -1400,7 +1400,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
if (MaybeAlign A = GVar->getAlign())
O << " .align " << A->value();
else
- O << " .align " << (int)DL.getPrefTypeAlignment(ETy);
+ O << " .align " << (int)DL.getPrefTypeAlign(ETy).value();
// Special case for i128
if (ETy->isIntegerTy(128)) {
diff --git a/llvm/lib/Target/Target.cpp b/llvm/lib/Target/Target.cpp
index 7411687e2ca3d..1094b83d72ebf 100644
--- a/llvm/lib/Target/Target.cpp
+++ b/llvm/lib/Target/Target.cpp
@@ -119,7 +119,7 @@ unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
}
unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
- return unwrap(TD)->getPrefTypeAlignment(unwrap(Ty));
+ return unwrap(TD)->getPrefTypeAlign(unwrap(Ty)).value();
}
unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 3371f257074dc..1aa3b25168657 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -911,12 +911,12 @@ static DIType *solveDIType(DIBuilder &Builder, Type *Ty,
// };
RetType =
Builder.createPointerType(nullptr, Layout.getTypeSizeInBits(Ty),
- Layout.getABITypeAlignment(Ty) * CHAR_BIT,
+ Layout.getABITypeAlign(Ty).value() * CHAR_BIT,
/*DWARFAddressSpace=*/std::nullopt, Name);
} else if (Ty->isStructTy()) {
auto *DIStruct = Builder.createStructType(
Scope, Name, Scope->getFile(), LineNum, Layout.getTypeSizeInBits(Ty),
- Layout.getPrefTypeAlignment(Ty) * CHAR_BIT,
+ Layout.getPrefTypeAlign(Ty).value() * CHAR_BIT,
llvm::DINode::FlagArtificial, nullptr, llvm::DINodeArray());
auto *StructTy = cast<StructType>(Ty);
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index e80d388fa124b..ceb2f52ce873f 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1583,7 +1583,7 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
}
// Create the alloca. If we have DataLayout, use nice alignment.
- Align Alignment(DL.getPrefTypeAlignment(ByValType));
+ Align Alignment = DL.getPrefTypeAlign(ByValType);
// If the byval had an alignment specified, we *must* use at least that
// alignment, as it is required by the byval argument (and uses of the
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 870dc2b16a092..a23515817563e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6119,7 +6119,7 @@ SwitchLookupTable::SwitchLookupTable(
Array->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
// Set the alignment to that of an array items. We will be only loading one
// value out of it.
- Array->setAlignment(Align(DL.getPrefTypeAlignment(ValueType)));
+ Array->setAlignment(DL.getPrefTypeAlign(ValueType));
Kind = ArrayKind;
}
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 610d005db79a0..397588278c01c 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -1475,7 +1475,7 @@ static Value *optimizeMemCmpConstantSize(CallInst *CI, Value *LHS, Value *RHS,
// to legal integers or equality comparison. See block below this.
if (DL.isLegalInteger(Len * 8) && isOnlyUsedInZeroEqualityComparison(CI)) {
IntegerType *IntType = IntegerType::get(CI->getContext(), Len * 8);
- unsigned PrefAlignment = DL.getPrefTypeAlignment(IntType);
+ Align PrefAlignment = DL.getPrefTypeAlign(IntType);
// First, see if we can fold either argument to a constant.
Value *LHSV = nullptr;
More information about the llvm-commits
mailing list