Skip to content

Commit 2c2f6a3

Browse files
committed
[mlir] Adding 'no_inline' and 'always_inline' attributes on mlir::LLMV::CallOp
1 parent 924c7ea commit 2c2f6a3

File tree

4 files changed

+56
-21
lines changed

4 files changed

+56
-21
lines changed

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -771,23 +771,21 @@ def LLVM_CallOp : LLVM_MemAccessOpBase<"call",
771771
}];
772772

773773
dag args = (ins OptionalAttr<TypeAttrOf<LLVM_FunctionType>>:$var_callee_type,
774-
OptionalAttr<FlatSymbolRefAttr>:$callee,
775-
Variadic<LLVM_Type>:$callee_operands,
776-
DefaultValuedAttr<LLVM_FastmathFlagsAttr,
777-
"{}">:$fastmathFlags,
778-
OptionalAttr<DenseI32ArrayAttr>:$branch_weights,
779-
DefaultValuedAttr<CConv, "CConv::C">:$CConv,
780-
DefaultValuedAttr<TailCallKind, "TailCallKind::None">:$TailCallKind,
781-
OptionalAttr<LLVM_MemoryEffectsAttr>:$memory_effects,
782-
OptionalAttr<UnitAttr>:$convergent,
783-
OptionalAttr<UnitAttr>:$no_unwind,
784-
OptionalAttr<UnitAttr>:$will_return,
785-
VariadicOfVariadic<LLVM_Type,
786-
"op_bundle_sizes">:$op_bundle_operands,
787-
DenseI32ArrayAttr:$op_bundle_sizes,
788-
OptionalAttr<ArrayAttr>:$op_bundle_tags,
789-
OptionalAttr<DictArrayAttr>:$arg_attrs,
790-
OptionalAttr<DictArrayAttr>:$res_attrs);
774+
OptionalAttr<FlatSymbolRefAttr>:$callee,
775+
Variadic<LLVM_Type>:$callee_operands,
776+
DefaultValuedAttr<LLVM_FastmathFlagsAttr, "{}">:$fastmathFlags,
777+
OptionalAttr<DenseI32ArrayAttr>:$branch_weights,
778+
DefaultValuedAttr<CConv, "CConv::C">:$CConv,
779+
DefaultValuedAttr<TailCallKind, "TailCallKind::None">:$TailCallKind,
780+
OptionalAttr<LLVM_MemoryEffectsAttr>:$memory_effects,
781+
OptionalAttr<UnitAttr>:$convergent, OptionalAttr<UnitAttr>:$no_unwind,
782+
OptionalAttr<UnitAttr>:$will_return,
783+
VariadicOfVariadic<LLVM_Type, "op_bundle_sizes">:$op_bundle_operands,
784+
DenseI32ArrayAttr:$op_bundle_sizes,
785+
OptionalAttr<ArrayAttr>:$op_bundle_tags,
786+
OptionalAttr<DictArrayAttr>:$arg_attrs,
787+
OptionalAttr<DictArrayAttr>:$res_attrs, OptionalAttr<UnitAttr>:$no_inline,
788+
OptionalAttr<UnitAttr>:$always_inline);
791789
// Append the aliasing related attributes defined in LLVM_MemAccessOpBase.
792790
let arguments = !con(args, aliasAttrs);
793791
let results = (outs Optional<LLVM_Type>:$result);

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,8 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
10361036
/*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
10371037
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr,
10381038
/*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
1039-
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
1039+
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr,
1040+
/*no_inline*/ nullptr, /*always_inline*/ nullptr);
10401041
}
10411042

10421043
void CallOp::build(OpBuilder &builder, OperationState &state,
@@ -1064,7 +1065,8 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
10641065
/*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
10651066
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr,
10661067
/*access_groups=*/nullptr,
1067-
/*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
1068+
/*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr,
1069+
/*no_inline*/ nullptr, /*always_inline*/ nullptr);
10681070
}
10691071

10701072
void CallOp::build(OpBuilder &builder, OperationState &state,
@@ -1078,7 +1080,8 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
10781080
/*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
10791081
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr,
10801082
/*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
1081-
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
1083+
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr,
1084+
/*no_inline*/ nullptr, /*always_inline*/ nullptr);
10821085
}
10831086

10841087
void CallOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func,
@@ -1092,7 +1095,8 @@ void CallOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func,
10921095
/*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
10931096
/*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
10941097
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr,
1095-
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
1098+
/*noalias_scopes=*/nullptr, /*tbaa=*/nullptr,
1099+
/*no_inline*/ nullptr, /*always_inline*/ nullptr);
10961100
}
10971101

10981102
CallInterfaceCallable CallOp::getCallableForCallee() {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
319319
call->addFnAttr(llvm::Attribute::NoUnwind);
320320
if (callOp.getWillReturnAttr())
321321
call->addFnAttr(llvm::Attribute::WillReturn);
322+
if (callOp.getNoInlineAttr())
323+
call->addFnAttr(llvm::Attribute::NoInline);
324+
if (callOp.getAlwaysInlineAttr())
325+
call->addFnAttr(llvm::Attribute::AlwaysInline);
322326

323327
if (failed(convertParameterAndResultAttrs(callOp, call, moduleTranslation)))
324328
return failure();

mlir/test/Target/LLVMIR/llvmir.mlir

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,35 @@ llvm.func @willreturn_call() {
26212621
// CHECK: #[[ATTRS]]
26222622
// CHECK-SAME: willreturn
26232623

2624+
// -----
2625+
2626+
llvm.func @f()
2627+
2628+
// CHECK-LABEL: @no_inline_call
2629+
// CHECK-SAME: #[[ATTRS:[0-9]+]]
2630+
llvm.func @no_inline_call() {
2631+
llvm.call @f() {no_inline} : () -> ()
2632+
llvm.return
2633+
}
2634+
2635+
// CHECK: #[[ATTRS]]
2636+
// CHECK-SAME: noinline
2637+
2638+
// -----
2639+
2640+
llvm.func @f()
2641+
2642+
// CHECK-LABEL: @always_inline_call
2643+
// CHECK-SAME: #[[ATTRS:[0-9]+]]
2644+
llvm.func @always_inline_call() {
2645+
llvm.call @f() {always_inline} : () -> ()
2646+
llvm.return
2647+
}
2648+
2649+
// CHECK: #[[ATTRS]]
2650+
// CHECK-SAME: alwaysinline
2651+
2652+
26242653
// -----
26252654

26262655
llvm.func @fa()

0 commit comments

Comments
 (0)