[named-addr-spaces-branch][Patch,committed] Fix C++ bug; Add common pointer target hook

Michael Meissner meissner@linux.vnet.ibm.com
Wed Dec 3 21:02:00 GMT 2008


On Tue, Dec 02, 2008 at 11:00:17AM +0100, Richard Guenther wrote:
> On Mon, Dec 1, 2008 at 6:21 PM, Michael Meissner
> <meissner@linux.vnet.ibm.com> wrote:
> > On Sun, Nov 30, 2008 at 11:02:25PM +0100, Richard Guenther wrote:
> >> I can see a pattern here.  Either this needs a function or, more likely, this
> >> is broken - why does TYPE_PRECISION not work here?
> >
> > I tried just using TYPE_PRECISION, and it causes C++ testsuite failures.
> 
> Can you investigate why?  The middle-end expects that to work in other
> places.

Ok, I tracked this down.  POINTER_TYPE and REFERENCE_TYPE nodes have the
correct TYPE_PRECISION.  OFFSET_TYPE on the other hand does not set
TYPE_PRECISION.

In the function fit_double_type (in fold-const.c), it originally checked for
the type being a pointer, or offset and using POINTER_SIZE instead of
TYPE_PRECISION.

The other 3 functions in tree.c (integer_pow2p, tree_log2, tree_floor_log2) do
not check for OFFSET_TYPE, so presumably they are only called with integer or
pointer types.

In the main source, the following files reference POINTER_SIZE:
c-common.c	create null_node, usage ok
convert.c	patches add support for varying pointer sizes
dwarf2asm.c	For exception handling with generic pointers
emit-rtl.c	create ptr_node, ok here, but ptr_node/size_node should be
		checked
except.c	For exception handling with generic pointers
fold-const.c	fit_double_type
stor-layout.c	creation of OFFSET_TYPE fields
targethooks.c	In default_builtin_vector_alignment_reachable
tree.c		integer_pow2p, tree_log2, tree_floor_log2
varasm.c	assemble_addr_to_section, default_assemble_integer,
		initializer_constant_valid_p -- I think I need to check these

Now, this patch to stor-layout.c will set the TYPE_PRECISION for OFFSET_TYPE
(I've only run the C++ tests at this point, not the full test suite):

Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c   (revision 142377)
+++ gcc/stor-layout.c   (working copy)
@@ -1681,6 +1681,7 @@ layout_type (tree type)
       /* A pointer might be MODE_PARTIAL_INT,
         but ptrdiff_t must be integral.  */
       TYPE_MODE (type) = mode_for_size (POINTER_SIZE, MODE_INT, 0);
+      TYPE_PRECISION (type) = POINTER_SIZE;
       break;

I think however for completeness, I need to check for OFFSET_TYPE's being
created with named addresses and set the size appropriately.

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com



More information about the Gcc-patches mailing list