Author: Nikita Popov Date: 2024-06-29T11:50:28+02:00 New Revision: 5cc1287bdbb2de9ad91e4ba8dc9eeb9508c734a5
URL: https://github.com/llvm/llvm-project/commit/5cc1287bdbb2de9ad91e4ba8dc9eeb9508c734a5 DIFF: https://github.com/llvm/llvm-project/commit/5cc1287bdbb2de9ad91e4ba8dc9eeb9508c734a5.diff LOG: [CGBuilder] Use getDataLayout() helpers (NFC) Added: Modified: clang/lib/CodeGen/CGBuilder.h Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h index ed07476f4047f..0bc4fda62979c 100644 --- a/clang/lib/CodeGen/CGBuilder.h +++ b/clang/lib/CodeGen/CGBuilder.h @@ -62,7 +62,7 @@ class CGBuilderTy : public CGBuilderBaseTy { template <bool IsInBounds> Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine &Name) { - const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout(); + const llvm::DataLayout &DL = BB->getDataLayout(); llvm::GetElementPtrInst *GEP; if (IsInBounds) GEP = cast<llvm::GetElementPtrInst>(CreateConstInBoundsGEP2_32( @@ -218,7 +218,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name = "") { llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType()); - const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout(); + const llvm::DataLayout &DL = BB->getDataLayout(); const llvm::StructLayout *Layout = DL.getStructLayout(ElTy); auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index)); @@ -240,7 +240,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateConstArrayGEP(Address Addr, uint64_t Index, const llvm::Twine &Name = "") { llvm::ArrayType *ElTy = cast<llvm::ArrayType>(Addr.getElementType()); - const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout(); + const llvm::DataLayout &DL = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy->getElementType())); @@ -260,7 +260,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateConstInBoundsGEP(Address Addr, uint64_t Index, const llvm::Twine &Name = "") { llvm::Type *ElTy = Addr.getElementType(); - const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout(); + const llvm::DataLayout &DL = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy)); return Address( @@ -277,7 +277,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateConstGEP(Address Addr, uint64_t Index, const llvm::Twine &Name = "") { llvm::Type *ElTy = Addr.getElementType(); - const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout(); + const llvm::DataLayout &DL = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy)); return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name), @@ -290,7 +290,7 @@ class CGBuilderTy : public CGBuilderBaseTy { using CGBuilderBaseTy::CreateGEP; Address CreateGEP(CodeGenFunction &CGF, Address Addr, llvm::Value *Index, const llvm::Twine &Name = "") { - const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout(); + const llvm::DataLayout &DL = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType())); @@ -412,7 +412,7 @@ class CGBuilderTy : public CGBuilderBaseTy { unsigned FieldIndex, llvm::MDNode *DbgInfo) { llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType()); - const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout(); + const llvm::DataLayout &DL = BB->getDataLayout(); const llvm::StructLayout *Layout = DL.getStructLayout(ElTy); auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index)); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits