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 @@ -296,8 +296,9 @@ OptionalAttr:$alignment); let results = (outs Res]>:$res); string llvmBuilder = [{ + auto addrSpace = $_resultType->getPointerAddressSpace(); auto *inst = builder.CreateAlloca( - $_resultType->getPointerElementType(), $arraySize); + $_resultType->getPointerElementType(), addrSpace, $arraySize); }] # setAlignmentCode # [{ $res = inst; }]; diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir --- a/mlir/test/Target/LLVMIR/llvmir.mlir +++ b/mlir/test/Target/LLVMIR/llvmir.mlir @@ -1176,6 +1176,8 @@ llvm.alloca %size x i32 {alignment = 0} : (i64) -> (!llvm.ptr) // CHECK-NEXT: alloca {{.*}} align 8 llvm.alloca %size x i32 {alignment = 8} : (i64) -> (!llvm.ptr) + // CHECK-NEXT: alloca {{.*}} addrspace(3) + llvm.alloca %size x i32 {alignment = 0} : (i64) -> (!llvm.ptr) llvm.return }