Skip to content

Commit 906b3cb

Browse files
authored
Add -sil-inline-never-function flag (#32660)
-sil-inline-never-functions already exists, but it does a substring match. This is not desired all the time. Add -sil-inline-never-function flag that does a full string match and avoids inlining functions with that name
1 parent 890df57 commit 906b3cb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ llvm::cl::opt<std::string>
1919
SILInlineNeverFuns("sil-inline-never-functions", llvm::cl::init(""),
2020
llvm::cl::desc("Never inline functions whose name "
2121
"includes this string."));
22+
llvm::cl::list<std::string>
23+
SILInlineNeverFun("sil-inline-never-function", llvm::cl::CommaSeparated,
24+
llvm::cl::desc("Never inline functions whose name "
25+
"is this string"));
2226

2327
//===----------------------------------------------------------------------===//
2428
// ConstantTracker
@@ -697,6 +701,13 @@ SILFunction *swift::getEligibleFunction(FullApplySite AI,
697701
&& Callee->getName().find(SILInlineNeverFuns, 0) != StringRef::npos)
698702
return nullptr;
699703

704+
if (!SILInlineNeverFun.empty() &&
705+
SILInlineNeverFun.end() != std::find(SILInlineNeverFun.begin(),
706+
SILInlineNeverFun.end(),
707+
Callee->getName())) {
708+
return nullptr;
709+
}
710+
700711
if (!Callee->shouldOptimize()) {
701712
return nullptr;
702713
}

test/SILOptimizer/array_contentof_opt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -Xllvm '-sil-inline-never-functions=$sSa6appendyy' %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -Xllvm '-sil-inline-never-functions=$sSa6appendyy' -Xllvm -sil-inline-never-function='$sSa6append10contentsOfyqd__n_t7ElementQyd__RszSTRd__lFSi_SaySiGTg5' %s | %FileCheck %s
22
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
33

44
// This is an end-to-end test of the Array.append(contentsOf:) ->

0 commit comments

Comments
 (0)