AutoFDO: Don't try to promote indirect calls that result in recursive direct calls
authorEugene Rozenfeld <erozen@microsoft.com>
Wed, 9 Feb 2022 07:00:33 +0000 (23:00 -0800)
committerEugene Rozenfeld <erozen@microsoft.com>
Thu, 10 Feb 2022 07:33:10 +0000 (23:33 -0800)
commitba125745d9e9fe90a18a2af8701b3269c5fdd468
treeec7c6b95fa344b78dc44cbccaeb7d02b4a6a6027
parent41582f88ec01c5ce2f85ebc4ac2743eb426d6e33
AutoFDO: Don't try to promote indirect calls that result in recursive direct calls

AutoFDO tries to promote and inline all indirect calls that were promoted
and inlined in the original binary and that are still hot. In the included
test case, the promotion results in a direct call that is a recursive call.
inline_call and optimize_inline_calls can't handle recursive calls at this stage.
Currently, inline_call fails with a segmentation fault.

This change leaves the indirect call alone if promotion will result in a recursive call.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:
* auto-profile.cc (afdo_indirect_call): Don't attempt to promote indirect calls
that will result in direct recursive calls.

gcc/testsuite/ChangeLog:
* g++.dg/tree-prof/indir-call-recursive-inlining.C : New test.
gcc/auto-profile.cc
gcc/testsuite/g++.dg/tree-prof/indir-call-recursive-inlining.C [new file with mode: 0644]