From patchwork Tue Jan 10 15:28:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 90721 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1065825obz; Tue, 10 Jan 2017 07:29:26 -0800 (PST) X-Received: by 10.99.226.3 with SMTP id q3mr4730624pgh.37.1484062166273; Tue, 10 Jan 2017 07:29:26 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 127si2472138pgi.128.2017.01.10.07.29.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 07:29:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445779-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445779-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445779-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=OrZCz+xjsZulW1VHw92zanejsiaI3hSMIsOlNEGjwEv22/1dTj ZAINvHu0xorEBPnfEJUsIGjzuYOpU7Mkk9551byQgalHlxsjD7FlZz1M7fHuuL6m ONiJ5RceUhBC3m6TxsFPAlnRSvY7LmVgz2wMMKy97DN05UlQLoofoE5Fg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=61D2V5/O9E5B32PfxP8gisBC+eU=; b=kMmKWB9ghmne75I4tAhR 3IGN+wyBUknLjPMJrqIIgCE/2kcEbIKck9azaW94ZYS5Ffl+0XrT8GJAcdlMZ4MD w/Q461/owh7Ey6fkNgS1wyFARj1rwYQxkZoyxTp/wcGek1GHf+tH9Vz/qO6Ps+8M UOM+3PtSaVOVPGfsVgsIU4k= Received: (qmail 101153 invoked by alias); 10 Jan 2017 15:29:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 101121 invoked by uid 89); 10 Jan 2017 15:29:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=H*M:4f36 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jan 2017 15:29:02 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 76CC0AB1D; Tue, 10 Jan 2017 15:28:59 +0000 (UTC) To: GCC Patches Cc: Jan Hubicka From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Reload global options when strict aliasing is dropped (PR ipa/79043). Message-ID: Date: Tue, 10 Jan 2017 16:28:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-IsSubscribed: yes As mentioned in the PR, we currently do not properly reload global optimization options when we drop strict-aliasing flag on a function that equals to cfun. Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin >From 53108a01c5fcb6fcfca15b389e76217b724915c3 Mon Sep 17 00:00:00 2001 From: marxin Date: Tue, 10 Jan 2017 14:43:04 +0100 Subject: [PATCH] Reload global options when strict aliasing is dropped (PR ipa/79043). gcc/ChangeLog: 2017-01-10 Martin Liska PR ipa/79043 * function.c (set_cfun): Add new argument force. * function.h (set_cfun): Likewise. * ipa-inline-transform.c (inline_call): Use the function when strict alising from is dropped for function we inline to. gcc/testsuite/ChangeLog: 2017-01-10 Martin Liska PR ipa/79043 * gcc.c-torture/execute/pr79043.c: New test. --- gcc/function.c | 4 ++-- gcc/function.h | 2 +- gcc/ipa-inline-transform.c | 8 ++++++++ gcc/testsuite/gcc.c-torture/execute/pr79043.c | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr79043.c diff --git a/gcc/function.c b/gcc/function.c index 7fde96adbe3..f625489205b 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4811,9 +4811,9 @@ invoke_set_current_function_hook (tree fndecl) /* cfun should never be set directly; use this function. */ void -set_cfun (struct function *new_cfun) +set_cfun (struct function *new_cfun, bool force) { - if (cfun != new_cfun) + if (cfun != new_cfun || force) { cfun = new_cfun; invoke_set_current_function_hook (new_cfun ? new_cfun->decl : NULL_TREE); diff --git a/gcc/function.h b/gcc/function.h index fb3cbbc3346..fb8f57ae385 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -613,7 +613,7 @@ extern tree block_chainon (tree, tree); extern void number_blocks (tree); /* cfun shouldn't be set directly; use one of these functions instead. */ -extern void set_cfun (struct function *new_cfun); +extern void set_cfun (struct function *new_cfun, bool force = false); extern void push_cfun (struct function *new_cfun); extern void pop_cfun (void); diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c index 7725fadd6d8..a8e73cd6967 100644 --- a/gcc/ipa-inline-transform.c +++ b/gcc/ipa-inline-transform.c @@ -340,6 +340,8 @@ inline_call (struct cgraph_edge *e, bool update_original, if (DECL_FUNCTION_PERSONALITY (callee->decl)) DECL_FUNCTION_PERSONALITY (to->decl) = DECL_FUNCTION_PERSONALITY (callee->decl); + + bool reload_optimization_node = false; if (!opt_for_fn (callee->decl, flag_strict_aliasing) && opt_for_fn (to->decl, flag_strict_aliasing)) { @@ -352,6 +354,7 @@ inline_call (struct cgraph_edge *e, bool update_original, to->name (), to->order); DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl) = build_optimization_node (&opts); + reload_optimization_node = true; } inline_summary *caller_info = inline_summaries->get (to); @@ -412,9 +415,14 @@ inline_call (struct cgraph_edge *e, bool update_original, callee->name (), callee->order, to->name (), to->order); DECL_FUNCTION_SPECIFIC_OPTIMIZATION (to->decl) = build_optimization_node (&opts); + reload_optimization_node = true; } } + /* Reload global optimization flags. */ + if (reload_optimization_node && DECL_STRUCT_FUNCTION (to->decl) == cfun) + set_cfun (cfun, true); + /* If aliases are involved, redirect edge to the actual destination and possibly remove the aliases. */ if (e->callee != callee) diff --git a/gcc/testsuite/gcc.c-torture/execute/pr79043.c b/gcc/testsuite/gcc.c-torture/execute/pr79043.c new file mode 100644 index 00000000000..b7fcc8260dc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr79043.c @@ -0,0 +1,21 @@ +/* PR ipa/78791 */ + +int val; + +int *ptr = &val; +float *ptr2 = &val; + +static +__attribute__((always_inline, optimize ("-fno-strict-aliasing"))) +typepun () +{ + *ptr2=0; +} + +main() +{ + *ptr=1; + typepun (); + if (*ptr) + __builtin_abort (); +} -- 2.11.0