Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ using namespace mlir;
static constexpr StringRef varargsAttrName = "func.varargs";
static constexpr StringRef linkageAttrName = "llvm.linkage";
static constexpr StringRef barePtrAttrName = "llvm.bareptr";
static constexpr StringRef noInlineAttr = "no_inline";

/// Return `true` if the `op` should use bare pointer calling convention.
static bool shouldUseBarePtrCallConv(Operation *op,
Expand Down Expand Up @@ -381,6 +382,11 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
newFuncOp.setMemoryEffectsAttr(memoryAttr);
}

// Propagate no_inline attributes
if (funcOp->hasAttr(noInlineAttr)) {
newFuncOp->setAttr(noInlineAttr, rewriter.getUnitAttr());
}

// Propagate argument/result attributes to all converted arguments/result
// obtained after converting a given original argument/result.
if (ArrayAttr resAttrDicts = funcOp.getAllResultAttrs()) {
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Conversion/FuncToLLVM/convert-funcs.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,11 @@ func.func private @badllvmlinkage(i32) attributes { "llvm.linkage" = 3 : i64 } /
func.func @variadic_func(%arg0: i32) attributes { "func.varargs" = true, "llvm.emit_c_interface" } {
return
}

// -----

// Check that no_inline attribute is propagated from func::FuncOp to LLVM::LLVMFuncOp
// CHECK-LABEL: llvm.func @func_with_noinline(%arg0: i32) attributes {no_inline}
func.func @func_with_noinline(%arg0: i32) attributes { no_inline } {
return
}
Loading