Deprecate DataLayout::getPrefTypeAlignment

This commit is contained in:
Guillaume Chatelet 2023-01-13 15:05:24 +00:00
parent bafa145c0e
commit 26bd6476c6
8 changed files with 12 additions and 10 deletions

View File

@ -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 @@ public:
/// 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 @@ public:
/// 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.

View File

@ -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());

View File

@ -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)) {

View File

@ -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,

View File

@ -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);

View File

@ -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

View File

@ -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;
}

View File

@ -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;