Skip to content

Commit f65e0b3

Browse files
committed
Address comments from ellishg
1 parent 9a955fd commit f65e0b3

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

llvm/lib/CGData/StableFunctionMap.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static cl::opt<unsigned> GlobalMergingMaxParams(
3838
cl::init(std::numeric_limits<unsigned>::max()), cl::Hidden);
3939
static cl::opt<bool> GlobalMergingSkipNoParams(
4040
"global-merging-skip-no-params",
41-
cl::desc("Skip merging functions with no parameters."), cl::init(false),
41+
cl::desc("Skip merging functions with no parameters."), cl::init(true),
4242
cl::Hidden);
4343
static cl::opt<double> GlobalMergingInstOverhead(
4444
"global-merging-inst-overhead",
@@ -181,6 +181,11 @@ static bool isProfitable(
181181
unsigned ParamCount = UniqueHashVals.size();
182182
if (ParamCount > GlobalMergingMaxParams)
183183
return false;
184+
// Theoretically, if ParamCount is 0, it results in identical code folding
185+
// (ICF), which we can skip merging here since the linker already handles
186+
// ICF. This pass would otherwise introduce unnecessary thunks that are
187+
// merely direct jumps. However, enabling this could be beneficial depending
188+
// on downstream passes, so we provide an option for it.
184189
if (GlobalMergingSkipNoParams && ParamCount == 0)
185190
return false;
186191
Cost += ParamCount * GlobalMergingParamOverhead + GlobalMergingCallOverhead;

llvm/test/CodeGen/Generic/cgdata-merge-no-params.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
; can be controlled by the -global-merging-skip-no-params option.
88

99
; RUN: llc -enable-global-merge-func=true -global-merging-skip-no-params=false < %s | FileCheck %s --check-prefix=MERGE
10-
; RUN: llc -enable-global-merge-func=true -global-merging-skip-no-params=true < %s | FileCheck %s --check-prefix=NOMERGE
10+
; RUN: llc -enable-global-merge-func=true -global-merging-skip-no-params=true < %s | FileCheck %s --implicit-check-not=".Tgm"
1111

1212
; MERGE: _f1.Tgm
1313
; MERGE: _f2.Tgm
1414

15-
; NOMERGE-NOT: _f1.Tgm
16-
; NOMERGE-NOT: _f2.Tgm
17-
1815
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
1916
target triple = "arm64-unknown-ios12.0.0"
2017

0 commit comments

Comments
 (0)