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]

fix compile/20030224-1.c


The problem with this test case is that we'd never gimplified the type,
which led to the rtl expansion abort.  We should almost never have to do
any of this, thus pushing the work inside the TREE_CONSTANT check.

Bootstrapped and tested on alphaev67-linux.

Also tested vs the regression on i686-linux, but I'm seeing something
that looks like memory corruption there under C++ only (!), which is
very strange since this code cannot be invoked under C++.

So not checked in yet.


r~


	* c-gimplify.c (gimplify_decl_stmt): Push gimplify_one_sizepos inside
	non-constant size check.  Gimplify the type too.  Tidy building
	BUILT_IN_STACK_ALLOC call.

Index: c-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-gimplify.c,v
retrieving revision 2.17
diff -c -p -d -r2.17 c-gimplify.c
*** c-gimplify.c	23 Jun 2004 07:43:18 -0000	2.17
--- c-gimplify.c	23 Jun 2004 18:01:32 -0000
*************** gimplify_decl_stmt (tree *stmt_p)
*** 488,512 ****
      {
        tree init = DECL_INITIAL (decl);
  
-       gimplify_one_sizepos (&DECL_SIZE (decl), stmt_p);
-       gimplify_one_sizepos (&DECL_SIZE_UNIT (decl), stmt_p);
- 
        if (!TREE_CONSTANT (DECL_SIZE (decl)))
  	{
  	  /* This is a variable-sized decl.  Simplify its size and mark it
  	     for deferred expansion.  Note that mudflap depends on the format
  	     of the emitted code: see mx_register_decls().  */
  
! 	  tree pt_type = build_pointer_type (TREE_TYPE (decl));
! 	  tree alloc_stmt
! 	    = (build_function_call_expr
! 	       (implicit_built_in_decls[BUILT_IN_STACK_ALLOC],
! 		tree_cons (NULL_TREE,
! 			   build1 (ADDR_EXPR, pt_type, decl),
! 			   tree_cons (NULL_TREE, DECL_SIZE_UNIT (decl),
! 				      NULL_TREE))));
  
! 	  gimplify_and_add (alloc_stmt, stmt_p);
  	  DECL_DEFER_OUTPUT (decl) = 1;
  	}
  
--- 488,512 ----
      {
        tree init = DECL_INITIAL (decl);
  
        if (!TREE_CONSTANT (DECL_SIZE (decl)))
  	{
  	  /* This is a variable-sized decl.  Simplify its size and mark it
  	     for deferred expansion.  Note that mudflap depends on the format
  	     of the emitted code: see mx_register_decls().  */
  
! 	  tree t, args;
  
! 	  gimplify_type_sizes (TREE_TYPE (decl), stmt_p);
! 	  gimplify_one_sizepos (&DECL_SIZE (decl), stmt_p);
! 	  gimplify_one_sizepos (&DECL_SIZE_UNIT (decl), stmt_p);
! 
! 	  args = tree_cons (NULL, DECL_SIZE_UNIT (decl), NULL);
! 	  t = build_fold_addr_expr (decl);
! 	  args = tree_cons (NULL, t, args);
! 	  t = implicit_built_in_decls[BUILT_IN_STACK_ALLOC];
! 	  t = build_function_call_expr (t, args);
! 
! 	  gimplify_and_add (t, stmt_p);
  	  DECL_DEFER_OUTPUT (decl) = 1;
  	}
  


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