#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"
/// 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
/// 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.
// 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());
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)) {
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)) {
}
unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
- return unwrap(TD)->getPrefTypeAlignment(unwrap(Ty));
+ return unwrap(TD)->getPrefTypeAlign(unwrap(Ty)).value();
}
unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
// };
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);
}
// 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
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;
}
// 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;