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]

Re: [patch] Fix type merging deficiency during WPA


On Tue, Jul 5, 2016 at 12:57 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> the deficiency comes from a chicken-and-egg problem during WPA: DECL nodes
> merging depends on type merging, but type merging also depends on DECL nodes
> merging for dynamic types declared at file scope, which easily occurs in Ada.

So this is sth like (invalid C)

t.h
---
int n;
struct X { int x[n]; };

t1.c
--
#include "t.h"
struct X x;
t2.c
--
#include "t.h"
struct X x;

?

It's not obvious from the fix (which I think is in the wrong place)
which operand_equal/hash
call during WPA this is supposed to fix.  So can you please provide a
little more context here?

Thanks,
Richard.

> For the attached trivial testcase, the compiler issues:
>
> /home/eric/svn/gcc/gcc/testsuite/gnat.dg/lto18_pkg1.ads:12:13: warning: type
> of 'lto18_pkg1__proc' does not match original declaration [-Wlto-type-
> mismatch]
> /home/eric/svn/gcc/gcc/testsuite/gnat.dg/lto18_pkg1.adb:3:3: note:
> 'lto18_pkg1__proc' was previously declared here
> /home/eric/svn/gcc/gcc/testsuite/gnat.dg/lto18_pkg1.adb:3:3: note: code may be
> misoptimized unless -fno-strict-aliasing is used
>
> The proposed fix is to add a special processing in operand_equal_p/add_expr
> for DECL nodes during WPA.  It contains a tweak for lto_fixup_prevailing_decls
> for the sake of completeness, but it is not necessary for fixing the problem.
>
> Tested on x86_64-suse-linux, OK for the mainline?
>
>
> 2016-07-05  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * cgraph.h (symbol_table::decl_assembler_name_hash): Make public.
>         * fold-const.c (operand_equal_p) <tcc_declaration>: Add special
>         processing during WPA.
>         * tree.c (add_expr) <tcc_declaration>: Likewise.
> lto/
>         * lto.c (walk_simple_constant_arithmetic): New function.
>         (LTO_SET_PREVAIL): Use it to fix up DECL nodes in simple expressions.
>
>
> 2016-07-05  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gnat.dg/lto18.adb: New test.
>         * gnat.dg/lto18_pkg1.ad[sb]: New helper.
>         * gnat.dg/lto18_pkg2.ad[sb]: Likewise.
>
> --
> Eric Botcazou


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