diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:12:03 +0000 |
| commit | c9157d925c489f07ba9c0b2ce47e5149b75969a5 (patch) | |
| tree | 08bc4a3d9cad3f9ebffa558ddf140b9d9257b219 /contrib/llvm-project/llvm/lib/IR/DataLayout.cpp | |
| parent | 2a66844f606a35d68ad8a8061f4bea204274b3bc (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/IR/DataLayout.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/IR/DataLayout.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/contrib/llvm-project/llvm/lib/IR/DataLayout.cpp b/contrib/llvm-project/llvm/lib/IR/DataLayout.cpp index 53842b184ed6..e28f043cf9e0 100644 --- a/contrib/llvm-project/llvm/lib/IR/DataLayout.cpp +++ b/contrib/llvm-project/llvm/lib/IR/DataLayout.cpp @@ -46,7 +46,7 @@ using namespace llvm; //===----------------------------------------------------------------------===// StructLayout::StructLayout(StructType *ST, const DataLayout &DL) - : StructSize(TypeSize::Fixed(0)) { + : StructSize(TypeSize::getFixed(0)) { assert(!ST->isOpaque() && "Cannot get layout of opaque structs"); IsPadded = false; NumElements = ST->getNumElements(); @@ -55,7 +55,7 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) for (unsigned i = 0, e = NumElements; i != e; ++i) { Type *Ty = ST->getElementType(i); if (i == 0 && Ty->isScalableTy()) - StructSize = TypeSize::Scalable(0); + StructSize = TypeSize::getScalable(0); const Align TyAlign = ST->isPacked() ? Align(1) : DL.getABITypeAlign(Ty); @@ -68,7 +68,7 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) // contains both fixed size and scalable size data type members). if (!StructSize.isScalable() && !isAligned(TyAlign, StructSize)) { IsPadded = true; - StructSize = TypeSize::Fixed(alignTo(StructSize, TyAlign)); + StructSize = TypeSize::getFixed(alignTo(StructSize, TyAlign)); } // Keep track of maximum alignment constraint. @@ -83,7 +83,7 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) // and all array elements would be aligned correctly. if (!StructSize.isScalable() && !isAligned(StructAlignment, StructSize)) { IsPadded = true; - StructSize = TypeSize::Fixed(alignTo(StructSize, StructAlignment)); + StructSize = TypeSize::getFixed(alignTo(StructSize, StructAlignment)); } } @@ -93,7 +93,7 @@ unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const { assert(!StructSize.isScalable() && "Cannot get element at offset for structure containing scalable " "vector types"); - TypeSize Offset = TypeSize::Fixed(FixedOffset); + TypeSize Offset = TypeSize::getFixed(FixedOffset); ArrayRef<TypeSize> MemberOffsets = getMemberOffsets(); const auto *SI = @@ -171,7 +171,7 @@ const char *DataLayout::getManglingComponent(const Triple &T) { return "-m:l"; if (T.isOSBinFormatMachO()) return "-m:o"; - if (T.isOSWindows() && T.isOSBinFormatCOFF()) + if ((T.isOSWindows() || T.isUEFI()) && T.isOSBinFormatCOFF()) return T.getArch() == Triple::x86 ? "-m:x" : "-m:w"; if (T.isOSBinFormatXCOFF()) return "-m:a"; @@ -649,6 +649,8 @@ Error DataLayout::setPointerAlignmentInBits(uint32_t AddrSpace, Align ABIAlign, if (PrefAlign < ABIAlign) return reportError( "Preferred alignment cannot be less than the ABI alignment"); + if (IndexBitWidth > TypeBitWidth) + return reportError("Index width cannot be larger than pointer width"); auto I = lower_bound(Pointers, AddrSpace, [](const PointerAlignElem &A, uint32_t AddressSpace) { |
