Skip to content

Commit 8a24db8

Browse files
committed
[FuncSpec] Enable SpecializeLiteralConstant by default
Enable specialization on literal constant arguments by default in Function Specialization.
1 parent dd76d9b commit 8a24db8

11 files changed

+27
-28
lines changed

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,11 @@ static cl::opt<bool> SpecializeOnAddress(
8484
"funcspec-on-address", cl::init(false), cl::Hidden, cl::desc(
8585
"Enable function specialization on the address of global values"));
8686

87-
// Disabled by default as it can significantly increase compilation times.
88-
//
89-
// https://llvm-compile-time-tracker.com
90-
// https://github.com/nikic/llvm-compile-time-tracker
9187
static cl::opt<bool> SpecializeLiteralConstant(
92-
"funcspec-for-literal-constant", cl::init(false), cl::Hidden, cl::desc(
93-
"Enable specialization of functions that take a literal constant as an "
94-
"argument"));
88+
"funcspec-for-literal-constant", cl::init(true), cl::Hidden,
89+
cl::desc(
90+
"Enable specialization of functions that take a literal constant as an "
91+
"argument"));
9592

9693
bool InstCostVisitor::canEliminateSuccessor(BasicBlock *BB, BasicBlock *Succ,
9794
DenseSet<BasicBlock *> &DeadBlocks) {
@@ -682,10 +679,9 @@ bool FunctionSpecializer::run() {
682679
(RequireMinSize && Metrics.NumInsts < MinFunctionSize))
683680
continue;
684681

685-
// TODO: For now only consider recursive functions when running multiple
686-
// times. This should change if specialization on literal constants gets
687-
// enabled.
688-
if (!Inserted && !Metrics.isRecursive && !SpecializeLiteralConstant)
682+
// When specialization on literal constants is disabled, only consider
683+
// recursive functions when running multiple times.
684+
if (!SpecializeLiteralConstant && !Inserted && !Metrics.isRecursive)
689685
continue;
690686

691687
int64_t Sz = *Metrics.NumInsts.getValue();

llvm/test/DebugInfo/Generic/ipsccp-remap-assign-id.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: opt -passes=ipsccp %s -S -o - | FileCheck %s
2-
; RUN: opt --try-experimental-debuginfo-iterators -passes=ipsccp %s -S -o - | FileCheck %s
1+
; RUN: opt -passes=ipsccp -funcspec-for-literal-constant=false %s -S -o - | FileCheck %s
2+
; RUN: opt --try-experimental-debuginfo-iterators -passes=ipsccp -funcspec-for-literal-constant=false %s -S -o - | FileCheck %s
33

44
;; Check the dbg.assign DIAssignID operand gets remapped after cloning.
55

llvm/test/Transforms/FunctionSpecialization/compiler-crash-58759.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -S --passes="default<O3>" < %s | FileCheck %s
1+
; RUN: opt -S --passes="default<O3>" -funcspec-for-literal-constant=false < %s | FileCheck %s
22

33
define dso_local i32 @g0(i32 noundef %x) local_unnamed_addr {
44
entry:

llvm/test/Transforms/FunctionSpecialization/function-specialization-constant-expression.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; Note that this test case shows that function specialization pass would
55
; transform the function even if no specialization happened.
66

7-
; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s | FileCheck %s
7+
; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -funcspec-for-literal-constant=false -S < %s | FileCheck %s
88

99
%struct = type { i8, i16, i32, i64, i64}
1010
@Global = internal constant %struct {i8 0, i16 1, i32 2, i64 3, i64 4}

llvm/test/Transforms/FunctionSpecialization/function-specialization2.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
2-
; RUN: opt -passes="ipsccp<func-spec>,deadargelim" -force-specialization -S < %s | FileCheck %s
3-
; RUN: opt -passes="ipsccp<func-spec>,deadargelim" -funcspec-max-iters=1 -force-specialization -S < %s | FileCheck %s --check-prefix=ONE-ITER
4-
; RUN: opt -passes="ipsccp<func-spec>,deadargelim" -funcspec-max-iters=0 -force-specialization -S < %s | FileCheck %s --check-prefix=DISABLED
2+
; RUN: opt -passes="ipsccp<func-spec>,deadargelim" -funcspec-for-literal-constant=false -force-specialization -S < %s | FileCheck %s
3+
; RUN: opt -passes="ipsccp<func-spec>,deadargelim" -funcspec-for-literal-constant=false -funcspec-max-iters=1 -force-specialization -S < %s | FileCheck %s --check-prefix=ONE-ITER
4+
; RUN: opt -passes="ipsccp<func-spec>,deadargelim" -funcspec-for-literal-constant=false -funcspec-max-iters=0 -force-specialization -S < %s | FileCheck %s --check-prefix=DISABLED
55

66

77
define internal i32 @func(ptr %0, i32 %1, ptr nocapture %2) {

llvm/test/Transforms/FunctionSpecialization/function-specialization4.ll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
; RUN: opt -passes="ipsccp<func-spec>" -force-specialization \
2-
; RUN: -funcspec-max-clones=2 -S < %s | FileCheck %s
2+
; RUN: -funcspec-for-literal-constant=false -funcspec-max-clones=2 \
3+
; RUN: -S < %s | FileCheck %s
34

45
; RUN: opt -passes="ipsccp<func-spec>" -force-specialization \
5-
; RUN: -funcspec-max-clones=1 -S < %s | FileCheck %s --check-prefix=CONST1
6+
; RUN: -funcspec-for-literal-constant=false -funcspec-max-clones=1 \
7+
; RUN: -S < %s | FileCheck %s --check-prefix=CONST1
68

79
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
810

llvm/test/Transforms/FunctionSpecialization/get-possible-constants.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -S --passes="ipsccp<func-spec>" < %s | FileCheck %s
1+
; RUN: opt -S --passes="ipsccp<func-spec>" -funcspec-for-literal-constant=false < %s | FileCheck %s
22
define dso_local i32 @p0(i32 noundef %x) {
33
entry:
44
%add = add nsw i32 %x, 1

llvm/test/Transforms/FunctionSpecialization/global-rank.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -S --passes="ipsccp<func-spec>" -funcspec-max-clones=1 < %s | FileCheck %s
1+
; RUN: opt -S --passes="ipsccp<func-spec>" -funcspec-for-literal-constant=false -funcspec-max-clones=1 < %s | FileCheck %s
22
define internal i32 @f(i32 noundef %x, ptr nocapture noundef readonly %p, ptr nocapture noundef readonly %q) noinline {
33
entry:
44
%call = tail call i32 %p(i32 noundef %x)

llvm/test/Transforms/FunctionSpecialization/identical-specializations.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
2-
; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s | FileCheck %s
2+
; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -funcspec-for-literal-constant=false -S < %s | FileCheck %s
33

44
define i64 @main(i64 %x, i64 %y, i1 %flag) {
55
entry:

llvm/test/Transforms/FunctionSpecialization/literal-const.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
; RUN: opt -S --passes="ipsccp<func-spec>" \
2+
; RUN: -funcspec-for-literal-constant=false \
23
; RUN: -force-specialization < %s | FileCheck %s -check-prefix CHECK-NOLIT
34
; RUN: opt -S --passes="ipsccp<func-spec>" \
4-
; RUN: -funcspec-for-literal-constant \
5+
; RUN: -funcspec-for-literal-constant=true \
56
; RUN: -force-specialization < %s | FileCheck %s -check-prefix CHECK-LIT
67

78
define i32 @f0(i32 noundef %x) {

0 commit comments

Comments
 (0)