[Mlir-commits] [mlir] b306eff - [MLIR] Enable inlining for private symbols (#122572)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Jan 11 06:10:31 PST 2025
Author: William Moses
Date: 2025-01-11T09:10:27-05:00
New Revision: b306eff56f950285e01c7accdb36f09d17506dcc
URL: https://github.com/llvm/llvm-project/commit/b306eff56f950285e01c7accdb36f09d17506dcc
DIFF: https://github.com/llvm/llvm-project/commit/b306eff56f950285e01c7accdb36f09d17506dcc.diff
LOG: [MLIR] Enable inlining for private symbols (#122572)
The inlining code for llvm funcs seems to have needlessly forbidden
inlining of private (e.g. non-cloning) symbols.
Added:
Modified:
mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
mlir/test/Dialect/LLVMIR/inlining.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
index dd20412ee70801..b3bed5ab5f412f 100644
--- a/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
@@ -663,8 +663,6 @@ struct LLVMInlinerInterface : public DialectInlinerInterface {
bool isLegalToInline(Operation *call, Operation *callable,
bool wouldBeCloned) const final {
- if (!wouldBeCloned)
- return false;
if (!isa<LLVM::CallOp>(call)) {
LLVM_DEBUG(llvm::dbgs() << "Cannot inline: call is not an '"
<< LLVM::CallOp::getOperationName() << "' op\n");
diff --git a/mlir/test/Dialect/LLVMIR/inlining.mlir b/mlir/test/Dialect/LLVMIR/inlining.mlir
index 0b7ca3f2bb048a..edaac4da0b044c 100644
--- a/mlir/test/Dialect/LLVMIR/inlining.mlir
+++ b/mlir/test/Dialect/LLVMIR/inlining.mlir
@@ -663,3 +663,16 @@ llvm.func @caller() {
llvm.call @vararg_intrinrics() : () -> ()
llvm.return
}
+
+// -----
+
+llvm.func @private_func(%a : i32) -> i32 attributes {sym_visibility = "private"} {
+ llvm.return %a : i32
+}
+
+// CHECK-LABEL: func @caller
+llvm.func @caller(%x : i32) -> i32 {
+ // CHECK-NOT: llvm.call @private_func
+ %z = llvm.call @private_func(%x) : (i32) -> (i32)
+ llvm.return %z : i32
+}
More information about the Mlir-commits
mailing list