@@ -982,8 +982,7 @@ struct EmboxCharOpConversion : public fir::FIROpConversion<fir::EmboxCharOp> {
982982template <typename ModuleOp>
983983static mlir::SymbolRefAttr
984984getMallocInModule (ModuleOp mod, fir::AllocMemOp op,
985- mlir::ConversionPatternRewriter &rewriter,
986- mlir::Type indexType) {
985+ mlir::ConversionPatternRewriter &rewriter) {
987986 static constexpr char mallocName[] = " malloc" ;
988987 if (auto mallocFunc =
989988 mod.template lookupSymbol <mlir::LLVM::LLVMFuncOp>(mallocName))
@@ -993,6 +992,7 @@ getMallocInModule(ModuleOp mod, fir::AllocMemOp op,
993992 return mlir::SymbolRefAttr::get (userMalloc);
994993
995994 mlir::OpBuilder moduleBuilder (mod.getBodyRegion ());
995+ auto indexType = mlir::IntegerType::get (op.getContext (), 64 );
996996 auto mallocDecl = moduleBuilder.create <mlir::LLVM::LLVMFuncOp>(
997997 op.getLoc (), mallocName,
998998 mlir::LLVM::LLVMFunctionType::get (getLlvmPtrType (op.getContext ()),
@@ -1002,13 +1002,12 @@ getMallocInModule(ModuleOp mod, fir::AllocMemOp op,
10021002}
10031003
10041004// / Return the LLVMFuncOp corresponding to the standard malloc call.
1005- static mlir::SymbolRefAttr getMalloc (fir::AllocMemOp op,
1006- mlir::ConversionPatternRewriter &rewriter,
1007- mlir::Type indexType) {
1005+ static mlir::SymbolRefAttr
1006+ getMalloc (fir::AllocMemOp op, mlir::ConversionPatternRewriter &rewriter) {
10081007 if (auto mod = op->getParentOfType <mlir::gpu::GPUModuleOp>())
1009- return getMallocInModule (mod, op, rewriter, indexType );
1008+ return getMallocInModule (mod, op, rewriter);
10101009 auto mod = op->getParentOfType <mlir::ModuleOp>();
1011- return getMallocInModule (mod, op, rewriter, indexType );
1010+ return getMallocInModule (mod, op, rewriter);
10121011}
10131012
10141013// / Helper function for generating the LLVM IR that computes the distance
@@ -1068,12 +1067,7 @@ struct AllocMemOpConversion : public fir::FIROpConversion<fir::AllocMemOp> {
10681067 for (mlir::Value opnd : adaptor.getOperands ())
10691068 size = rewriter.create <mlir::LLVM::MulOp>(
10701069 loc, ity, size, integerCast (loc, rewriter, ity, opnd));
1071- auto mallocTyWidth = lowerTy ().getIndexTypeBitwidth ();
1072- auto mallocTy =
1073- mlir::IntegerType::get (rewriter.getContext (), mallocTyWidth);
1074- if (mallocTyWidth != ity.getIntOrFloatBitWidth ())
1075- size = integerCast (loc, rewriter, mallocTy, size);
1076- heap->setAttr (" callee" , getMalloc (heap, rewriter, mallocTy));
1070+ heap->setAttr (" callee" , getMalloc (heap, rewriter));
10771071 rewriter.replaceOpWithNewOp <mlir::LLVM::CallOp>(
10781072 heap, ::getLlvmPtrType (heap.getContext ()), size,
10791073 addLLVMOpBundleAttrs (rewriter, heap->getAttrs (), 1 ));
0 commit comments