[Mlir-commits] [mlir] aaa0c81 - [MLIR][LLVM] Add memoryeffect for alloca

William S. Moses llvmlistbot at llvm.org
Tue Jan 11 22:53:30 PST 2022


Author: William S. Moses
Date: 2022-01-12T01:53:24-05:00
New Revision: aaa0c81683d85fa413e8af8eb2cfde7869ad3a1c

URL: https://github.com/llvm/llvm-project/commit/aaa0c81683d85fa413e8af8eb2cfde7869ad3a1c
DIFF: https://github.com/llvm/llvm-project/commit/aaa0c81683d85fa413e8af8eb2cfde7869ad3a1c.diff

LOG: [MLIR][LLVM] Add memoryeffect for alloca

Add memory effect for llvm.alloca op

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D117086

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
    mlir/test/Dialect/LLVMIR/canonicalize.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index c6b52c722c2d6..e1eaaa05f05b3 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -295,7 +295,7 @@ class MemoryOpWithAlignmentAndAttributes : MemoryOpWithAlignmentBase {
 def LLVM_AllocaOp : LLVM_Op<"alloca">, MemoryOpWithAlignmentBase {
   let arguments = (ins AnyInteger:$arraySize,
                    OptionalAttr<I64Attr>:$alignment);
-  let results = (outs LLVM_AnyPointer:$res);
+  let results = (outs Res<LLVM_AnyPointer, "", [MemAlloc<AutomaticAllocationScopeResource>]>:$res);
   string llvmBuilder = [{
     auto *inst = builder.CreateAlloca(
       $_resultType->getPointerElementType(), $arraySize);

diff  --git a/mlir/test/Dialect/LLVMIR/canonicalize.mlir b/mlir/test/Dialect/LLVMIR/canonicalize.mlir
index acc08c6453bcd..5fbe0b648d48d 100644
--- a/mlir/test/Dialect/LLVMIR/canonicalize.mlir
+++ b/mlir/test/Dialect/LLVMIR/canonicalize.mlir
@@ -122,3 +122,11 @@ llvm.func @addr_dce(%x : !llvm.ptr<i8>) {
   %0 = llvm.mlir.addressof @fp : !llvm.ptr<ptr<i8>>
   llvm.return 
 }
+
+// CHECK-LABEL: alloca_dce
+// CHECK-NEXT: llvm.return
+llvm.func @alloca_dce() {
+  %c1_i64 = arith.constant 1 : i64
+  %0 = llvm.alloca %c1_i64 x i32 : (i64) -> !llvm.ptr<i32>
+  llvm.return 
+}


        


More information about the Mlir-commits mailing list