diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 6abcadf0a4b45..b14bd830bb973 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -653,7 +653,7 @@ def LLVM_CallOp : LLVM_MemAccessOpBase<"call", OptionalAttr:$branch_weights, DefaultValuedAttr:$CConv, DefaultValuedAttr:$TailCallKind, - OptionalAttr:$memory, + OptionalAttr:$memory_effects, OptionalAttr:$convergent, OptionalAttr:$no_unwind, OptionalAttr:$will_return @@ -1439,7 +1439,7 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [ OptionalAttr:$arg_attrs, OptionalAttr:$res_attrs, OptionalAttr:$function_entry_count, - OptionalAttr:$memory, + OptionalAttr:$memory_effects, DefaultValuedAttr:$visibility_, OptionalAttr:$arm_streaming, OptionalAttr:$arm_locally_streaming, diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp index 059acb217709c..c1f6d8bc5b361 100644 --- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp +++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp @@ -325,7 +325,7 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp, rewriter.getContext(), {LLVM::ModRefInfo::NoModRef, LLVM::ModRefInfo::NoModRef, LLVM::ModRefInfo::NoModRef}); - newFuncOp.setMemoryAttr(memoryAttr); + newFuncOp.setMemoryEffectsAttr(memoryAttr); } // Propagate argument/result attributes to all converted arguments/result diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index f0ac45be4b9e8..73f92e5165a8c 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -982,7 +982,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results, /*var_callee_type=*/nullptr, callee, args, /*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr, /*CConv=*/nullptr, /*TailCallKind=*/nullptr, - /*memory=*/nullptr, + /*memory_effects=*/nullptr, /*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr, /*access_groups=*/nullptr, /*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr); @@ -1007,7 +1007,8 @@ void CallOp::build(OpBuilder &builder, OperationState &state, getCallOpVarCalleeType(calleeType), callee, args, /*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr, /*CConv=*/nullptr, - /*TailCallKind=*/nullptr, /*memory=*/nullptr, /*convergent=*/nullptr, + /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr, + /*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr, /*access_groups=*/nullptr, /*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr); @@ -1019,7 +1020,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, getCallOpVarCalleeType(calleeType), /*callee=*/nullptr, args, /*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr, - /*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory=*/nullptr, + /*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr, /*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr, /*access_groups=*/nullptr, /*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr); @@ -1031,7 +1032,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func, build(builder, state, getCallOpResultTypes(calleeType), getCallOpVarCalleeType(calleeType), SymbolRefAttr::get(func), args, /*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr, - /*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory=*/nullptr, + /*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr, /*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr, /*access_groups=*/nullptr, /*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp index ddf36ce6c715c..137c1962b100a 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp @@ -658,7 +658,7 @@ static Value handleByValArgument(OpBuilder &builder, Operation *callable, Value argument, Type elementType, uint64_t requestedAlignment) { auto func = cast(callable); - LLVM::MemoryEffectsAttr memoryEffects = func.getMemoryAttr(); + LLVM::MemoryEffectsAttr memoryEffects = func.getMemoryEffectsAttr(); // If there is no memory effects attribute, assume that the function is // not read-only. bool isReadOnly = memoryEffects && diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp index 8837c19b48588..bdb15a290209b 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp @@ -226,7 +226,7 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder, if (callOp.getWillReturnAttr()) call->addFnAttr(llvm::Attribute::WillReturn); - if (MemoryEffectsAttr memAttr = callOp.getMemoryAttr()) { + if (MemoryEffectsAttr memAttr = callOp.getMemoryEffectsAttr()) { llvm::MemoryEffects memEffects = llvm::MemoryEffects(llvm::MemoryEffects::Location::ArgMem, convertModRefInfoToLLVM(memAttr.getArgMem())) | diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp index 42e9b66a6a2ac..8b40b7b2df6c7 100644 --- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp @@ -1491,7 +1491,7 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) { inaccessibleMem); // Only set the attribute when it does not match the default value. if (!memAttr.isReadWrite()) - callOp.setMemoryAttr(memAttr); + callOp.setMemoryEffectsAttr(memAttr); if (!callInst->getType()->isVoidTy()) mapValue(inst, callOp.getResult()); @@ -1683,7 +1683,7 @@ static void processMemoryEffects(llvm::Function *func, LLVMFuncOp funcOp) { // Only set the attr when it does not match the default value. if (memAttr.isReadWrite()) return; - funcOp.setMemoryAttr(memAttr); + funcOp.setMemoryEffectsAttr(memAttr); } // List of LLVM IR attributes that map to an explicit attribute on the MLIR diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index fc3fb0b5334c1..3016d1846e00f 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1412,10 +1412,10 @@ LogicalResult ModuleTranslation::convertDialectAttributes( /// `llvmFunc`. static void convertFunctionMemoryAttributes(LLVMFuncOp func, llvm::Function *llvmFunc) { - if (!func.getMemory()) + if (!func.getMemoryEffects()) return; - MemoryEffectsAttr memEffects = func.getMemoryAttr(); + MemoryEffectsAttr memEffects = func.getMemoryEffectsAttr(); // Add memory effects incrementally. llvm::MemoryEffects newMemEffects = diff --git a/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir b/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir index dbbda8e1513a8..755c4cf42689c 100644 --- a/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir +++ b/mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir @@ -32,7 +32,7 @@ func.func @pass_through(%arg0: () -> ()) -> (() -> ()) { func.func private @llvmlinkage(i32) attributes { "llvm.linkage" = #llvm.linkage } // CHECK-LABEL: llvm.func @llvmreadnone(i32) -// CHECK-SAME: memory = #llvm.memory_effects +// CHECK-SAME: memory_effects = #llvm.memory_effects func.func private @llvmreadnone(i32) attributes { llvm.readnone } // CHECK-LABEL: llvm.func @body(i32) diff --git a/mlir/test/Dialect/LLVMIR/inlining.mlir b/mlir/test/Dialect/LLVMIR/inlining.mlir index 04de7659bcf17..f9551e311df59 100644 --- a/mlir/test/Dialect/LLVMIR/inlining.mlir +++ b/mlir/test/Dialect/LLVMIR/inlining.mlir @@ -422,7 +422,7 @@ llvm.func @test_byval(%ptr : !llvm.ptr) { // ----- -llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory = #llvm.memory_effects} { +llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory_effects = #llvm.memory_effects} { llvm.return } @@ -436,7 +436,7 @@ llvm.func @test_byval_read_only(%ptr : !llvm.ptr) { // ----- -llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory = #llvm.memory_effects} { +llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory_effects = #llvm.memory_effects} { llvm.return } @@ -451,7 +451,7 @@ llvm.func @test_byval_write_only(%ptr : !llvm.ptr) { // ----- -llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects} { +llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects} { llvm.return } @@ -472,7 +472,7 @@ llvm.func @test_byval_input_aligned(%unaligned : !llvm.ptr, %aligned : !llvm.ptr llvm.func @func_that_uses_ptr(%ptr : !llvm.ptr) -llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects} { +llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects} { llvm.call @func_that_uses_ptr(%ptr) : (!llvm.ptr) -> () llvm.return } @@ -496,7 +496,7 @@ module attributes { llvm.func @func_that_uses_ptr(%ptr : !llvm.ptr) -llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects} { +llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects} { llvm.call @func_that_uses_ptr(%ptr) : (!llvm.ptr) -> () llvm.return } @@ -524,7 +524,7 @@ module attributes { llvm.func @func_that_uses_ptr(%ptr : !llvm.ptr) -llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects} { +llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects} { llvm.call @func_that_uses_ptr(%ptr) : (!llvm.ptr) -> () llvm.return } @@ -550,7 +550,7 @@ llvm.func @test_alignment_exceeded_anyway() { llvm.mlir.global private @unaligned_global(42 : i64) : i64 llvm.mlir.global private @aligned_global(42 : i64) { alignment = 64 } : i64 -llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects} { +llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects} { llvm.return } diff --git a/mlir/test/Target/LLVMIR/Import/function-attributes.ll b/mlir/test/Target/LLVMIR/Import/function-attributes.ll index 6c38979a0a719..912f448657baa 100644 --- a/mlir/test/Target/LLVMIR/Import/function-attributes.ll +++ b/mlir/test/Target/LLVMIR/Import/function-attributes.ll @@ -13,14 +13,14 @@ define internal spir_func void @spir_func_internal() { ; // ----- ; CHECK-LABEL: @func_readnone -; CHECK-SAME: attributes {memory = #llvm.memory_effects} +; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects} ; CHECK: llvm.return define void @func_readnone() readnone { ret void } ; CHECK-LABEL: @func_readnone_indirect -; CHECK-SAME: attributes {memory = #llvm.memory_effects} +; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects} declare void @func_readnone_indirect() #0 attributes #0 = { readnone } @@ -152,7 +152,7 @@ define void @entry_count() !prof !1 { ; // ----- ; CHECK-LABEL: @func_memory -; CHECK-SAME: attributes {memory = #llvm.memory_effects} +; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects} ; CHECK: llvm.return define void @func_memory() memory(readwrite, argmem: none) { ret void diff --git a/mlir/test/Target/LLVMIR/Import/instructions.ll b/mlir/test/Target/LLVMIR/Import/instructions.ll index b4dad2deb3496..3b1dcee1e85c7 100644 --- a/mlir/test/Target/LLVMIR/Import/instructions.ll +++ b/mlir/test/Target/LLVMIR/Import/instructions.ll @@ -569,13 +569,13 @@ declare void @f() ; CHECK-LABEL: @call_memory_effects define void @call_memory_effects() { -; CHECK: llvm.call @f() {memory = #llvm.memory_effects} +; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects} call void @f() memory(none) -; CHECK: llvm.call @f() {memory = #llvm.memory_effects} +; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects} call void @f() memory(none, argmem: write, inaccessiblemem: read) -; CHECK: llvm.call @f() {memory = #llvm.memory_effects} +; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects} call void @f() memory(write, argmem: none) -; CHECK: llvm.call @f() {memory = #llvm.memory_effects} +; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects} call void @f() memory(readwrite, inaccessiblemem: read) ; CHECK: llvm.call @f() ; CHECK-NOT: #llvm.memory_effects diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir index ab5b65bde6305..db54d131299c6 100644 --- a/mlir/test/Target/LLVMIR/llvmir.mlir +++ b/mlir/test/Target/LLVMIR/llvmir.mlir @@ -2276,7 +2276,7 @@ llvm.func @readonly_function(%arg0: !llvm.ptr {llvm.readonly}) // CHECK: declare void @arg_mem_none_func() #[[ATTR:[0-9]+]] llvm.func @arg_mem_none_func() attributes { - memory = #llvm.memory_effects} + memory_effects = #llvm.memory_effects} // CHECK: attributes #[[ATTR]] = { memory(readwrite, argmem: none) } @@ -2284,7 +2284,7 @@ llvm.func @arg_mem_none_func() attributes { // CHECK: declare void @readwrite_func() #[[ATTR:[0-9]+]] llvm.func @readwrite_func() attributes { - memory = #llvm.memory_effects} + memory_effects = #llvm.memory_effects} // CHECK: attributes #[[ATTR]] = { memory(readwrite) } @@ -2527,16 +2527,16 @@ llvm.func @fb() llvm.func @fc() llvm.func @fd() -// CHECK-LABEL: @mem_none_call +// CHECK-LABEL: @mem_effects_call // CHECK: call void @fa() #[[ATTRS_0:[0-9]+]] // CHECK: call void @fb() #[[ATTRS_1:[0-9]+]] // CHECK: call void @fc() #[[ATTRS_2:[0-9]+]] // CHECK: call void @fd() #[[ATTRS_3:[0-9]+]] -llvm.func @mem_none_call() { - llvm.call @fa() {memory = #llvm.memory_effects} : () -> () - llvm.call @fb() {memory = #llvm.memory_effects} : () -> () - llvm.call @fc() {memory = #llvm.memory_effects} : () -> () - llvm.call @fd() {memory = #llvm.memory_effects} : () -> () +llvm.func @mem_effects_call() { + llvm.call @fa() {memory_effects = #llvm.memory_effects} : () -> () + llvm.call @fb() {memory_effects = #llvm.memory_effects} : () -> () + llvm.call @fc() {memory_effects = #llvm.memory_effects} : () -> () + llvm.call @fd() {memory_effects = #llvm.memory_effects} : () -> () llvm.return }