[PATCH] D93838: [SCCP] Add Function Specialization pass
Chuanqi Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 19 18:47:52 PDT 2021
ChuanqiXu added a comment.
In D93838#2769900 <https://reviews.llvm.org/D93838#2769900>, @davidxl wrote:
> For the motivating case from MCF, there is actually code in InlineCost Analysis to handle it. See InlineCostCallAnalyzer::onLoweredCall(..). If it is not already handled there, it is a bug to be fixed there.
It is hard to believe that inline could handle the case in MCF. The case in MCF is there is a function `spec_qsort` with signature `(void*, size_t, size_t, int*(const void*, const void*))`. And there is two calls to `spec_qsort`:
spec_qsort(perm + 1, basket_sizes[thread], sizeof(BASKET*),
(int (*)(const void *, const void *))cost_compare);
// and
spec_qsort(arcs_pointer_sorted[thread], new_arcs_array[thread], sizeof(arc_p),
(int (*)(const void *, const void *))arc_compare);
And the benefit comes from function specialization specialize spec_qsort with cost_compare and arc_compare. And finally, cost_compare and arc_compare are inlined in the specialized function. In my minds, without function specialization, compiler couldn't determine the value for the function pointer at compile time. So the inlining couldn't happen.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93838/new/
https://reviews.llvm.org/D93838
More information about the llvm-commits
mailing list