[PATCH] D139346: [FuncSpec] Global ranking of specialisations

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 10:14:52 PST 2022


chill created this revision.
Herald added subscribers: snehasish, ormris, hiraditya.
Herald added a project: All.
chill requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The `FunctionSpecialization` pass chooses specializations among the opportunities
presented by a single function and its calls, progressively penalizing subsequent
specialization attempts by artificially increasing the cost of a specialization, depending
on how many specialization were applied before. Thus the chosen specializations are
sensitive to the order the functions appear in the module and may be worse than
others, had those others been considered earlier.

This patch makes the `FunctionSpecialization` pass rank the specializations globally, i.e. 
choose the "best" specializations amongst the all possible specializations
in the module, for all functions.

Since this involved quite a bit of redesign of the pass data structures, this patch also carries:

- removal of duplicate specializations
- optimization of call sites update, by collecting per specialization the list of call sites that can be directly rewritten, without prior expensive check if the call constants and their positions match those of the specialized function.


https://reviews.llvm.org/D139346

Files:
  llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h
  llvm/include/llvm/Transforms/Utils/SCCPSolver.h
  llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
  llvm/test/Transforms/FunctionSpecialization/global-rank.ll
  llvm/test/Transforms/FunctionSpecialization/identical-specializations.ll
  llvm/test/Transforms/FunctionSpecialization/specialization-order.ll
  llvm/test/Transforms/FunctionSpecialization/specialize-multiple-arguments.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139346.480151.patch
Type: text/x-patch
Size: 30737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221205/1c718640/attachment.bin>


More information about the llvm-commits mailing list