Skip to content

Commit

Permalink
tree-optimization/109139 - fix .DEFERRED_INIT removal
Browse files Browse the repository at this point in the history
The following make sure to strip MEMs when looking for unused
decls on the LHS of .DEFERRED_INIT.

	PR tree-optimization/109139
	* tree-ssa-live.cc (remove_unused_locals): Look at the
	base address for unused decls on the LHS of .DEFERRED_INIT.

	* gcc.dg/torture/pr109139.c: New testcase.
  • Loading branch information
rguenth committed Mar 15, 2023
1 parent 45641f3 commit 0fc541e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions gcc/testsuite/gcc.dg/torture/pr109139.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* { dg-do compile } */
/* { dg-additional-options "-ftrivial-auto-var-init=zero" } */

const int COMPARE_CANDIDATE;
char ipmi_ek_compare_link_record1_0, ipmi_ek_compare_link_record2_0;
void ipmi_ek_compare_link()
{
for (; ipmi_ek_compare_link_record1_0;)
for (; ipmi_ek_compare_link_record2_0;) {
int link[COMPARE_CANDIDATE];
}
}
3 changes: 2 additions & 1 deletion gcc/tree-ssa-live.cc
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,8 @@ remove_unused_locals (void)
else if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
{
tree lhs = gimple_call_lhs (stmt);
if (DECL_P (lhs) && !is_used_p (lhs))
tree base = get_base_address (lhs);
if (DECL_P (base) && !is_used_p (base))
{
unlink_stmt_vdef (stmt);
gsi_remove (&gsi, true);
Expand Down

0 comments on commit 0fc541e

Please sign in to comment.