[PATCH] D106426: [FuncSpec] Support specialising recursive functions

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 22 02:08:24 PDT 2021


SjoerdMeijer added a comment.

Thanks for looking at this!
Have inlined my response to some queries below, and am now going to address the code comments now.

In D106426#2892809 <https://reviews.llvm.org/D106426#2892809>, @ChuanqiXu wrote:

> The example in the summary looks a little bit scaring at the first glance. I thought it may specialize 1000 times if the code looks like:
>
>   int Global = 1;
>   void recursiveFunc(int *arg) {
>     if (*arg < 1000) {
>       print(*arg);
>       recursiveFunc(*arg + 1);
>     }
>   }
>   void main() {
>     recursiveFunc(&Global);
>   }
>
> And I found that it is controlled by `FuncSpecializationMaxIters` which is 1 by default.

Exactly, this is controlled by option `-function-specialization-max-iters` which indeed defaults to 1, but in the new tests you'll see that higher values are used to do more iterations and specialise recursive functions.

> And my question is: what would be different if we don't change the value for `FuncSpecializationMaxIters`?

I have no plan to change the default number of iterations at this point. First, I wanted to get this features in, so that it can be controlled with this option. But next, when we start looking at enabling the function specialisation pass by default and need to look at compile times again, we can revise this what would be acceptable. Or perhaps we do need a "aggressive" options, that sets the number of iterations to some value. But yeah, getting function specialisation enabled by default is going to be difficult, and didn't want to make it even more difficult by consider changing the default at this point


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

https://reviews.llvm.org/D106426



More information about the llvm-commits mailing list