-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[mlir][llvm] Respect call noinline attr in inliner #134493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit extends the LLVM dialect inliner interface to respect the call op's noinline attribute. This is a follow-up to llvm#133726 which added the noinline attribute to the LLVM dialect call op.
@llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-mlir Author: Tobias Gysi (gysit) ChangesThis commit extends the LLVM dialect inliner interface to respect the call op's noinline attribute. This is a follow-up to #133726 Full diff: https://github.com/llvm/llvm-project/pull/134493.diff 2 Files Affected:
diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
index aab8d037cd8d2..1edf7fd070b27 100644
--- a/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
@@ -664,11 +664,16 @@ struct LLVMInlinerInterface : public DialectInlinerInterface {
bool isLegalToInline(Operation *call, Operation *callable,
bool wouldBeCloned) const final {
- if (!isa<LLVM::CallOp>(call)) {
+ auto callOp = dyn_cast<LLVM::CallOp>(call);
+ if (!callOp) {
LLVM_DEBUG(llvm::dbgs() << "Cannot inline: call is not an '"
<< LLVM::CallOp::getOperationName() << "' op\n");
return false;
}
+ if (callOp.getNoInline()) {
+ LLVM_DEBUG(llvm::dbgs() << "Cannot inline: call is marked no_inline\n");
+ return false;
+ }
auto funcOp = dyn_cast<LLVM::LLVMFuncOp>(callable);
if (!funcOp) {
LLVM_DEBUG(llvm::dbgs()
diff --git a/mlir/test/Dialect/LLVMIR/inlining.mlir b/mlir/test/Dialect/LLVMIR/inlining.mlir
index eb249a4771753..136d0f85d509a 100644
--- a/mlir/test/Dialect/LLVMIR/inlining.mlir
+++ b/mlir/test/Dialect/LLVMIR/inlining.mlir
@@ -95,7 +95,7 @@ llvm.func @foo() -> (i32) attributes { no_inline } {
llvm.return %0 : i32
}
-llvm.func @bar() -> (i32) attributes { no_inline } {
+llvm.func @bar() -> (i32) {
%0 = llvm.mlir.constant(1 : i32) : i32
llvm.return %0 : i32
}
@@ -106,7 +106,7 @@ llvm.func @callee_with_multiple_blocks(%cond: i1) -> (i32) {
%0 = llvm.call @foo() : () -> (i32)
llvm.br ^bb3(%0: i32)
^bb2:
- %1 = llvm.call @bar() : () -> (i32)
+ %1 = llvm.call @bar() { no_inline } : () -> (i32)
llvm.br ^bb3(%1: i32)
^bb3(%arg: i32):
llvm.return %arg : i32
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, thanks!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/199/builds/2636 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/41/builds/5983 Here is the relevant piece of the build log for the reference
|
This commit extends the LLVM dialect inliner interface to respect the call op's noinline attribute. This is a follow-up to #133726
which added the noinline attribute to the LLVM dialect call op.