diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 328ff9da3639..c6b52c722c2d 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -356,7 +356,7 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [NoSideEffect]> { } def LLVM_LoadOp : LLVM_Op<"load">, MemoryOpWithAlignmentAndAttributes { - let arguments = (ins LLVM_PointerTo:$addr, + let arguments = (ins Arg, "", [MemRead]>:$addr, OptionalAttr:$access_groups, OptionalAttr:$alias_scopes, OptionalAttr:$noalias_scopes, @@ -390,7 +390,7 @@ def LLVM_LoadOp : LLVM_Op<"load">, MemoryOpWithAlignmentAndAttributes { def LLVM_StoreOp : LLVM_Op<"store">, MemoryOpWithAlignmentAndAttributes { let arguments = (ins LLVM_LoadableType:$value, - LLVM_PointerTo:$addr, + Arg,"",[MemWrite]>:$addr, OptionalAttr:$access_groups, OptionalAttr:$alias_scopes, OptionalAttr:$noalias_scopes, @@ -861,7 +861,7 @@ def UnnamedAddr : LLVM_EnumAttr< let cppNamespace = "::mlir::LLVM"; } -def LLVM_AddressOfOp : LLVM_Op<"mlir.addressof"> { +def LLVM_AddressOfOp : LLVM_Op<"mlir.addressof", [NoSideEffect]> { let arguments = (ins FlatSymbolRefAttr:$global_name); let results = (outs LLVM_Type:$res); diff --git a/mlir/test/Dialect/LLVMIR/canonicalize.mlir b/mlir/test/Dialect/LLVMIR/canonicalize.mlir index 7185920efe54..acc08c6453bc 100644 --- a/mlir/test/Dialect/LLVMIR/canonicalize.mlir +++ b/mlir/test/Dialect/LLVMIR/canonicalize.mlir @@ -104,3 +104,21 @@ func @llvm_constant() -> i32 { // CHECK: return %[[RES]] return %2 : i32 } + +// ----- + +// CHECK-LABEL: load_dce +// CHECK-NEXT: llvm.return +llvm.func @load_dce(%x : !llvm.ptr) { + %0 = llvm.load %x : !llvm.ptr + llvm.return +} + +llvm.mlir.global external @fp() : !llvm.ptr + +// CHECK-LABEL: addr_dce +// CHECK-NEXT: llvm.return +llvm.func @addr_dce(%x : !llvm.ptr) { + %0 = llvm.mlir.addressof @fp : !llvm.ptr> + llvm.return +}