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

Yifeng Dong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 27 06:50:55 PST 2021


dongAxis1944 added inline comments.


================
Comment at: lib/Transforms/IPO/FunctionSpecialization.cpp:209
+        // IPSCCP to propagate the constant arguments.
+        Function *Clone = cloneCandidateFunction(F);
+        Argument *ClonedArg = Clone->arg_begin() + A.getArgNo();
----------------
sanwou01 wrote:
> dongAxis1944 wrote:
> > i think cloneCandidateFunction might become ‘compile time killer’, think the following case:
> > 
> > ```
> > f(int arg1, int arg2) {...}
> > g(1, 2);
> > ```
> > this patch might clone 'f' twice. But i think it might be avoid.
> It looks like the outer loop would terminate on the first argument that can be used for specialization. So for your example, assuming there is only one call to `f` we would first specialize into
> ```
> f.arg1(int arg2) { arg1 = 1; ... }
> f.arg1(2);
> ```
> and on the next call to `specializeFunctions` into 
> ```
> f.arg1.arg2() { arg1 = 1; arg2 = 2; ... }
> f.arg1.arg2();
> ```
> 
> In general, yes, this pass has the potential to impact compile time significantly, especially if there are many possible (known constant) values for some arguments. That is why a good cost model (`isArgumentInteresting`) is important.
yes, you right.   do you have any plan to construct a call graph(not likely scc in llvm) to calculate all the possible value of arguments? Then clone and simplify the function, i think it might faster than this.


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