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]

builtin_alloca broken in 32/64 machines


On machines where ptr_mode != Pmode, builtin alloca causes an ICE since
allocate_dynamic_stack_space is being called as if it returned a ptr_mode
value, but it's really returning Pmode.

Thu Feb  1 07:22:41 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* builtins.c (expand_builtin_alloca): allocate_dynamic_stack_space
	returns Pmode pseudo, but we need ptr_mode.
	* explow.c (allocate_dynamic_stack_space): Use plus_constant.
	Remove bogus conversions; use HOST_WIDE_INT for size.
	Don't use TARGET if wrong mode.

*** builtins.c	2001/01/28 01:50:04	1.92
--- builtins.c	2001/02/01 11:45:45
*************** expand_builtin_alloca (arglist, target)
*** 3102,3105 ****
--- 3103,3107 ----
  {
    rtx op0;
+   rtx result;
  
    if (!validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE))
*************** expand_builtin_alloca (arglist, target)
*** 3110,3114 ****
  
    /* Allocate the desired space.  */
!   return allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
  }
  
--- 3112,3122 ----
  
    /* Allocate the desired space.  */
!   result = allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
! 
! #ifdef POINTERS_EXTEND_UNSIGNED
!   result = convert_memory_address (ptr_mode, result);
! #endif
! 
!   return result;
  }
  
*** explow.c	2001/01/22 18:59:36	1.56
--- explow.c	2001/02/01 11:46:02
*************** allocate_dynamic_stack_space (size, targ
*** 1295,1307 ****
  
    if (MUST_ALIGN)
!     {
!       if (GET_CODE (size) == CONST_INT)
! 	size = GEN_INT (INTVAL (size)
! 			+ (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1));
!       else
! 	size = expand_binop (Pmode, add_optab, size,
! 			     GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1),
! 			     NULL_RTX, 1, OPTAB_LIB_WIDEN);
!     }
  
  #ifdef SETJMP_VIA_SAVE_AREA
--- 1295,1302 ----
  
    if (MUST_ALIGN)
!     size
!       = force_operand (plus_constant (size, 
! 				      BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1),
! 		       NULL_RTX);
  
  #ifdef SETJMP_VIA_SAVE_AREA
*************** allocate_dynamic_stack_space (size, targ
*** 1326,1335 ****
  	/* If anyone creates a target with these characteristics, let them
  	   know that our optimization cannot work correctly in such a case.  */
! 	abort();
  #endif
  
  	if (GET_CODE (size) == CONST_INT)
  	  {
! 	    int new = INTVAL (size) / align * align;
  
  	    if (INTVAL (size) != new)
--- 1321,1330 ----
  	/* If anyone creates a target with these characteristics, let them
  	   know that our optimization cannot work correctly in such a case.  */
! 	abort ();
  #endif
  
  	if (GET_CODE (size) == CONST_INT)
  	  {
! 	    HOST_WIDE_INT new = INTVAL (size) / align * align;
  
  	    if (INTVAL (size) != new)
*************** allocate_dynamic_stack_space (size, targ
*** 1396,1402 ****
      probe_stack_range (STACK_CHECK_MAX_FRAME_SIZE + STACK_CHECK_PROTECT, size);
  
!   /* Don't use a TARGET that isn't a pseudo.  */
    if (target == 0 || GET_CODE (target) != REG
!       || REGNO (target) < FIRST_PSEUDO_REGISTER)
      target = gen_reg_rtx (Pmode);
  
--- 1391,1398 ----
      probe_stack_range (STACK_CHECK_MAX_FRAME_SIZE + STACK_CHECK_PROTECT, size);
  
!   /* Don't use a TARGET that isn't a pseudo or is the wrong mode.  */
    if (target == 0 || GET_CODE (target) != REG
!       || REGNO (target) < FIRST_PSEUDO_REGISTER
!       || GET_MODE (target) != Pmode)
      target = gen_reg_rtx (Pmode);
  
*************** allocate_dynamic_stack_space (size, targ
*** 1423,1427 ****
  	mode = Pmode;
  
-       size = convert_modes (mode, ptr_mode, size, 1);
        pred = insn_data[(int) CODE_FOR_allocate_stack].operand[1].predicate;
        if (pred && ! ((*pred) (size, mode)))
--- 1419,1422 ----
*************** allocate_dynamic_stack_space (size, targ
*** 1436,1440 ****
        emit_move_insn (target, virtual_stack_dynamic_rtx);
  #endif
-       size = convert_modes (Pmode, ptr_mode, size, 1);
  
        /* Check stack bounds if necessary.  */
--- 1431,1434 ----

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