From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C19B93858024; Wed, 23 Nov 2022 01:42:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C19B93858024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669167751; bh=ukWBk0t/dd/DjUUT1jHZsci+PqBAsGs7Kc38Kok6e8Y=; h=From:To:Subject:Date:From; b=L6Q3JoXZpAzoDaiU7KiSeII3wEoonMo+jDIn/GfdpKGjLPOqzWMLv7gUYnszAbE2K Zuu4V6a1OjtXegoeWPhJfnz7uoQo4hTG6bYnhYRkUdIhlfTffD9u0QbAPhW0EACBje 03FmAYcuf+VqFxCxtf7cIz0bbb1qIO0fI8yUZ0A0= From: "fxue at os dot amperecomputing.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107828] New: tree-inlining would generate SSA with incorrect def stmt Date: Wed, 23 Nov 2022 01:42:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fxue at os dot amperecomputing.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107828 Bug ID: 107828 Summary: tree-inlining would generate SSA with incorrect def stmt Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: fxue at os dot amperecomputing.com Target Milestone: --- In the function "remap_gimple_op_r" of tree-inlining.cc: ... if (TREE_CODE (*tp) =3D=3D SSA_NAME) { *tp =3D remap_ssa_name (*tp, id); *walk_subtrees =3D 0; if (is_lhs) SSA_NAME_DEF_STMT (*tp) =3D wi_p->stmt; return NULL; } The definition statement of original "*tp" may be same as wi_p->stmt. So, we will end up with a statement that it is pointed by both old and new SSA nam= e, while the old one should have been reclaimed. And this happens when some parameter needs to be adjusted during inline versioning as: remap_gimple_stmt() { ... if (id->param_body_adjs) { ... if (!gimple_seq_empty_p (extra_stmts)) { memset (&wi, 0, sizeof (wi)); wi.info =3D id; for (gimple_stmt_iterator egsi =3D gsi_start (extra_stmts); !gsi_end_p (egsi); gsi_next (&egsi)) walk_gimple_op (gsi_stmt (egsi), remap_gimple_op_r, &wi); ^^^^^^^^^^^^^^^^^ ... } } ... }=