forked from OSchip/llvm-project
[MLIR][LLVM] Add MemRead/MemWrite behavior to llvm store/load/addressof ops
This patch adds corresponding memory effects to mlir llvm-dialect load/store/addressof ops, which thus enables canonicalizations of those ops (like dead code elimination) that rely on the effect interface Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D117041
This commit is contained in:
parent
694fd10659
commit
65c15cbd4a
|
@ -356,7 +356,7 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [NoSideEffect]> {
|
|||
}
|
||||
|
||||
def LLVM_LoadOp : LLVM_Op<"load">, MemoryOpWithAlignmentAndAttributes {
|
||||
let arguments = (ins LLVM_PointerTo<LLVM_LoadableType>:$addr,
|
||||
let arguments = (ins Arg<LLVM_PointerTo<LLVM_LoadableType>, "", [MemRead]>:$addr,
|
||||
OptionalAttr<SymbolRefArrayAttr>:$access_groups,
|
||||
OptionalAttr<SymbolRefArrayAttr>:$alias_scopes,
|
||||
OptionalAttr<SymbolRefArrayAttr>:$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<LLVM_LoadableType>:$addr,
|
||||
Arg<LLVM_PointerTo<LLVM_LoadableType>,"",[MemWrite]>:$addr,
|
||||
OptionalAttr<SymbolRefArrayAttr>:$access_groups,
|
||||
OptionalAttr<SymbolRefArrayAttr>:$alias_scopes,
|
||||
OptionalAttr<SymbolRefArrayAttr>:$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);
|
||||
|
||||
|
|
|
@ -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<i8>) {
|
||||
%0 = llvm.load %x : !llvm.ptr<i8>
|
||||
llvm.return
|
||||
}
|
||||
|
||||
llvm.mlir.global external @fp() : !llvm.ptr<i8>
|
||||
|
||||
// CHECK-LABEL: addr_dce
|
||||
// CHECK-NEXT: llvm.return
|
||||
llvm.func @addr_dce(%x : !llvm.ptr<i8>) {
|
||||
%0 = llvm.mlir.addressof @fp : !llvm.ptr<ptr<i8>>
|
||||
llvm.return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue