public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6509] Change the 3rd parameter of function .DEFERRED_INIT from IS_VLA to decl name.
@ 2022-01-11 23:19 Qing Zhao
  0 siblings, 0 replies; only message in thread
From: Qing Zhao @ 2022-01-11 23:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6c98c8b41b031bdba5c05f4ac875baf48b9efe33

commit r12-6509-g6c98c8b41b031bdba5c05f4ac875baf48b9efe33
Author: Qing Zhao <qing.zhao@oracle.com>
Date:   Tue Jan 11 23:18:13 2022 +0000

    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.

Diff:
---
 gcc/gimplify.c                                   | 28 +++++++++++------
 gcc/internal-fn.c                                | 10 ++----
 gcc/testsuite/c-c++-common/auto-init-1.c         | 20 ++++++------
 gcc/testsuite/c-c++-common/auto-init-10.c        |  2 +-
 gcc/testsuite/c-c++-common/auto-init-11.c        |  2 +-
 gcc/testsuite/c-c++-common/auto-init-12.c        |  2 +-
 gcc/testsuite/c-c++-common/auto-init-13.c        |  4 +--
 gcc/testsuite/c-c++-common/auto-init-14.c        |  4 +--
 gcc/testsuite/c-c++-common/auto-init-15.c        |  2 +-
 gcc/testsuite/c-c++-common/auto-init-16.c        |  2 +-
 gcc/testsuite/c-c++-common/auto-init-2.c         | 20 ++++++------
 gcc/testsuite/c-c++-common/auto-init-3.c         |  6 ++--
 gcc/testsuite/c-c++-common/auto-init-4.c         |  6 ++--
 gcc/testsuite/c-c++-common/auto-init-5.c         |  6 ++--
 gcc/testsuite/c-c++-common/auto-init-6.c         |  6 ++--
 gcc/testsuite/c-c++-common/auto-init-7.c         |  8 ++---
 gcc/testsuite/c-c++-common/auto-init-8.c         |  8 ++---
 gcc/testsuite/c-c++-common/auto-init-9.c         |  4 +--
 gcc/testsuite/c-c++-common/auto-init-esra.c      |  6 ++--
 gcc/testsuite/c-c++-common/auto-init-padding-1.c |  2 +-
 gcc/testsuite/gcc.target/aarch64/auto-init-2.c   |  2 +-
 gcc/tree-cfg.c                                   | 39 ++++++------------------
 gcc/tree-sra.c                                   | 12 ++++----
 23 files changed, 93 insertions(+), 108 deletions(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d1b27d7f46f..d64d9c447ce 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -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.
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index b24102a5990..db16179c9f8 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -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);
 
diff --git a/gcc/testsuite/c-c++-common/auto-init-1.c b/gcc/testsuite/c-c++-common/auto-init-1.c
index 84ba0a90d45..df04358728b 100644
--- a/gcc/testsuite/c-c++-common/auto-init-1.c
+++ b/gcc/testsuite/c-c++-common/auto-init-1.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-10.c b/gcc/testsuite/c-c++-common/auto-init-10.c
index f35205f2a30..dda7ea1e032 100644
--- a/gcc/testsuite/c-c++-common/auto-init-10.c
+++ b/gcc/testsuite/c-c++-common/auto-init-10.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-11.c b/gcc/testsuite/c-c++-common/auto-init-11.c
index a2d66908d83..6eb468785ce 100644
--- a/gcc/testsuite/c-c++-common/auto-init-11.c
+++ b/gcc/testsuite/c-c++-common/auto-init-11.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-12.c b/gcc/testsuite/c-c++-common/auto-init-12.c
index f05d743fda0..964291c5bd9 100644
--- a/gcc/testsuite/c-c++-common/auto-init-12.c
+++ b/gcc/testsuite/c-c++-common/auto-init-12.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-13.c b/gcc/testsuite/c-c++-common/auto-init-13.c
index b0c0365b288..aa5883af770 100644
--- a/gcc/testsuite/c-c++-common/auto-init-13.c
+++ b/gcc/testsuite/c-c++-common/auto-init-13.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-14.c b/gcc/testsuite/c-c++-common/auto-init-14.c
index 986bb19faaf..dd1ff3e339d 100644
--- a/gcc/testsuite/c-c++-common/auto-init-14.c
+++ b/gcc/testsuite/c-c++-common/auto-init-14.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-15.c b/gcc/testsuite/c-c++-common/auto-init-15.c
index aa9d7fab68a..5857287ecbe 100644
--- a/gcc/testsuite/c-c++-common/auto-init-15.c
+++ b/gcc/testsuite/c-c++-common/auto-init-15.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-16.c b/gcc/testsuite/c-c++-common/auto-init-16.c
index 86493eef9e4..1e309959fc5 100644
--- a/gcc/testsuite/c-c++-common/auto-init-16.c
+++ b/gcc/testsuite/c-c++-common/auto-init-16.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-2.c b/gcc/testsuite/c-c++-common/auto-init-2.c
index 69768d6451d..6ac63bb1dda 100644
--- a/gcc/testsuite/c-c++-common/auto-init-2.c
+++ b/gcc/testsuite/c-c++-common/auto-init-2.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-3.c b/gcc/testsuite/c-c++-common/auto-init-3.c
index 062d60c1631..9d9c86d8dd0 100644
--- a/gcc/testsuite/c-c++-common/auto-init-3.c
+++ b/gcc/testsuite/c-c++-common/auto-init-3.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-4.c b/gcc/testsuite/c-c++-common/auto-init-4.c
index 9d8f23ed4e3..848df2a0e26 100644
--- a/gcc/testsuite/c-c++-common/auto-init-4.c
+++ b/gcc/testsuite/c-c++-common/auto-init-4.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-5.c b/gcc/testsuite/c-c++-common/auto-init-5.c
index 9c98a6e7ab2..9c4de612182 100644
--- a/gcc/testsuite/c-c++-common/auto-init-5.c
+++ b/gcc/testsuite/c-c++-common/auto-init-5.c
@@ -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" } } */
 
diff --git a/gcc/testsuite/c-c++-common/auto-init-6.c b/gcc/testsuite/c-c++-common/auto-init-6.c
index 3fe24562ebb..6a406447f3d 100644
--- a/gcc/testsuite/c-c++-common/auto-init-6.c
+++ b/gcc/testsuite/c-c++-common/auto-init-6.c
@@ -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" } } */
 
diff --git a/gcc/testsuite/c-c++-common/auto-init-7.c b/gcc/testsuite/c-c++-common/auto-init-7.c
index 19986969a8f..b44dd5e68ed 100644
--- a/gcc/testsuite/c-c++-common/auto-init-7.c
+++ b/gcc/testsuite/c-c++-common/auto-init-7.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-8.c b/gcc/testsuite/c-c++-common/auto-init-8.c
index 9778e911e3a..739ac028931 100644
--- a/gcc/testsuite/c-c++-common/auto-init-8.c
+++ b/gcc/testsuite/c-c++-common/auto-init-8.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-9.c b/gcc/testsuite/c-c++-common/auto-init-9.c
index 29acb7f8669..113107ffd5c 100644
--- a/gcc/testsuite/c-c++-common/auto-init-9.c
+++ b/gcc/testsuite/c-c++-common/auto-init-9.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-esra.c b/gcc/testsuite/c-c++-common/auto-init-esra.c
index 77ec02355df..ce6779f20fc 100644
--- a/gcc/testsuite/c-c++-common/auto-init-esra.c
+++ b/gcc/testsuite/c-c++-common/auto-init-esra.c
@@ -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" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-padding-1.c b/gcc/testsuite/c-c++-common/auto-init-padding-1.c
index 83db8dde832..d2e322717f0 100644
--- a/gcc/testsuite/c-c++-common/auto-init-padding-1.c
+++ b/gcc/testsuite/c-c++-common/auto-init-padding-1.c
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/auto-init-2.c b/gcc/testsuite/gcc.target/aarch64/auto-init-2.c
index 2c54e6d6038..375befd325b 100644
--- a/gcc/testsuite/gcc.target/aarch64/auto-init-2.c
+++ b/gcc/testsuite/gcc.target/aarch64/auto-init-2.c
@@ -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" } } */
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index bb3779367fe..b7fe313b70c 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -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
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 889c028f1d7..e0ea2c7b308 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-11 23:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 23:19 [gcc r12-6509] Change the 3rd parameter of function .DEFERRED_INIT from IS_VLA to decl name Qing Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).