From 818f42daf4719587f8087715732d09b40f643925 Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Wed, 14 Aug 2024 00:03:31 +0200 Subject: [PATCH] Fix for the removed DataLayout constructor. (#8391) * Fix for the removed DataLayout constructor. * Update CodeGen_LLVM.cpp * Update CodeGen_LLVM.cpp * Update CodeGen_LLVM.cpp --------- Co-authored-by: Steven Johnson --- src/CodeGen_LLVM.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CodeGen_LLVM.cpp b/src/CodeGen_LLVM.cpp index 373cc0764813..b5489eb2b514 100644 --- a/src/CodeGen_LLVM.cpp +++ b/src/CodeGen_LLVM.cpp @@ -1910,7 +1910,7 @@ Value *CodeGen_LLVM::codegen_buffer_pointer(const string &buffer, Halide::Type t Value *CodeGen_LLVM::codegen_buffer_pointer(Value *base_address, Halide::Type type, Expr index) { // Promote index to 64-bit on targets that use 64-bit pointers. - llvm::DataLayout d(module.get()); + const llvm::DataLayout &d = module->getDataLayout(); if (promote_indices() && d.getPointerSize() == 8) { index = promote_64(index); } @@ -1951,7 +1951,7 @@ Value *CodeGen_LLVM::codegen_buffer_pointer(Value *base_address, Halide::Type ty } // Promote index to 64-bit on targets that use 64-bit pointers. - llvm::DataLayout d(module.get()); + const llvm::DataLayout &d = module->getDataLayout(); if (d.getPointerSize() == 8) { llvm::Type *index_type = index->getType(); llvm::Type *desired_index_type = i64_t; @@ -3286,7 +3286,7 @@ void CodeGen_LLVM::visit(const Call *op) { } else if (op->is_intrinsic(Call::undef)) { user_error << "undef not eliminated before code generation. Please report this as a Halide bug.\n"; } else if (op->is_intrinsic(Call::size_of_halide_buffer_t)) { - llvm::DataLayout d(module.get()); + const llvm::DataLayout &d = module->getDataLayout(); value = ConstantInt::get(i32_t, (int)d.getTypeAllocSize(halide_buffer_t_type)); } else if (op->is_intrinsic(Call::strict_float)) { IRBuilder::FastMathFlagGuard guard(*builder); @@ -4466,7 +4466,7 @@ Value *CodeGen_LLVM::create_alloca_at_entry(llvm::Type *t, int n, bool zero_init Value *size = ConstantInt::get(i32_t, n); AllocaInst *ptr = builder->CreateAlloca(t, size, name); int align = native_vector_bits() / 8; - llvm::DataLayout d(module.get()); + const llvm::DataLayout &d = module->getDataLayout(); int allocated_size = n * (int)d.getTypeAllocSize(t); if (t->isVectorTy() || n > 1) { ptr->setAlignment(llvm::Align(align));