Skip to content

Commit b306eff

Browse files
authored
[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.
1 parent b622cc6 commit b306eff

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,6 @@ struct LLVMInlinerInterface : public DialectInlinerInterface {
663663

664664
bool isLegalToInline(Operation *call, Operation *callable,
665665
bool wouldBeCloned) const final {
666-
if (!wouldBeCloned)
667-
return false;
668666
if (!isa<LLVM::CallOp>(call)) {
669667
LLVM_DEBUG(llvm::dbgs() << "Cannot inline: call is not an '"
670668
<< LLVM::CallOp::getOperationName() << "' op\n");

mlir/test/Dialect/LLVMIR/inlining.mlir

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,3 +663,16 @@ llvm.func @caller() {
663663
llvm.call @vararg_intrinrics() : () -> ()
664664
llvm.return
665665
}
666+
667+
// -----
668+
669+
llvm.func @private_func(%a : i32) -> i32 attributes {sym_visibility = "private"} {
670+
llvm.return %a : i32
671+
}
672+
673+
// CHECK-LABEL: func @caller
674+
llvm.func @caller(%x : i32) -> i32 {
675+
// CHECK-NOT: llvm.call @private_func
676+
%z = llvm.call @private_func(%x) : (i32) -> (i32)
677+
llvm.return %z : i32
678+
}

0 commit comments

Comments
 (0)