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] Don't optimize function addresses


The enclosed change fixes PR middle-end/35705.  The 32-bit PA-RISC
runtimes treat function pointers in a unique manner.  Many targets
have function pointers which point to function descriptors.  In the
PA case, a function pointer may point to a descriptor or directly
to code.  The plabel bit is used to distinguish these two cases.

Various code needs to be able to test this bit.  However in 4.3.0,
an optimization of function pointers was introduced based on the
alignment of the actual function code.  This is incorrect for targets
that use function descriptors, but it also made it impossible for C
code to test the plabel bit.  A similar situation may apply to
arm/thumb function pointers.

The enclosed change disables this optimization.

The patch has been tested on hppa-unknown-linux, hppa2.0w-hp-hpux11.11
and hppa64-hp-hpux11.11 with no observed regressions.

Ok for trunk and 4.3 branch?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2008-03-31  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR middle-end/35705
	* fold-const.c (get_pointer_modulus_and_residue): Return modulus 1 if
	the expression is a function address.

Index: fold-const.c
===================================================================
--- fold-const.c	(revision 133621)
+++ fold-const.c	(working copy)
@@ -9065,7 +9065,7 @@
 	    }
 	}
 
-      if (DECL_P (expr))
+      if (DECL_P (expr) && TREE_CODE (expr) != FUNCTION_DECL)
 	return DECL_ALIGN_UNIT (expr);
     }
   else if (code == POINTER_PLUS_EXPR)


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