Skip to content

[mlir][LLVM] Allow call_intrinsic to inline #70940

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

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

nicolasvasilache
Copy link
Contributor

LLVM::CallIntrinsicOp was previously overlooked from the isLegalToInline.

LLVM::CallIntrinsicOp was previously overlooked from the isLegalToInline.
@llvmbot
Copy link
Member

llvmbot commented Nov 1, 2023

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-llvm

Author: Nicolas Vasilache (nicolasvasilache)

Changes

LLVM::CallIntrinsicOp was previously overlooked from the isLegalToInline.


Full diff: https://github.com/llvm/llvm-project/pull/70940.diff

2 Files Affected:

  • (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp (+1)
  • (modified) mlir/test/Dialect/LLVMIR/inlining.mlir (+2)
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
index b40be73ff21f703..6063abdba7b9a1f 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
@@ -694,6 +694,7 @@ struct LLVMInlinerInterface : public DialectInlinerInterface {
             LLVM::AtomicRMWOp,
             LLVM::AtomicCmpXchgOp,
             LLVM::CallOp,
+            LLVM::CallIntrinsicOp,
             LLVM::DbgDeclareOp,
             LLVM::DbgLabelOp,
             LLVM::DbgValueOp,
diff --git a/mlir/test/Dialect/LLVMIR/inlining.mlir b/mlir/test/Dialect/LLVMIR/inlining.mlir
index 3f14dc6de6b764c..1296b8e031c1330 100644
--- a/mlir/test/Dialect/LLVMIR/inlining.mlir
+++ b/mlir/test/Dialect/LLVMIR/inlining.mlir
@@ -28,6 +28,7 @@ func.func @inner_func_inlinable(%ptr : !llvm.ptr) -> i32 {
   llvm.unreachable
 ^bb2:
   llvm.intr.stackrestore %stack : !llvm.ptr
+  llvm.call_intrinsic "llvm.x86.sse41.round.ss"() : () -> (vector<8xf32>)
   return %1 : i32
 }
 
@@ -50,6 +51,7 @@ func.func @inner_func_inlinable(%ptr : !llvm.ptr) -> i32 {
 // CHECK: llvm.inline_asm has_side_effects "foo", "bar"
 // CHECK: llvm.unreachable
 // CHECK: llvm.intr.stackrestore %[[STACK]]
+// CHECK: llvm.call_intrinsic "llvm.x86.sse41.round.ss"(
 func.func @test_inline(%ptr : !llvm.ptr) -> i32 {
   %0 = call @inner_func_inlinable(%ptr) : (!llvm.ptr) -> i32
   return %0 : i32

Copy link
Contributor

@definelicht definelicht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We can think about whether it's time to remove the allowlist, if there are few or no unhandled cases left (potentially making a disallowlist instead - debug info handling comes to mind).

@nicolasvasilache nicolasvasilache merged commit 8c0ec79 into llvm:main Nov 1, 2023
@nicolasvasilache nicolasvasilache deleted the inline branch November 1, 2023 14:42
@joker-eph
Copy link
Collaborator

I definitely don't quite get why we have an allowlist in the first place: does the LLVM inliner has such list?

@definelicht
Copy link
Contributor

I definitely don't quite get why we have an allowlist in the first place: does the LLVM inliner has such list?

It is/was a migration strategy to be able to gradually develop the inliner to be feature complete. The LLVM inliner is quite, let's say, "decentralized", so there's no single place to see a list of features that must be supported :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants