Change the 3rd parameter of function .DEFERRED_INIT from IS_VLA to decl name.

Currently, the 3rd parameter of function .DEFERRED_INIT is IS_VLA, which is
not needed at all;

In this patch, we change the 3rd parameter from IS_VLA to the name of the var
decl for the following purposes:

1. Fix (or work around) PR103720:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103720

As confirmed in PR103720, with the current definition of .DEFERRED_INIT,

Dom transformed:
  c$a$0_6 = .DEFERRED_INIT (8, 2, 0);
  _1 = .DEFERRED_INIT (8, 2, 0);

into:
  c$a$0_6 = .DEFERRED_INIT (8, 2, 0);
  _1 = c$a$0_6;

which is incorrectly done due to Dom treating the two calls to const function
.DEFERRED_INIT as the same call since all actual parameters are the same.

The same issue has been exposed in PR102608 due to a different optimization VN,
the fix for PR102608 is to specially handle call to .DEFERRED_INIT in VN to
exclude it from CSE.

To fix PR103720, we could do the same as the fix to PR102608 to specially
handle call to .DEFERRED_INIT in Dom to exclude it from being optimized.

However, in addition to Dom and VN, there should be other optimizations that
have the same issue as PR103720 or PR102608 (As I built Linux kernel with
-ftrivial-auto-var-init=zero -Werror, I noticed a bunch of bugos warnings).

Other than identifying all the optimizations and specially handling call to
.DEFERRED_INIT in all these optimizations, changing the 3rd parameter of the
function .DEFERRED_INIT from IS_VLA to the name string of the var decl might
be a better workaround (or a fix). After this change, since the 3rd actual
parameter is the name string of the variable, different calls for different
variables will have different name strings as the 3rd actual, As a result, the
optimization that previously treated the different calls to .DEFERRED_INIT as
the same will be prevented.

2. Prepare for enabling -Wuninitialized + -ftrivail-auto-var-init for address
taken variables.

As discussion in the following thread:

https://gcc.gnu.org/pipermail/gcc-patches/2021-August/577431.html

With the current implemenation of -ftrivial-auto-var-init and uninitialized
warning analysis, the uninitialized warning for an address taken auto variable
might be missed since the variable is completely eliminated by optimization and
replaced with a temporary variable in all the uses.

In order to improve such situation, changing the 3rd parameter of the function
.DEFERRED_INIT to the name string of the variable will provide necessary
information to uninitialized warning analysis to make the missing warning
possible.

gcc/ChangeLog:

2022-01-11  qing zhao  <qing.zhao@oracle.com>

	* gimplify.c (gimple_add_init_for_auto_var): Delete the 3rd argument.
	Change the 3rd argument of function .DEFERRED_INIT to the name of the
	decl.
	(gimplify_decl_expr): Delete the 3rd argument when call
	gimple_add_init_for_auto_var.
	* internal-fn.c (expand_DEFERRED_INIT): Update comments to reflect
	the 3rd argument change of function .DEFERRED_INIT.
	* tree-cfg.c (verify_gimple_call): Update comments and verification
	to reflect the 3rd argument change of function .DEFERRED_INIT.
	* tree-sra.c (generate_subtree_deferred_init): Delete the 3rd argument.
	(sra_modify_deferred_init): Change the 3rd argument of function
	.DEFERRED_INIT to the name of the decl.

gcc/testsuite/ChangeLog:

2022-01-11  qing zhao  <qing.zhao@oracle.com>

	* c-c++-common/auto-init-1.c: Adjust testcase to reflect the 3rd
	argument change of function .DEFERRED_INIT.
	* c-c++-common/auto-init-10.c: Likewise.
	* c-c++-common/auto-init-11.c: Likewise.
	* c-c++-common/auto-init-12.c: Likewise.
	* c-c++-common/auto-init-13.c: Likewise.
	* c-c++-common/auto-init-14.c: Likewise.
	* c-c++-common/auto-init-15.c: Likewise.
	* c-c++-common/auto-init-16.c: Likewise.
	* c-c++-common/auto-init-2.c: Likewise.
	* c-c++-common/auto-init-3.c: Likewise.
	* c-c++-common/auto-init-4.c: Likewise.
	* c-c++-common/auto-init-5.c: Likewise.
	* c-c++-common/auto-init-6.c: Likewise.
	* c-c++-common/auto-init-7.c: Likewise.
	* c-c++-common/auto-init-8.c: Likewise.
	* c-c++-common/auto-init-9.c: Likewise.
	* c-c++-common/auto-init-esra.c: Likewise.
	* c-c++-common/auto-init-padding-1.c: Likewise.
	* gcc.target/aarch64/auto-init-2.c: Likewise.
This commit is contained in:
Qing Zhao 2022-01-11 23:18:13 +00:00
parent a01be2f309
commit 6c98c8b41b
23 changed files with 93 additions and 108 deletions

View file

@ -1748,16 +1748,13 @@ force_labels_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
Build a call to internal const function DEFERRED_INIT:
1st argument: SIZE of the DECL;
2nd argument: INIT_TYPE;
3rd argument: IS_VLA, 0 NO, 1 YES;
3rd argument: NAME of the DECL;
as LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL). */
as LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, IS_VLA)
if IS_VLA is false, the LHS is the DECL itself,
if IS_VLA is true, the LHS is a MEM_REF whose address is the pointer
to this DECL. */
static void
gimple_add_init_for_auto_var (tree decl,
enum auto_init_type init_type,
bool is_vla,
gimple_seq *seq_p)
{
gcc_assert (auto_var_p (decl));
@ -1767,13 +1764,25 @@ gimple_add_init_for_auto_var (tree decl,
tree init_type_node
= build_int_cst (integer_type_node, (int) init_type);
tree is_vla_node
= build_int_cst (integer_type_node, (int) is_vla);
tree decl_name = NULL_TREE;
if (DECL_NAME (decl))
decl_name = build_string_literal (IDENTIFIER_LENGTH (DECL_NAME (decl)) + 1,
IDENTIFIER_POINTER (DECL_NAME (decl)));
else
{
char *decl_name_anonymous = xasprintf ("D.%u", DECL_UID (decl));
decl_name = build_string_literal (strlen (decl_name_anonymous) + 1,
decl_name_anonymous);
free (decl_name_anonymous);
}
tree call = build_call_expr_internal_loc (loc, IFN_DEFERRED_INIT,
TREE_TYPE (decl), 3,
decl_size, init_type_node,
is_vla_node);
decl_name);
gimplify_assign (decl, call, seq_p);
}
@ -1947,7 +1956,6 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
{
gimple_add_init_for_auto_var (decl,
flag_auto_var_init,
is_vla,
seq_p);
/* The expanding of a call to the above .DEFERRED_INIT will apply
block initialization to the whole space covered by this variable.

View file

@ -3011,11 +3011,7 @@ expand_UNIQUE (internal_fn, gcall *stmt)
}
/* Expand the IFN_DEFERRED_INIT function:
LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, IS_VLA);
if IS_VLA is false, the LHS is the DECL itself,
if IS_VLA is true, the LHS is a MEM_REF whose address is the pointer
to this DECL.
LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL);
Initialize the LHS with zero/pattern according to its second argument
INIT_TYPE:
@ -3071,8 +3067,8 @@ expand_DEFERRED_INIT (internal_fn, gcall *stmt)
if (!reg_lhs)
{
/* If this is a VLA or the variable is not in register,
expand to a memset to initialize it. */
/* If the variable is not in register, expand to a memset
to initialize it. */
mark_addressable (lhs);
tree var_addr = build_fold_addr_expr (lhs);

View file

@ -29,13 +29,13 @@ void foo()
return;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, 2, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 2, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 2, \&\"temp3\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 2, \&\"temp4\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 2, \&\"temp5\"" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 2, \&\"temp5\"" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 2, \&\"temp6\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 2, \&\"temp7\"" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 2, \&\"temp7\"" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 2, \&\"temp8\"" "gimple" } } */

View file

@ -18,5 +18,5 @@ void foo()
return;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, 1, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(" "gimple" } } */

View file

@ -11,4 +11,4 @@ void foo(int n)
return;
}
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 2, 1\\)" "gimple" } } */
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 2, \&\"arr\"" "gimple" } } */

View file

@ -11,4 +11,4 @@ void foo(int n)
return;
}
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 1, 1\\)" "gimple" } } */
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 1, \&\"arr\"" "gimple" } } */

View file

@ -19,5 +19,5 @@ int foo()
return d.b + var.bar.b;
}
/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, 1, \&\"d\"" "gimple" } } */
/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, 1, \&\"var\"" "gimple" } } */

View file

@ -19,5 +19,5 @@ int foo()
return d.b + var.bar.b;
}
/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, 2, \&\"d\"" "gimple" } } */
/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, 2, \&\"var\"" "gimple" } } */

View file

@ -10,4 +10,4 @@ void foo(int a)
g(x);
}
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 2, 1\\)" "gimple" } } */
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 2, \&\"x\"" "gimple" } } */

View file

@ -10,4 +10,4 @@ void foo(int a)
g(x);
}
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 1, 1\\)" "gimple" } } */
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, 1, \&\"x\"" "gimple" } } */

View file

@ -29,13 +29,13 @@ void foo()
return;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, 1, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, 1, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, 1, \&\"temp3\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, 1, \&\"temp4\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, 1, \&\"temp5\"" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, 1, \&\"temp5\"" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, 1, \&\"temp6\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, 1, \&\"temp7\"" "gimple" { target ilp32 } } } */
/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, 1, \&\"temp7\"" "gimple" { target lp64 } } } */
/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, 1, \&\"temp8\"" "gimple" } } */

View file

@ -14,6 +14,6 @@ long double foo()
return result;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 2, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 2, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 2, \&\"temp3\"" "gimple" } } */

View file

@ -14,6 +14,6 @@ long double foo()
return result;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, 1, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, 1, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), 1, \&\"temp3\"" "gimple" } } */

View file

@ -15,7 +15,7 @@ _Complex long double foo()
return result;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 2, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 2, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 2, \&\"temp3\"" "gimple" } } */

View file

@ -15,7 +15,7 @@ _Complex long double foo()
return result;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, 1, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, 1, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), 1, \&\"temp3\"" "gimple" } } */

View file

@ -29,7 +29,7 @@ double foo()
return result;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, 2, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, 2, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, 2, \&\"temp3\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(8, 2, \&\"temp4\"" "gimple" } } */

View file

@ -29,7 +29,7 @@ double foo()
return result;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(8, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, 1, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, 1, \&\"temp2\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, 1, \&\"temp3\"" "gimple" } } */
/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(8, 1, \&\"temp4\"" "gimple" } } */

View file

@ -16,5 +16,5 @@ void foo()
return;
}
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(8, 2, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, 2, \&\"temp1\"" "gimple" } } */
/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(8, 2, \&\"temp2\"" "gimple" } } */

View file

@ -1,6 +1,6 @@
/* Verify the strength reduction adjustment for -ftrivial-auto-var-init. */
/* { dg-do compile } */
/* { dg-options "-O2 -ftrivial-auto-var-init=zero -fdump-tree-gimple -fdump-tree-esra" } */
/* { dg-options "-O2 -ftrivial-auto-var-init=zero -fno-PIC -fdump-tree-gimple -fdump-tree-esra" } */
typedef double VECTOR[3];
@ -31,5 +31,5 @@ void VCross(VECTOR a, const VECTOR b, const VECTOR c)
Assign_Vector(a, tmp);
}
/* { dg-final { scan-tree-dump-times "tmp = .DEFERRED_INIT \\(24, 2, 0\\)" 1 "gimple" } } */
/* { dg-final { scan-tree-dump-times ".DEFERRED_INIT \\(8, 2, 0\\)" 3 "esra" } } */
/* { dg-final { scan-tree-dump-times "tmp = .DEFERRED_INIT \\(24, 2, \&\"tmp\"" 1 "gimple" } } */
/* { dg-final { scan-tree-dump-times ".DEFERRED_INIT \\(8, 2, \&\"tmp\"" 3 "esra" } } */

View file

@ -19,5 +19,5 @@ void foo(int a)
g(s);
}
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(24, 1, 0\\)" "gimple" } } */
/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(24, 1, \&\"s\"" "gimple" } } */
/* { dg-final { scan-tree-dump "__builtin_clear_padding" "gimple" } } */

View file

@ -32,4 +32,4 @@ void foo()
/* { dg-final { scan-rtl-dump-times "0xfe\\\]" 1 "expand" } } */
/* { dg-final { scan-rtl-dump-times "0xfffffffffffffefe" 1 "expand" } } */
/* { dg-final { scan-rtl-dump-times "0xfffffffffefefefe" 2 "expand" } } */
/* { dg-final { scan-rtl-dump-times "0xfefefefefefefefe" 2 "expand" } } */
/* { dg-final { scan-rtl-dump-times "0xfefefefefefefefe" 3 "expand" } } */

View file

@ -3455,19 +3455,14 @@ verify_gimple_call (gcall *stmt)
}
/* For a call to .DEFERRED_INIT,
LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, IS_VLA)
we should guarantee that the 1st and the 3rd arguments are consistent:
1st argument: SIZE of the DECL;
3rd argument: IS_VLA, 0 NO, 1 YES;
LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL)
we should guarantee that when the 1st argument is a constant, it should
be the same as the size of the LHS. */
if IS_VLA is false, the 1st argument should be a constant and the same as
the size of the LHS. */
if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
{
tree size_of_arg0 = gimple_call_arg (stmt, 0);
tree size_of_lhs = TYPE_SIZE_UNIT (TREE_TYPE (lhs));
tree is_vla_node = gimple_call_arg (stmt, 2);
bool is_vla = (bool) TREE_INT_CST_LOW (is_vla_node);
if (TREE_CODE (lhs) == SSA_NAME)
lhs = SSA_NAME_VAR (lhs);
@ -3477,27 +3472,13 @@ verify_gimple_call (gcall *stmt)
&size_from_arg0);
bool is_constant_size_lhs = poly_int_tree_p (size_of_lhs,
&size_from_lhs);
if (!is_vla)
{
if (!is_constant_size_arg0)
{
error ("%<DEFFERED_INIT%> calls for non-VLA should have "
"constant size for the first argument");
return true;
}
else if (!is_constant_size_lhs)
{
error ("%<DEFFERED_INIT%> calls for non-VLA should have "
"constant size for the LHS");
return true;
}
else if (maybe_ne (size_from_arg0, size_from_lhs))
{
error ("%<DEFFERED_INIT%> calls for non-VLA should have same "
"constant size for the first argument and LHS");
return true;
}
}
if (is_constant_size_arg0 && is_constant_size_lhs)
if (maybe_ne (size_from_arg0, size_from_lhs))
{
error ("%<DEFFERED_INIT%> calls should have same "
"constant size for the first argument and LHS");
return true;
}
}
/* ??? The C frontend passes unpromoted arguments in case it

View file

@ -4123,7 +4123,7 @@ get_repl_default_def_ssa_name (struct access *racc, tree reg_type)
static void
generate_subtree_deferred_init (struct access *access,
tree init_type,
tree is_vla,
tree decl_name,
gimple_stmt_iterator *gsi,
location_t loc)
{
@ -4135,7 +4135,7 @@ generate_subtree_deferred_init (struct access *access,
gimple *call
= gimple_build_call_internal (IFN_DEFERRED_INIT, 3,
TYPE_SIZE_UNIT (TREE_TYPE (repl)),
init_type, is_vla);
init_type, decl_name);
gimple_call_set_lhs (call, repl);
gsi_insert_before (gsi, call, GSI_SAME_STMT);
update_stmt (call);
@ -4144,7 +4144,7 @@ generate_subtree_deferred_init (struct access *access,
}
if (access->first_child)
generate_subtree_deferred_init (access->first_child, init_type,
is_vla, gsi, loc);
decl_name, gsi, loc);
access = access ->next_sibling;
}
@ -4152,7 +4152,7 @@ generate_subtree_deferred_init (struct access *access,
}
/* For a call to .DEFERRED_INIT:
var = .DEFERRED_INIT (size_of_var, init_type, is_vla);
var = .DEFERRED_INIT (size_of_var, init_type, name_of_var);
examine the LHS variable VAR and replace it with a scalar replacement if
there is one, also replace the RHS call to a call to .DEFERRED_INIT of
the corresponding scalar relacement variable. Examine the subtree and
@ -4164,7 +4164,7 @@ sra_modify_deferred_init (gimple *stmt, gimple_stmt_iterator *gsi)
{
tree lhs = gimple_call_lhs (stmt);
tree init_type = gimple_call_arg (stmt, 1);
tree is_vla = gimple_call_arg (stmt, 2);
tree decl_name = gimple_call_arg (stmt, 2);
struct access *lhs_access = get_access_for_expr (lhs);
if (!lhs_access)
@ -4185,7 +4185,7 @@ sra_modify_deferred_init (gimple *stmt, gimple_stmt_iterator *gsi)
if (lhs_access->first_child)
generate_subtree_deferred_init (lhs_access->first_child,
init_type, is_vla, gsi, loc);
init_type, decl_name, gsi, loc);
if (lhs_access->grp_covered)
{
unlink_stmt_vdef (stmt);