This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR34462, another bug with create_ssa_artifical_load_stmt


This fixes another unexpected non-renamed VOPs bug in connection with
PRE and create_ssa_artifical_load_stmt.

The problem is that the operand scanner is triggered on a fake store 
inserted
by PRE insert_fake_stores() as if a new stmt_ann is generated, the stmt is
marked modified and bsi_insert_after() will update the stmts operands in 
this
case.

For some reason this figures new, unrenamed virtual operands:

# VUSE <SFT.2_69, SFT.3_70, SFT.4, SFT.5, SFT.6, SMT.15_71> { SFT.2 SFT.3 
SFT.4
SFT.5 SFT.6 SMT.15 }
storetmp.19_3 = *dest_22

which triggers this ICE.

So, I believe we should not re-build operands for this stmt, as we 
carefuly
use create_ssa_artificial_load_stmt () to do so.  In fact, this will make
the following part of that function non-effective:

  /* All uses in this fake stmt must not be in the immediate use lists.  
*/
  FOR_EACH_SSA_USE_OPERAND (use_p, new_stmt, iter, SSA_OP_ALL_USES)
    delink_imm_use (use_p);

Of course, making this effective again confuses SCCVN which really doesn't
like "broken" immediate uses which causes VN_TOPs to leak out.

Fixed by adding a parameter to create_ssa_artifical_load_stmt to say
if we want immediate uses to be de-linked (we do for DOM, but not
for PRE).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to
mainline.

Richard.

2007-12-14  Richard Guenther  <rguenther@suse.de>

	PR middle-end/34462
	* tree-ssa-operands.h (create_ssa_artificial_load_stmt): Add
	parameter to say whether to unlink immediate uses.
	* tree-ssa-operands.c (create_ssa_artificial_load_stmt): Do not
	mark the artificial stmt as modified.  Unlink immediate uses
	only if requested.
	* tree-ssa-dom.c (record_equivalences_from_stmt): Update caller.
	* tree-ssa-pre.c (insert_fake_stores): Likewise.

	* gcc.c-torture/compile/20071214-1.c: New testcase.

Index: tree-ssa-operands.c
===================================================================
*** tree-ssa-operands.c	(revision 130928)
--- tree-ssa-operands.c	(working copy)
*************** copy_virtual_operands (tree dest, tree s
*** 2647,2663 ****
     create an artificial stmt which looks like a load from the store, this can
     be used to eliminate redundant loads.  OLD_OPS are the operands from the 
     store stmt, and NEW_STMT is the new load which represents a load of the
!    values stored.  */
  
  void
! create_ssa_artificial_load_stmt (tree new_stmt, tree old_stmt)
  {
    tree op;
    ssa_op_iter iter;
    use_operand_p use_p;
    unsigned i;
  
!   get_stmt_ann (new_stmt);
  
    /* Process NEW_STMT looking for operands.  */
    start_ssa_stmt_operands ();
--- 2647,2669 ----
     create an artificial stmt which looks like a load from the store, this can
     be used to eliminate redundant loads.  OLD_OPS are the operands from the 
     store stmt, and NEW_STMT is the new load which represents a load of the
!    values stored.  If DELINK_IMM_USES_P is specified, the immediate
!    uses of this stmt will be de-linked.  */
  
  void
! create_ssa_artificial_load_stmt (tree new_stmt, tree old_stmt,
! 				 bool delink_imm_uses_p)
  {
    tree op;
    ssa_op_iter iter;
    use_operand_p use_p;
    unsigned i;
+   stmt_ann_t ann;
  
!   /* Create the stmt annotation but make sure to not mark the stmt
!      as modified as we will build operands ourselves.  */
!   ann = get_stmt_ann (new_stmt);
!   ann->modified = 0;
  
    /* Process NEW_STMT looking for operands.  */
    start_ssa_stmt_operands ();
*************** create_ssa_artificial_load_stmt (tree ne
*** 2687,2694 ****
    finalize_ssa_stmt_operands (new_stmt);
  
    /* All uses in this fake stmt must not be in the immediate use lists.  */
!   FOR_EACH_SSA_USE_OPERAND (use_p, new_stmt, iter, SSA_OP_ALL_USES)
!     delink_imm_use (use_p);
  }
  
  
--- 2693,2701 ----
    finalize_ssa_stmt_operands (new_stmt);
  
    /* All uses in this fake stmt must not be in the immediate use lists.  */
!   if (delink_imm_uses_p)
!     FOR_EACH_SSA_USE_OPERAND (use_p, new_stmt, iter, SSA_OP_ALL_USES)
!       delink_imm_use (use_p);
  }
  
  
Index: tree-ssa-operands.h
===================================================================
*** tree-ssa-operands.h	(revision 130928)
--- tree-ssa-operands.h	(working copy)
*************** extern void free_stmt_operands (tree);
*** 210,216 ****
  extern bool verify_imm_links (FILE *f, tree var);
  
  extern void copy_virtual_operands (tree, tree);
! extern void create_ssa_artificial_load_stmt (tree, tree);
  
  extern void dump_immediate_uses (FILE *file);
  extern void dump_immediate_uses_for (FILE *file, tree var);
--- 210,216 ----
  extern bool verify_imm_links (FILE *f, tree var);
  
  extern void copy_virtual_operands (tree, tree);
! extern void create_ssa_artificial_load_stmt (tree, tree, bool);
  
  extern void dump_immediate_uses (FILE *file);
  extern void dump_immediate_uses_for (FILE *file, tree var);
Index: tree-ssa-dom.c
===================================================================
*** tree-ssa-dom.c	(revision 130928)
--- tree-ssa-dom.c	(working copy)
*************** record_equivalences_from_stmt (tree stmt
*** 1618,1624 ****
  	  /* Build a new statement with the RHS and LHS exchanged.  */
  	  new_stmt = build_gimple_modify_stmt (rhs, lhs);
  
! 	  create_ssa_artificial_load_stmt (new_stmt, stmt);
  
  	  /* Finally enter the statement into the available expression
  	     table.  */
--- 1618,1624 ----
  	  /* Build a new statement with the RHS and LHS exchanged.  */
  	  new_stmt = build_gimple_modify_stmt (rhs, lhs);
  
! 	  create_ssa_artificial_load_stmt (new_stmt, stmt, true);
  
  	  /* Finally enter the statement into the available expression
  	     table.  */
Index: tree-ssa-pre.c
===================================================================
*** tree-ssa-pre.c	(revision 130928)
--- tree-ssa-pre.c	(working copy)
*************** insert_fake_stores (void)
*** 3171,3177 ****
  
  	      lhs = make_ssa_name (storetemp, new_tree);
  	      GIMPLE_STMT_OPERAND (new_tree, 0) = lhs;
! 	      create_ssa_artificial_load_stmt (new_tree, stmt);
  
  	      NECESSARY (new_tree) = 0;
  	      VEC_safe_push (tree, heap, inserted_exprs, new_tree);
--- 3171,3177 ----
  
  	      lhs = make_ssa_name (storetemp, new_tree);
  	      GIMPLE_STMT_OPERAND (new_tree, 0) = lhs;
! 	      create_ssa_artificial_load_stmt (new_tree, stmt, false);
  
  	      NECESSARY (new_tree) = 0;
  	      VEC_safe_push (tree, heap, inserted_exprs, new_tree);
Index: testsuite/gcc.c-torture/compile/20071214-1.c
===================================================================
*** testsuite/gcc.c-torture/compile/20071214-1.c	(revision 0)
--- testsuite/gcc.c-torture/compile/20071214-1.c	(revision 0)
***************
*** 0 ****
--- 1,15 ----
+ typedef __builtin_va_list va_list;
+ void gftp_config_parse_args (int numargs, char **first, ...)
+ {
+   char **dest = first;
+   va_list argp;
+   __builtin_va_start (argp, first);
+   while (numargs-- > 0)
+     {
+       *dest = __builtin_malloc (1);
+       dest = __builtin_va_arg(argp, char **);
+       *dest = ((void *)0);
+     }
+   __builtin_va_end(argp);
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]