This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
IA64 Patch for pointer extension
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 26 Apr 2005 10:57:56 -0700 (PDT)
- Subject: IA64 Patch for pointer extension
I ran across the following bug while working on libffi.
expand_expr_real_1 was extending a 32 bit pointer into a 64 bit pointer
using integer style extension instead of the IA64 pointer extension
instruction (addp4). The included test case would core dump on IA64
HP-UX before but passes with this patch.
There were no regressions on IA64 HP-UX or Linux. Richard Kenner had
suggested putting a gcc_assert in convert_memory_address as part of
this, I am sending that as a seperate patch.
Steve Ellcey
sje@cup.hp.com
ChangeLog:
2005-04-26 Steve Ellcey <sje@cup.hp.com>
* expr.c (expand_expr_real_1): Handle expansion of pointers.
testsuite/ChangeLog:
2005-04-26 Steve Ellcey <sje@cup.hp.com>
* gcc.dg/ia64-ptr-1.c: New.
*** gcc.orig/gcc/expr.c Tue Apr 26 10:13:49 2005
--- gcc/gcc/expr.c Tue Apr 26 10:13:40 2005
*************** expand_expr_real_1 (tree exp, rtx target
*** 7409,7414 ****
--- 7409,7417 ----
if (GET_MODE (op0) == mode)
;
+ else if (POINTER_TYPE_P (TREE_TYPE (exp)))
+ op0 = convert_memory_address (mode, op0);
+
/* If OP0 is a constant, just convert it into the proper mode. */
else if (CONSTANT_P (op0))
{
*** gcc.orig/gcc/testsuite/gcc.dg/ia64-ptr-1.c Tue Apr 26 10:15:52 2005
--- gcc/gcc/testsuite/gcc.dg/ia64-ptr-1.c Tue Apr 26 10:16:08 2005
***************
*** 0 ****
--- 1,24 ----
+ /* { dg-do run { target ia64-*-hpux* } } */
+ /* { dg-options "-O0" } */
+
+ extern void abort (void);
+
+ typedef int *PTR64 __attribute__((mode(DI)));
+
+ void bar(PTR64 x)
+ {
+ *x = 13;
+ }
+
+ void foo(int * x)
+ {
+ bar(x);
+ }
+
+ main()
+ {
+ int i;
+ foo(&i);
+ if (i != 13) abort();
+ return 0;
+ }