]> gcc.gnu.org Git - gcc.git/commit
bitint: Fix up adjustment of large/huge _BitInt arguments of returns_twice calls...
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Mar 2024 08:16:43 +0000 (09:16 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 15 Mar 2024 08:16:43 +0000 (09:16 +0100)
commit90b9872311ccb24685ba33b6ba6f374d50f03874
treec8bf1b841af18581d280ea49419b3d791dea82c0
parent3fd46d859cda1074125449a4cc680ce59fcebc38
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  <jakub@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.
gcc/gimple-lower-bitint.cc
gcc/testsuite/gcc.dg/bitint-100.c [new file with mode: 0644]
This page took 0.068222 seconds and 5 git commands to generate.