From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105295 invoked by alias); 30 Nov 2015 23:05:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 104987 invoked by uid 89); 30 Nov 2015 23:05:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 30 Nov 2015 23:05:43 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id AB63A5439D3; Tue, 1 Dec 2015 00:05:39 +0100 (CET) Date: Mon, 30 Nov 2015 23:12:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: -fstrict-aliasing fixes 1/5: propagate -fno-strict-aliasing in the inliner Message-ID: <20151130230539.GB30608@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-11/txt/msg03533.txt.bz2 Hi, this is first patch in the broken up series. It adds the logic into ipa-inline-transform to drop the flag when inlining. I do it always until we find a way to make early optimizations safe WRT this transform. The testcase triggers with GCC 5.0/4.9 too, older compilers passes if -fstrict-aliasing is used at linktime and fails otherwise. Bootstrapped/regtested x86_64-linux, will commit it after re-testing on Firefox. Honza * ipa-inline-transform.c (inline_call): Drop -fstrict-aliasing when inlining -fno-strict-aliasing into -fstrict-aliasing body. * gcc.dg/lto/alias-1_0.c: New testcase. * gcc.dg/lto/alias-1_1.c: New testcase. Index: ipa-inline-transform.c =================================================================== --- ipa-inline-transform.c (revision 231081) +++ ipa-inline-transform.c (working copy) @@ -322,6 +322,21 @@ inline_call (struct cgraph_edge *e, bool if (DECL_FUNCTION_PERSONALITY (callee->decl)) DECL_FUNCTION_PERSONALITY (to->decl) = DECL_FUNCTION_PERSONALITY (callee->decl); + if (!opt_for_fn (callee->decl, flag_strict_aliasing) + && opt_for_fn (to->decl, flag_strict_aliasing)) + { + struct gcc_options opts = global_options; + + cl_optimization_restore (&opts, + TREE_OPTIMIZATION (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl))); + opts.x_flag_strict_aliasing = false; + if (dump_file) + fprintf (dump_file, "Dropping flag_strict_aliasing on %s:%i\n", + to->name (), to->order); + build_optimization_node (&opts); + DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl) + = build_optimization_node (&opts); + } /* If aliases are involved, redirect edge to the actual destination and possibly remove the aliases. */ Index: testsuite/gcc.dg/lto/alias-1_0.c =================================================================== --- testsuite/gcc.dg/lto/alias-1_0.c (revision 0) +++ testsuite/gcc.dg/lto/alias-1_0.c (revision 0) @@ -0,0 +1,23 @@ +/* { dg-lto-do run } */ +/* { dg-lto-options { { -O2 -flto } } } */ +int val; + +__attribute__ ((used)) +int *ptr = &val; +__attribute__ ((used)) +float *ptr2 = (void *)&val; + +extern void typefun(float val); + +void link_error (void); + +int +main() +{ + *ptr=1; + typefun (0); + if (*ptr) + __builtin_abort (); + return 0; +} + Index: testsuite/gcc.dg/lto/alias-1_1.c =================================================================== --- testsuite/gcc.dg/lto/alias-1_1.c (revision 0) +++ testsuite/gcc.dg/lto/alias-1_1.c (revision 0) @@ -0,0 +1,7 @@ +/* { dg-options "-fno-strict-aliasing" } */ +extern float *ptr2; +void +typefun (float val) +{ + *ptr2=val; +}