[PATCH] D115509: [FuncSpec] Respect MaxConstantsThreshold

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 17 01:46:21 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG78a392cf9f34: [FuncSpec] Respect MaxConstantsThreshold (authored by SjoerdMeijer).

Changed prior to commit:
  https://reviews.llvm.org/D115509?vs=393443&id=395071#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115509/new/

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
@@ -409,11 +409,15 @@
         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.395071.patch
Type: text/x-patch
Size: 1644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211217/7979626a/attachment.bin>


More information about the llvm-commits mailing list