diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -219,8 +219,10 @@ LLVM_OneResultOp<"alloca">, Arguments<(ins LLVM_Type:$arraySize, OptionalAttr:$alignment)> { string llvmBuilder = [{ + llvm::Module *module = builder.GetInsertBlock()->getModule(); + auto allocaAddrSpace = module->getDataLayout().getAllocaAddrSpace(); auto *alloca = builder.CreateAlloca( - $_resultType->getPointerElementType(), $arraySize); + $_resultType->getPointerElementType(), allocaAddrSpace, $arraySize); if ($alignment.hasValue()) { auto align = $alignment.getValue().getZExtValue(); if (align != 0)