https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113466
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:90b9872311ccb24685ba33b6ba6f374d50f03874 commit r14-9490-g90b9872311ccb24685ba33b6ba6f374d50f03874 Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Mar 15 09:16:43 2024 +0100 bitint: Fix up adjustment of large/huge _BitInt arguments of returns_twice calls [PR113466] This patch (on top of the just posted gsi_safe_insert* fixes patch) fixes the instrumentation of large/huge _BitInt SSA_NAME arguments of returns_twice calls. In this case it isn't just a matter of using gsi_safe_insert_before instead of gsi_insert_before, we need to do more. One thing is that unlike the asan/ubsan instrumentation which does just some checking, here we want the statement before the call to load into a SSA_NAME which is passed to the call. With another edge we need to add a PHI, with one PHI argument the loaded SSA_NAME, another argument an uninitialized warning free SSA_NAME and a result and arrange for all 3 SSA_NAMEs to be preserved (i.e. stay as is, be no longer lowered afterwards). Unfortunately, edge_before_returns_twice_call can create new SSA_NAMEs using copy_ssa_name and while we can have a reasonable partition for them (same partition as PHI result correspoding to the PHI argument newly added), adding SSA_NAMEs into a partition after the partitions are finalized is too ugly. So, this patch takes a different approach suggested by Richi, just emit the argument loads before the returns_twice call normally (i.e. temporarily create invalid IL) and just remember that we did that, and when the bitint lowering is otherwise done fix this up, gsi_remove those statements, gsi_safe_insert_before and and create the needed new PHIs. 2024-03-15 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/113466 * gimple-lower-bitint.cc (bitint_large_huge): Add m_returns_twice_calls member. (bitint_large_huge::bitint_large_huge): Initialize it. (bitint_large_huge::~bitint_large_huge): Release it. (bitint_large_huge::lower_call): Remember ECF_RETURNS_TWICE call stmts before which at least one statement has been inserted. (gimple_lower_bitint): Move argument loads before ECF_RETURNS_TWICE calls to a different block and add corresponding PHIs. * gcc.dg/bitint-100.c: New test.