[FuncSpec] Support function specialization across multiple arguments.
authorAlexandros Lamprineas <alexandros.lamprineas@arm.com>
Wed, 23 Mar 2022 14:51:16 +0000 (14:51 +0000)
committerAlexandros Lamprineas <alexandros.lamprineas@arm.com>
Mon, 28 Mar 2022 11:01:53 +0000 (12:01 +0100)
commit8045bf9d0dc5be3a8b8d075fdfe23828f4b7d70e
tree4925585b8e4222023961658dbfa59ab52f468d46
parent4ca111d4cb4c0b425268c86b54fb19c4be2e88dd
[FuncSpec] Support function specialization across multiple arguments.

The current implementation of Function Specialization does not allow
specializing more than one arguments per function call, which is a
limitation I am lifting with this patch.

My main challenge was to choose the most suitable ADT for storing the
specializations. We need an associative container for binding all the
actual arguments of a specialization to the function call. We also
need a consistent iteration order across executions. Lastly we want
to be able to sort the entries by Gain and reject the least profitable
ones.

MapVector fits the bill but not quite; erasing elements is expensive
and using stable_sort messes up the indices to the underlying vector.
I am therefore using the underlying vector directly after calculating
the Gain.

Differential Revision: https://reviews.llvm.org/D119880
llvm/include/llvm/Transforms/Utils/SCCPSolver.h
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
llvm/lib/Transforms/Utils/SCCPSolver.cpp
llvm/test/Transforms/FunctionSpecialization/function-specialization4.ll
llvm/test/Transforms/FunctionSpecialization/specialize-multiple-arguments.ll [new file with mode: 0644]