Skip to content

Commit 2eea9d6

Browse files
authored
[mlir] Rename memory attribute to memory_effects in llvmir dialect (#100108)
This commit renames the memory attribute on operations to "memory_effects" to be in line with the naming LLVM IR is using.
1 parent 16f22c0 commit 2eea9d6

File tree

12 files changed

+37
-36
lines changed

12 files changed

+37
-36
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ def LLVM_CallOp : LLVM_MemAccessOpBase<"call",
653653
OptionalAttr<DenseI32ArrayAttr>:$branch_weights,
654654
DefaultValuedAttr<CConv, "CConv::C">:$CConv,
655655
DefaultValuedAttr<TailCallKind, "TailCallKind::None">:$TailCallKind,
656-
OptionalAttr<LLVM_MemoryEffectsAttr>:$memory,
656+
OptionalAttr<LLVM_MemoryEffectsAttr>:$memory_effects,
657657
OptionalAttr<UnitAttr>:$convergent,
658658
OptionalAttr<UnitAttr>:$no_unwind,
659659
OptionalAttr<UnitAttr>:$will_return
@@ -1439,7 +1439,7 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
14391439
OptionalAttr<DictArrayAttr>:$arg_attrs,
14401440
OptionalAttr<DictArrayAttr>:$res_attrs,
14411441
OptionalAttr<I64Attr>:$function_entry_count,
1442-
OptionalAttr<LLVM_MemoryEffectsAttr>:$memory,
1442+
OptionalAttr<LLVM_MemoryEffectsAttr>:$memory_effects,
14431443
DefaultValuedAttr<Visibility, "mlir::LLVM::Visibility::Default">:$visibility_,
14441444
OptionalAttr<UnitAttr>:$arm_streaming,
14451445
OptionalAttr<UnitAttr>:$arm_locally_streaming,

mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
325325
rewriter.getContext(),
326326
{LLVM::ModRefInfo::NoModRef, LLVM::ModRefInfo::NoModRef,
327327
LLVM::ModRefInfo::NoModRef});
328-
newFuncOp.setMemoryAttr(memoryAttr);
328+
newFuncOp.setMemoryEffectsAttr(memoryAttr);
329329
}
330330

331331
// Propagate argument/result attributes to all converted arguments/result

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
982982
/*var_callee_type=*/nullptr, callee, args, /*fastmathFlags=*/nullptr,
983983
/*branch_weights=*/nullptr,
984984
/*CConv=*/nullptr, /*TailCallKind=*/nullptr,
985-
/*memory=*/nullptr,
985+
/*memory_effects=*/nullptr,
986986
/*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
987987
/*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
988988
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
@@ -1007,7 +1007,8 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
10071007
getCallOpVarCalleeType(calleeType), callee, args,
10081008
/*fastmathFlags=*/nullptr,
10091009
/*branch_weights=*/nullptr, /*CConv=*/nullptr,
1010-
/*TailCallKind=*/nullptr, /*memory=*/nullptr, /*convergent=*/nullptr,
1010+
/*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
1011+
/*convergent=*/nullptr,
10111012
/*no_unwind=*/nullptr, /*will_return=*/nullptr,
10121013
/*access_groups=*/nullptr,
10131014
/*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
@@ -1019,7 +1020,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
10191020
getCallOpVarCalleeType(calleeType),
10201021
/*callee=*/nullptr, args,
10211022
/*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr,
1022-
/*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory=*/nullptr,
1023+
/*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
10231024
/*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
10241025
/*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
10251026
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
@@ -1031,7 +1032,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func,
10311032
build(builder, state, getCallOpResultTypes(calleeType),
10321033
getCallOpVarCalleeType(calleeType), SymbolRefAttr::get(func), args,
10331034
/*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr,
1034-
/*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory=*/nullptr,
1035+
/*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
10351036
/*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
10361037
/*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
10371038
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);

mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ static Value handleByValArgument(OpBuilder &builder, Operation *callable,
658658
Value argument, Type elementType,
659659
uint64_t requestedAlignment) {
660660
auto func = cast<LLVM::LLVMFuncOp>(callable);
661-
LLVM::MemoryEffectsAttr memoryEffects = func.getMemoryAttr();
661+
LLVM::MemoryEffectsAttr memoryEffects = func.getMemoryEffectsAttr();
662662
// If there is no memory effects attribute, assume that the function is
663663
// not read-only.
664664
bool isReadOnly = memoryEffects &&

mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
226226
if (callOp.getWillReturnAttr())
227227
call->addFnAttr(llvm::Attribute::WillReturn);
228228

229-
if (MemoryEffectsAttr memAttr = callOp.getMemoryAttr()) {
229+
if (MemoryEffectsAttr memAttr = callOp.getMemoryEffectsAttr()) {
230230
llvm::MemoryEffects memEffects =
231231
llvm::MemoryEffects(llvm::MemoryEffects::Location::ArgMem,
232232
convertModRefInfoToLLVM(memAttr.getArgMem())) |

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
14911491
inaccessibleMem);
14921492
// Only set the attribute when it does not match the default value.
14931493
if (!memAttr.isReadWrite())
1494-
callOp.setMemoryAttr(memAttr);
1494+
callOp.setMemoryEffectsAttr(memAttr);
14951495

14961496
if (!callInst->getType()->isVoidTy())
14971497
mapValue(inst, callOp.getResult());
@@ -1683,7 +1683,7 @@ static void processMemoryEffects(llvm::Function *func, LLVMFuncOp funcOp) {
16831683
// Only set the attr when it does not match the default value.
16841684
if (memAttr.isReadWrite())
16851685
return;
1686-
funcOp.setMemoryAttr(memAttr);
1686+
funcOp.setMemoryEffectsAttr(memAttr);
16871687
}
16881688

16891689
// List of LLVM IR attributes that map to an explicit attribute on the MLIR

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,10 +1412,10 @@ LogicalResult ModuleTranslation::convertDialectAttributes(
14121412
/// `llvmFunc`.
14131413
static void convertFunctionMemoryAttributes(LLVMFuncOp func,
14141414
llvm::Function *llvmFunc) {
1415-
if (!func.getMemory())
1415+
if (!func.getMemoryEffects())
14161416
return;
14171417

1418-
MemoryEffectsAttr memEffects = func.getMemoryAttr();
1418+
MemoryEffectsAttr memEffects = func.getMemoryEffectsAttr();
14191419

14201420
// Add memory effects incrementally.
14211421
llvm::MemoryEffects newMemEffects =

mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func.func @pass_through(%arg0: () -> ()) -> (() -> ()) {
3232
func.func private @llvmlinkage(i32) attributes { "llvm.linkage" = #llvm.linkage<extern_weak> }
3333

3434
// CHECK-LABEL: llvm.func @llvmreadnone(i32)
35-
// CHECK-SAME: memory = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>
35+
// CHECK-SAME: memory_effects = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>
3636
func.func private @llvmreadnone(i32) attributes { llvm.readnone }
3737

3838
// CHECK-LABEL: llvm.func @body(i32)

mlir/test/Dialect/LLVMIR/inlining.mlir

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ llvm.func @test_byval(%ptr : !llvm.ptr) {
422422

423423
// -----
424424

425-
llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory = #llvm.memory_effects<other = readwrite, argMem = read, inaccessibleMem = readwrite>} {
425+
llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory_effects = #llvm.memory_effects<other = readwrite, argMem = read, inaccessibleMem = readwrite>} {
426426
llvm.return
427427
}
428428

@@ -436,7 +436,7 @@ llvm.func @test_byval_read_only(%ptr : !llvm.ptr) {
436436

437437
// -----
438438

439-
llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory = #llvm.memory_effects<other = readwrite, argMem = write, inaccessibleMem = readwrite>} {
439+
llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) attributes {memory_effects = #llvm.memory_effects<other = readwrite, argMem = write, inaccessibleMem = readwrite>} {
440440
llvm.return
441441
}
442442

@@ -451,7 +451,7 @@ llvm.func @test_byval_write_only(%ptr : !llvm.ptr) {
451451

452452
// -----
453453

454-
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
454+
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
455455
llvm.return
456456
}
457457

@@ -472,7 +472,7 @@ llvm.func @test_byval_input_aligned(%unaligned : !llvm.ptr, %aligned : !llvm.ptr
472472

473473
llvm.func @func_that_uses_ptr(%ptr : !llvm.ptr)
474474

475-
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
475+
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
476476
llvm.call @func_that_uses_ptr(%ptr) : (!llvm.ptr) -> ()
477477
llvm.return
478478
}
@@ -496,7 +496,7 @@ module attributes {
496496

497497
llvm.func @func_that_uses_ptr(%ptr : !llvm.ptr)
498498

499-
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
499+
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
500500
llvm.call @func_that_uses_ptr(%ptr) : (!llvm.ptr) -> ()
501501
llvm.return
502502
}
@@ -524,7 +524,7 @@ module attributes {
524524

525525
llvm.func @func_that_uses_ptr(%ptr : !llvm.ptr)
526526

527-
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
527+
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
528528
llvm.call @func_that_uses_ptr(%ptr) : (!llvm.ptr) -> ()
529529
llvm.return
530530
}
@@ -550,7 +550,7 @@ llvm.func @test_alignment_exceeded_anyway() {
550550
llvm.mlir.global private @unaligned_global(42 : i64) : i64
551551
llvm.mlir.global private @aligned_global(42 : i64) { alignment = 64 } : i64
552552

553-
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
553+
llvm.func @aligned_byval_arg(%ptr : !llvm.ptr { llvm.byval = i16, llvm.align = 16 }) attributes {memory_effects = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = read>} {
554554
llvm.return
555555
}
556556

mlir/test/Target/LLVMIR/Import/function-attributes.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ define internal spir_func void @spir_func_internal() {
1313
; // -----
1414

1515
; CHECK-LABEL: @func_readnone
16-
; CHECK-SAME: attributes {memory = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
16+
; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
1717
; CHECK: llvm.return
1818
define void @func_readnone() readnone {
1919
ret void
2020
}
2121

2222
; CHECK-LABEL: @func_readnone_indirect
23-
; CHECK-SAME: attributes {memory = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
23+
; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
2424
declare void @func_readnone_indirect() #0
2525
attributes #0 = { readnone }
2626

@@ -152,7 +152,7 @@ define void @entry_count() !prof !1 {
152152
; // -----
153153

154154
; CHECK-LABEL: @func_memory
155-
; CHECK-SAME: attributes {memory = #llvm.memory_effects<other = readwrite, argMem = none, inaccessibleMem = readwrite>}
155+
; CHECK-SAME: attributes {memory_effects = #llvm.memory_effects<other = readwrite, argMem = none, inaccessibleMem = readwrite>}
156156
; CHECK: llvm.return
157157
define void @func_memory() memory(readwrite, argmem: none) {
158158
ret void

mlir/test/Target/LLVMIR/Import/instructions.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,13 @@ declare void @f()
569569

570570
; CHECK-LABEL: @call_memory_effects
571571
define void @call_memory_effects() {
572-
; CHECK: llvm.call @f() {memory = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
572+
; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>}
573573
call void @f() memory(none)
574-
; CHECK: llvm.call @f() {memory = #llvm.memory_effects<other = none, argMem = write, inaccessibleMem = read>}
574+
; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects<other = none, argMem = write, inaccessibleMem = read>}
575575
call void @f() memory(none, argmem: write, inaccessiblemem: read)
576-
; CHECK: llvm.call @f() {memory = #llvm.memory_effects<other = write, argMem = none, inaccessibleMem = write>}
576+
; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects<other = write, argMem = none, inaccessibleMem = write>}
577577
call void @f() memory(write, argmem: none)
578-
; CHECK: llvm.call @f() {memory = #llvm.memory_effects<other = readwrite, argMem = readwrite, inaccessibleMem = read>}
578+
; CHECK: llvm.call @f() {memory_effects = #llvm.memory_effects<other = readwrite, argMem = readwrite, inaccessibleMem = read>}
579579
call void @f() memory(readwrite, inaccessiblemem: read)
580580
; CHECK: llvm.call @f()
581581
; CHECK-NOT: #llvm.memory_effects

mlir/test/Target/LLVMIR/llvmir.mlir

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,15 +2276,15 @@ llvm.func @readonly_function(%arg0: !llvm.ptr {llvm.readonly})
22762276

22772277
// CHECK: declare void @arg_mem_none_func() #[[ATTR:[0-9]+]]
22782278
llvm.func @arg_mem_none_func() attributes {
2279-
memory = #llvm.memory_effects<other = readwrite, argMem = none, inaccessibleMem = readwrite>}
2279+
memory_effects = #llvm.memory_effects<other = readwrite, argMem = none, inaccessibleMem = readwrite>}
22802280

22812281
// CHECK: attributes #[[ATTR]] = { memory(readwrite, argmem: none) }
22822282

22832283
// -----
22842284

22852285
// CHECK: declare void @readwrite_func() #[[ATTR:[0-9]+]]
22862286
llvm.func @readwrite_func() attributes {
2287-
memory = #llvm.memory_effects<other = readwrite, argMem = readwrite, inaccessibleMem = readwrite>}
2287+
memory_effects = #llvm.memory_effects<other = readwrite, argMem = readwrite, inaccessibleMem = readwrite>}
22882288

22892289
// CHECK: attributes #[[ATTR]] = { memory(readwrite) }
22902290

@@ -2527,16 +2527,16 @@ llvm.func @fb()
25272527
llvm.func @fc()
25282528
llvm.func @fd()
25292529

2530-
// CHECK-LABEL: @mem_none_call
2530+
// CHECK-LABEL: @mem_effects_call
25312531
// CHECK: call void @fa() #[[ATTRS_0:[0-9]+]]
25322532
// CHECK: call void @fb() #[[ATTRS_1:[0-9]+]]
25332533
// CHECK: call void @fc() #[[ATTRS_2:[0-9]+]]
25342534
// CHECK: call void @fd() #[[ATTRS_3:[0-9]+]]
2535-
llvm.func @mem_none_call() {
2536-
llvm.call @fa() {memory = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>} : () -> ()
2537-
llvm.call @fb() {memory = #llvm.memory_effects<other = read, argMem = none, inaccessibleMem = write>} : () -> ()
2538-
llvm.call @fc() {memory = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = write>} : () -> ()
2539-
llvm.call @fd() {memory = #llvm.memory_effects<other = readwrite, argMem = read, inaccessibleMem = readwrite>} : () -> ()
2535+
llvm.func @mem_effects_call() {
2536+
llvm.call @fa() {memory_effects = #llvm.memory_effects<other = none, argMem = none, inaccessibleMem = none>} : () -> ()
2537+
llvm.call @fb() {memory_effects = #llvm.memory_effects<other = read, argMem = none, inaccessibleMem = write>} : () -> ()
2538+
llvm.call @fc() {memory_effects = #llvm.memory_effects<other = read, argMem = read, inaccessibleMem = write>} : () -> ()
2539+
llvm.call @fd() {memory_effects = #llvm.memory_effects<other = readwrite, argMem = read, inaccessibleMem = readwrite>} : () -> ()
25402540
llvm.return
25412541

25422542
}

0 commit comments

Comments
 (0)