re PR target/11184 ([ia64 hpux] ICE on __builtin_apply building libobjc)

PR target/11184
	* builtins.c (expand_builtin_apply): Use convert_memory_address
	before returning the value.

	* alias.c (find_base_value): Simplify use of
	convert_memory_address.
	(find_base_term): Likewise.
	* builtins.c (expand_builtin_stejmp_setup): Likewise.
	(expand_builtin_longjmp): Likewise.
	(expand_builtin_prefetch): Likewise.
	(get_memory_rtx): Likewise.
	(expand_builtin_return): Likewise.
	(expand_builtin_memcpy): Likewise.
	(expand_builtin_strncpy): Likewise.
	(expand_builtin_memset): Likewise.
	(expand_builtin_va_arg): Likewise.
	(expand_builtin_va_copy): Likewise.
	(expand_builtin_alloca): Likewise.
	* calls.c (expand_call): Likewise.
	* except.c (expand_builtin_extract_return_addr): Likewise.
	(expand_builtin_eh_return): Likewise.
	* explow.c (convert_memory_address): Define even when
	POINTER_EXTEND_UNSIGNED is not defined.  Do nothing if the address
	is already in the right mode.
	* explow.c (memory_address): Simplify use of convert_memory_address.
	(probe_stack_range): Likewise.
	* expmed.c (make_tree): Likewise.
	* expr.c (emit_block_move_in_libcall): Likewise.
	(expand_assignment): Likewise.
	(expand_expr): Likewise.
	* function.c (assign_parms): Likewise.
	(expand_function_end): Likewise.
	* integrate.c (copy_rtx_and_substitute): Likewise.
	* stmt.c (expand_computed_goto): Likewise.

	PR target/11184
	* gcc.dg/builtin-apply1.c: New test.

From-SVN: r71539
This commit is contained in:
Mark Mitchell 2003-09-18 20:43:13 +00:00 committed by Mark Mitchell
parent bdf1f1c16d
commit 5ae6cd0d1b
13 changed files with 102 additions and 146 deletions

View File

@ -1,3 +1,40 @@
2003-09-18 Mark Mitchell <mark@codesourcery.com>
PR target/11184
* builtins.c (expand_builtin_apply): Use convert_memory_address
before returning the value.
* alias.c (find_base_value): Simplify use of
convert_memory_address.
(find_base_term): Likewise.
* builtins.c (expand_builtin_stejmp_setup): Likewise.
(expand_builtin_longjmp): Likewise.
(expand_builtin_prefetch): Likewise.
(get_memory_rtx): Likewise.
(expand_builtin_return): Likewise.
(expand_builtin_memcpy): Likewise.
(expand_builtin_strncpy): Likewise.
(expand_builtin_memset): Likewise.
(expand_builtin_va_arg): Likewise.
(expand_builtin_va_copy): Likewise.
(expand_builtin_alloca): Likewise.
* calls.c (expand_call): Likewise.
* except.c (expand_builtin_extract_return_addr): Likewise.
(expand_builtin_eh_return): Likewise.
* explow.c (convert_memory_address): Define even when
POINTER_EXTEND_UNSIGNED is not defined. Do nothing if the address
is already in the right mode.
* explow.c (memory_address): Simplify use of convert_memory_address.
(probe_stack_range): Likewise.
* expmed.c (make_tree): Likewise.
* expr.c (emit_block_move_in_libcall): Likewise.
(expand_assignment): Likewise.
(expand_expr): Likewise.
* function.c (assign_parms): Likewise.
(expand_function_end): Likewise.
* integrate.c (copy_rtx_and_substitute): Likewise.
* stmt.c (expand_computed_goto): Likewise.
2003-09-18 Roger Sayle <roger@eyesopen.com>
* simplify-rtx.c (simplify_unary_operation): Only transform

View File

@ -888,10 +888,8 @@ find_base_value (rtx src)
{
rtx temp = find_base_value (XEXP (src, 0));
#ifdef POINTERS_EXTEND_UNSIGNED
if (temp != 0 && CONSTANT_P (temp) && GET_MODE (temp) != Pmode)
if (temp != 0 && CONSTANT_P (temp))
temp = convert_memory_address (Pmode, temp);
#endif
return temp;
}
@ -1307,10 +1305,8 @@ find_base_term (rtx x)
{
rtx temp = find_base_term (XEXP (x, 0));
#ifdef POINTERS_EXTEND_UNSIGNED
if (temp != 0 && CONSTANT_P (temp) && GET_MODE (temp) != Pmode)
if (temp != 0 && CONSTANT_P (temp))
temp = convert_memory_address (Pmode, temp);
#endif
return temp;
}

View File

@ -477,10 +477,7 @@ expand_builtin_setjmp_setup (rtx buf_addr, rtx receiver_label)
if (setjmp_alias_set == -1)
setjmp_alias_set = new_alias_set ();
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (buf_addr) != Pmode)
buf_addr = convert_memory_address (Pmode, buf_addr);
#endif
buf_addr = convert_memory_address (Pmode, buf_addr);
buf_addr = force_reg (Pmode, force_operand (buf_addr, NULL_RTX));
@ -661,10 +658,7 @@ expand_builtin_longjmp (rtx buf_addr, rtx value)
if (setjmp_alias_set == -1)
setjmp_alias_set = new_alias_set ();
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (buf_addr) != Pmode)
buf_addr = convert_memory_address (Pmode, buf_addr);
#endif
buf_addr = convert_memory_address (Pmode, buf_addr);
buf_addr = force_reg (Pmode, buf_addr);
@ -807,10 +801,7 @@ expand_builtin_prefetch (tree arglist)
insn_data[(int) CODE_FOR_prefetch].operand[0].mode))
|| (GET_MODE (op0) != Pmode))
{
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (op0) != Pmode)
op0 = convert_memory_address (Pmode, op0);
#endif
op0 = convert_memory_address (Pmode, op0);
op0 = force_reg (Pmode, op0);
}
emit_insn (gen_prefetch (op0, op1, op2));
@ -833,10 +824,7 @@ get_memory_rtx (tree exp)
rtx addr = expand_expr (exp, NULL_RTX, ptr_mode, EXPAND_SUM);
rtx mem;
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (addr) != Pmode)
addr = convert_memory_address (Pmode, addr);
#endif
addr = convert_memory_address (Pmode, addr);
mem = gen_rtx_MEM (BLKmode, memory_address (BLKmode, addr));
@ -1193,10 +1181,7 @@ expand_builtin_apply (rtx function, rtx arguments, rtx argsize)
rtx call_fusage = 0;
rtx struct_value = targetm.calls.struct_value_rtx (cfun ? TREE_TYPE (cfun->decl) : 0, 0);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (arguments) != Pmode)
arguments = convert_memory_address (Pmode, arguments);
#endif
arguments = convert_memory_address (Pmode, arguments);
/* Create a block where the return registers can be saved. */
result = assign_stack_local (BLKmode, apply_result_size (), -1);
@ -1334,7 +1319,8 @@ expand_builtin_apply (rtx function, rtx arguments, rtx argsize)
OK_DEFER_POP;
/* Return the address of the result block. */
return copy_addr_to_reg (XEXP (result, 0));
result = copy_addr_to_reg (XEXP (result, 0));
return convert_memory_address (ptr_mode, result);
}
/* Perform an untyped return. */
@ -1347,10 +1333,7 @@ expand_builtin_return (rtx result)
rtx reg;
rtx call_fusage = 0;
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (result) != Pmode)
result = convert_memory_address (Pmode, result);
#endif
result = convert_memory_address (Pmode, result);
apply_result_size ();
result = gen_rtx_MEM (BLKmode, result);
@ -2521,10 +2504,7 @@ expand_builtin_memcpy (tree arglist, rtx target, enum machine_mode mode)
builtin_memcpy_read_str,
(void *) src_str, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_mem) != ptr_mode)
dest_mem = convert_memory_address (ptr_mode, dest_mem);
#endif
dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
@ -2538,10 +2518,7 @@ expand_builtin_memcpy (tree arglist, rtx target, enum machine_mode mode)
if (dest_addr == 0)
{
dest_addr = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_addr) != ptr_mode)
dest_addr = convert_memory_address (ptr_mode, dest_addr);
#endif
dest_addr = convert_memory_address (ptr_mode, dest_addr);
}
return dest_addr;
}
@ -2620,10 +2597,7 @@ expand_builtin_mempcpy (tree arglist, rtx target, enum machine_mode mode,
builtin_memcpy_read_str,
(void *) src_str, dest_align, endp);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_mem) != ptr_mode)
dest_mem = convert_memory_address (ptr_mode, dest_mem);
#endif
dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
@ -2638,10 +2612,7 @@ expand_builtin_mempcpy (tree arglist, rtx target, enum machine_mode mode,
dest_mem = move_by_pieces (dest_mem, src_mem, INTVAL (len_rtx),
MIN (dest_align, src_align), endp);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_mem) != ptr_mode)
dest_mem = convert_memory_address (ptr_mode, dest_mem);
#endif
dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
@ -2877,10 +2848,7 @@ expand_builtin_strncpy (tree arglist, rtx target, enum machine_mode mode)
builtin_strncpy_read_str,
(void *) p, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_mem) != ptr_mode)
dest_mem = convert_memory_address (ptr_mode, dest_mem);
#endif
dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
@ -2998,10 +2966,7 @@ expand_builtin_memset (tree arglist, rtx target, enum machine_mode mode)
builtin_memset_gen_str,
val_rtx, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_mem) != ptr_mode)
dest_mem = convert_memory_address (ptr_mode, dest_mem);
#endif
dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
@ -3022,10 +2987,7 @@ expand_builtin_memset (tree arglist, rtx target, enum machine_mode mode)
builtin_memset_read_str,
&c, dest_align, 0);
dest_mem = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_mem) != ptr_mode)
dest_mem = convert_memory_address (ptr_mode, dest_mem);
#endif
dest_mem = convert_memory_address (ptr_mode, dest_mem);
return dest_mem;
}
@ -3038,10 +3000,7 @@ expand_builtin_memset (tree arglist, rtx target, enum machine_mode mode)
if (dest_addr == 0)
{
dest_addr = force_operand (XEXP (dest_mem, 0), NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dest_addr) != ptr_mode)
dest_addr = convert_memory_address (ptr_mode, dest_addr);
#endif
dest_addr = convert_memory_address (ptr_mode, dest_addr);
}
return dest_addr;
@ -4039,10 +3998,7 @@ expand_builtin_va_arg (tree valist, tree type)
#endif
}
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (addr) != Pmode)
addr = convert_memory_address (Pmode, addr);
#endif
addr = convert_memory_address (Pmode, addr);
result = gen_rtx_MEM (TYPE_MODE (type), addr);
set_mem_alias_set (result, get_varargs_alias_set ());
@ -4101,13 +4057,8 @@ expand_builtin_va_copy (tree arglist)
size = expand_expr (TYPE_SIZE_UNIT (va_list_type_node), NULL_RTX,
VOIDmode, EXPAND_NORMAL);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (dstb) != Pmode)
dstb = convert_memory_address (Pmode, dstb);
if (GET_MODE (srcb) != Pmode)
srcb = convert_memory_address (Pmode, srcb);
#endif
dstb = convert_memory_address (Pmode, dstb);
srcb = convert_memory_address (Pmode, srcb);
/* "Dereference" to BLKmode memories. */
dstb = gen_rtx_MEM (BLKmode, dstb);
@ -4190,11 +4141,7 @@ expand_builtin_alloca (tree arglist, rtx target)
/* Allocate the desired space. */
result = allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (result) != ptr_mode)
result = convert_memory_address (ptr_mode, result);
#endif
result = convert_memory_address (ptr_mode, result);
return result;
}

View File

@ -3026,11 +3026,8 @@ expand_call (tree exp, rtx target, int ignore)
structure value. */
if (pass != 0 && structure_value_addr && ! structure_value_addr_parm)
{
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (structure_value_addr) != Pmode)
structure_value_addr = convert_memory_address
(Pmode, structure_value_addr);
#endif
structure_value_addr
= convert_memory_address (Pmode, structure_value_addr);
emit_move_insn (struct_value,
force_reg (Pmode,
force_operand (structure_value_addr,

View File

@ -2974,10 +2974,7 @@ expand_builtin_frob_return_addr (tree addr_tree)
{
rtx addr = expand_expr (addr_tree, NULL_RTX, ptr_mode, 0);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (addr) != Pmode)
addr = convert_memory_address (Pmode, addr);
#endif
addr = convert_memory_address (Pmode, addr);
#ifdef RETURN_ADDR_OFFSET
addr = force_reg (Pmode, addr);
@ -2998,10 +2995,7 @@ expand_builtin_eh_return (tree stackadj_tree ATTRIBUTE_UNUSED,
#ifdef EH_RETURN_STACKADJ_RTX
tmp = expand_expr (stackadj_tree, cfun->eh->ehr_stackadj, VOIDmode, 0);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (tmp) != Pmode)
tmp = convert_memory_address (Pmode, tmp);
#endif
tmp = convert_memory_address (Pmode, tmp);
if (!cfun->eh->ehr_stackadj)
cfun->eh->ehr_stackadj = copy_to_reg (tmp);
else if (tmp != cfun->eh->ehr_stackadj)
@ -3009,10 +3003,7 @@ expand_builtin_eh_return (tree stackadj_tree ATTRIBUTE_UNUSED,
#endif
tmp = expand_expr (handler_tree, cfun->eh->ehr_handler, VOIDmode, 0);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (tmp) != Pmode)
tmp = convert_memory_address (Pmode, tmp);
#endif
tmp = convert_memory_address (Pmode, tmp);
if (!cfun->eh->ehr_handler)
cfun->eh->ehr_handler = copy_to_reg (tmp);
else if (tmp != cfun->eh->ehr_handler)

View File

@ -303,8 +303,6 @@ break_out_memory_refs (rtx x)
return x;
}
#ifdef POINTERS_EXTEND_UNSIGNED
/* Given X, a memory address in ptr_mode, convert it to an address
in Pmode, or vice versa (TO_MODE says which way). We take advantage of
the fact that pointers are not allowed to overflow by commuting arithmetic
@ -312,12 +310,22 @@ break_out_memory_refs (rtx x)
used. */
rtx
convert_memory_address (enum machine_mode to_mode, rtx x)
convert_memory_address (enum machine_mode to_mode ATTRIBUTE_UNUSED,
rtx x)
{
enum machine_mode from_mode = to_mode == ptr_mode ? Pmode : ptr_mode;
#ifndef POINTERS_EXTEND_UNSIGNED
return x;
#else /* defined(POINTERS_EXTEND_UNSIGNED) */
enum machine_mode from_mode;
rtx temp;
enum rtx_code code;
/* If X already has the right mode, just return it. */
if (GET_MODE (x) == to_mode)
return x;
from_mode = to_mode == ptr_mode ? Pmode : ptr_mode;
/* Here we handle some special cases. If none of them apply, fall through
to the default case. */
switch (GET_CODE (x))
@ -381,8 +389,8 @@ convert_memory_address (enum machine_mode to_mode, rtx x)
return convert_modes (to_mode, from_mode,
x, POINTERS_EXTEND_UNSIGNED);
#endif /* defined(POINTERS_EXTEND_UNSIGNED) */
}
#endif
/* Given a memory address or facsimile X, construct a new address,
currently equivalent, that is stable: future stores won't change it.
@ -434,10 +442,7 @@ memory_address (enum machine_mode mode, rtx x)
if (GET_CODE (x) == ADDRESSOF)
return x;
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (x) != Pmode)
x = convert_memory_address (Pmode, x);
#endif
x = convert_memory_address (Pmode, x);
/* By passing constant addresses thru registers
we get a chance to cse them. */
@ -1419,11 +1424,7 @@ probe_stack_range (HOST_WIDE_INT first, rtx size)
stack_pointer_rtx,
plus_constant (size, first)));
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (addr) != ptr_mode)
addr = convert_memory_address (ptr_mode, addr);
#endif
addr = convert_memory_address (ptr_mode, addr);
emit_library_call (stack_check_libfunc, LCT_NORMAL, VOIDmode, 1, addr,
ptr_mode);
}

View File

@ -4115,12 +4115,10 @@ make_tree (tree type, rtx x)
t = make_node (RTL_EXPR);
TREE_TYPE (t) = type;
#ifdef POINTERS_EXTEND_UNSIGNED
/* If TYPE is a POINTER_TYPE, X might be Pmode with TYPE_MODE being
ptr_mode. So convert. */
if (POINTER_TYPE_P (type) && GET_MODE (x) != TYPE_MODE (type))
if (POINTER_TYPE_P (type))
x = convert_memory_address (TYPE_MODE (type), x);
#endif
RTL_EXPR_RTL (t) = x;
/* There are no insns to be output

View File

@ -1957,10 +1957,8 @@ emit_block_move_via_libcall (rtx dst, rtx src, rtx size)
dst_addr = copy_to_mode_reg (Pmode, XEXP (dst, 0));
src_addr = copy_to_mode_reg (Pmode, XEXP (src, 0));
#ifdef POINTERS_EXTEND_UNSIGNED
dst_addr = convert_memory_address (ptr_mode, dst_addr);
src_addr = convert_memory_address (ptr_mode, src_addr);
#endif
dst_tree = make_tree (ptr_type_node, dst_addr);
src_tree = make_tree (ptr_type_node, src_addr);
@ -4299,11 +4297,8 @@ expand_assignment (tree to, tree from, int want_value)
emit_block_move (to_rtx, value, expr_size (from), BLOCK_OP_NORMAL);
else
{
#ifdef POINTERS_EXTEND_UNSIGNED
if (POINTER_TYPE_P (TREE_TYPE (to))
&& GET_MODE (to_rtx) != GET_MODE (value))
if (POINTER_TYPE_P (TREE_TYPE (to)))
value = convert_memory_address (GET_MODE (to_rtx), value);
#endif
emit_move_insn (to_rtx, value);
}
preserve_temp_slots (to_rtx);
@ -9228,11 +9223,8 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
{
op0 = XEXP (op0, 0);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
&& mode == ptr_mode)
if (GET_MODE (op0) == Pmode && mode == ptr_mode)
op0 = convert_memory_address (ptr_mode, op0);
#endif
return op0;
}
@ -9293,11 +9285,8 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
&& ! REG_USERVAR_P (op0))
mark_reg_pointer (op0, TYPE_ALIGN (TREE_TYPE (type)));
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (op0) == Pmode && GET_MODE (op0) != mode
&& mode == ptr_mode)
if (GET_MODE (op0) == Pmode && mode == ptr_mode)
op0 = convert_memory_address (ptr_mode, op0);
#endif
return op0;

View File

@ -5182,11 +5182,7 @@ assign_parms (tree fndecl)
rtx addr = DECL_RTL (function_result_decl);
rtx x;
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (addr) != Pmode)
addr = convert_memory_address (Pmode, addr);
#endif
addr = convert_memory_address (Pmode, addr);
x = gen_rtx_MEM (DECL_MODE (result), addr);
set_mem_attributes (x, result, 1);
SET_DECL_RTL (result, x);
@ -7069,12 +7065,9 @@ expand_function_end (void)
assignment and USE below when inlining this function. */
REG_FUNCTION_VALUE_P (outgoing) = 1;
#ifdef POINTERS_EXTEND_UNSIGNED
/* The address may be ptr_mode and OUTGOING may be Pmode. */
if (GET_MODE (outgoing) != GET_MODE (value_address))
value_address = convert_memory_address (GET_MODE (outgoing),
value_address);
#endif
value_address = convert_memory_address (GET_MODE (outgoing),
value_address);
emit_move_insn (outgoing, value_address);

View File

@ -2157,11 +2157,7 @@ copy_rtx_and_substitute (rtx orig, struct inline_remap *map, int for_lhs)
#endif
temp = XEXP (temp, 0);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (temp) != GET_MODE (orig))
temp = convert_memory_address (GET_MODE (orig), temp);
#endif
temp = convert_memory_address (GET_MODE (orig), temp);
return temp;
}
else if (GET_CODE (constant) == LABEL_REF)

View File

@ -520,10 +520,7 @@ expand_computed_goto (tree exp)
{
rtx x = expand_expr (exp, NULL_RTX, VOIDmode, 0);
#ifdef POINTERS_EXTEND_UNSIGNED
if (GET_MODE (x) != Pmode)
x = convert_memory_address (Pmode, x);
#endif
x = convert_memory_address (Pmode, x);
emit_queue ();

View File

@ -1,3 +1,8 @@
2003-09-18 Mark Mitchell <mark@codesourcery.com>
PR target/11184
* gcc.dg/builtin-apply1.c: New test.
2003-09-18 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9848

View File

@ -0,0 +1,9 @@
/* PR 11184 */
/* Origin: Dara Hazeghi <dhazeghi@yahoo.com> */
void *
objc_msg_sendv (char * arg_frame, void (*foo)())
{
return __builtin_apply ( foo, arg_frame, 4);
}