[PATCH] D115509: [FuncSpec] Respect MaxConstantsThreshold
Sjoerd Meijer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 10 04:01:24 PST 2021
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: ChuanqiXu, snehasish, labrinea.
Herald added subscribers: ormris, hiraditya.
SjoerdMeijer requested review of this revision.
Herald added a project: LLVM.
This is a follow up of D115458 <https://reviews.llvm.org/D115458> and splits off the function change.
This truncates the worklist to 'MaxConstantsThreshold' candidates if the `MaxConstantsThreshold` was exceeded. It changes the behaviour of option `-func-specialization-max-constants`. Before it didn't specialise at all when this threshold was exceeded, but now it specialises up to `MaxConstantsThreshold` candidates from the sorted worklist.
https://reviews.llvm.org/D115509
Files:
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
llvm/test/Transforms/FunctionSpecialization/function-specialization4.ll
Index: llvm/test/Transforms/FunctionSpecialization/function-specialization4.ll
===================================================================
--- llvm/test/Transforms/FunctionSpecialization/function-specialization4.ll
+++ llvm/test/Transforms/FunctionSpecialization/function-specialization4.ll
@@ -38,7 +38,7 @@
ret i32 %add1
}
-; CONST1-NOT: define internal i32 @foo.1(i32 %x, i32* %b, i32* %c)
+; CONST1: define internal i32 @foo.1(i32 %x, i32* %b, i32* %c)
; CONST1-NOT: define internal i32 @foo.2(i32 %x, i32* %b, i32* %c)
; CHECK: define internal i32 @foo.1(i32 %x, i32* %b, i32* %c) {
Index: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -406,11 +406,15 @@
llvm::sort(Worklist,
[] (ArgInfo &L, ArgInfo &R) { return L.Gain > R.Gain; });
- // TODO: truncate the worklist to 'MaxConstantsThreshold' candidates if
+ // Truncate the worklist to 'MaxConstantsThreshold' candidates if
// necessary.
if (Worklist.size() > MaxConstantsThreshold) {
- Worklist.clear();
- continue;
+ LLVM_DEBUG(dbgs() << "FnSpecialization: number of constants exceed "
+ << "the maximum number of constants threshold.\n"
+ << "Truncating worklist to " << MaxConstantsThreshold
+ << " candidates.\n");
+ Worklist.erase(Worklist.begin() + MaxConstantsThreshold,
+ Worklist.end());
}
if (IsPartial || Worklist.size() < ActualConstArg.size())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115509.393443.patch
Type: text/x-patch
Size: 1704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211210/de261ca8/attachment.bin>
More information about the llvm-commits
mailing list