[PATCH] D93838: [LLVM] [SCCP] : Add Function Specialization pass

Chuanqi Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 04:29:20 PDT 2021


ChuanqiXu added a comment.

I tried to run this pass with aggressive mode for SPEC2017 in LTO. Then the compilation time seems to be extremely long. It can't compile one benchmark with 2 hours. I think we should add options to limit the iterations times or re-factor the cost-model.



================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:99
+// THe maximum number of clones allowed for a single function specialization:
+static const unsigned MaxConstantsThreshold = 3;
+
----------------
Could we use cl::opt<unsigned>? It would be easy to tuning.


================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:102
+// Assuming the average loop iteration count.
+static const unsigned AvgLoopIterationCount = 10;
+
----------------
Same with above.


================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:2392
+      SmallVector<Constant *, 4> Constants;
+      if (!isArgumentInteresting(&A, Constants, IsPartial))
+        continue;
----------------
If there is a callsite look like this:
```
foo(1, 2, 3, 4);
```
Would the compiler transform it into?
```
foo_1(2, 3, 4);
```
then
```
foo_1_2(3, 4)
```
then
```
foo_1_2_3(4)
```
finally
```
foo_1_2_3_4()
```
The process looks a little bit weird.



================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:2908
+    // Run only one iteration if the aggresive flag is not on.
+    if (!IsAggressive)
+      break;
----------------
It looks we should add a iteration counter and an option to limit the times of iterations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93838



More information about the llvm-commits mailing list