This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Remove bogus PLUS_EXPR -> POINTER_PLUS_EXPR folding
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: java at gcc dot gnu dot org, tromey at redhat dot com, aph at redhat dot com
- Date: Fri, 16 Jan 2009 17:45:02 +0100 (CET)
- Subject: Re: [PATCH] Remove bogus PLUS_EXPR -> POINTER_PLUS_EXPR folding
- References: <alpine.LNX.2.00.0901161453350.24314@zhemvz.fhfr.qr>
On Fri, 16 Jan 2009, Richard Guenther wrote:
>
> This removes a bogus folding that causes miscompiles of libstdc++
> testcases with the ext_pointer class (PR38835) and non-field-sensitive
> PTA (field-sensitive PTA is too dumb). I probably anticipated the
> problem in PR36227 which should be fixed with that patch as well.
>
> Fold changes
>
> return <retval> = (const struct _Fwd_list_node_base *) ((long unsigned int) this + (long unsigned int) ((const struct _Relative_pointer_impl *) this)->_M_diff);
>
> to
>
> (const struct _Fwd_list_node_base *) this p+ (long unsigned int) ((const struct _Relative_pointer_impl *) this)->_M_diff
>
> which makes PTA correctly conclude that 'this' and the result of the
> POINTER_PLUS_EXPR point to the same object. Which they do not - the source
> used addition in (long unsigned int) to avoid this issue and the resulting
> pointer points somewhere else.
>
> Fixed by removing the folding. This also fixes -Wsystem-header warnings
> and miscompiles for the libstdc++ testsuite.
>
> Bootstrap and regtest on x86_64-unknown-linux-gnu ongoing.
Needs one extra hunk in the Java frontend. Bootstrapped and tested
on x86_64-unknown-linux-gnu, is that ok for trunk?
Also needs one C++ testcase XFAILed, the FE passes
(long int) &16B->y - 16 into fold and expects us to perform offsetof
magic. I will try to address both XFAILs later.
Thanks,
Richard.
2009-01-16 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38835
PR middle-end/36227
java/
* builtins.c (build_addr_sum): Use POINTER_PLUS_EXPR.
Index: gcc/java/builtins.c
===================================================================
*** gcc/java/builtins.c (revision 143429)
--- gcc/java/builtins.c (working copy)
*************** static tree
*** 265,273 ****
build_addr_sum (tree type, tree addr, tree offset)
{
tree ptr_type = build_pointer_type (type);
! return fold_build2 (PLUS_EXPR,
! ptr_type,
! fold_convert (ptr_type, addr), offset);
}
/* Make sure that this-arg is non-NULL. This is a security check. */
--- 265,274 ----
build_addr_sum (tree type, tree addr, tree offset)
{
tree ptr_type = build_pointer_type (type);
! return fold_build2 (POINTER_PLUS_EXPR,
! ptr_type,
! fold_convert (ptr_type, addr),
! fold_convert (sizetype, offset));
}
/* Make sure that this-arg is non-NULL. This is a security check. */