From patchwork Thu Dec 15 10:56:41 2016 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: 88130 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp721183qgi; Thu, 15 Dec 2016 02:57:08 -0800 (PST) X-Received: by 10.99.101.65 with SMTP id z62mr1181740pgb.74.1481799428289; Thu, 15 Dec 2016 02:57:08 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l3si1901308pld.312.2016.12.15.02.57.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Dec 2016 02:57:08 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444489-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-444489-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444489-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=aD/zgRc7vDT8ON0Ez416UhQt8DuIYhDC/lJBnwFpvVxWKg+KG0 b6AJfjEg1R0uECFvn6Di9duxiEMoFWNG5CSKCj3JXomqaSnRD0L6HNXKaAJhUuUO Sj7nsSb+ZJmENbk9tjKAb8vAK2EYI7rfesmNWeHVBvNIEYAF5W957JfDM= 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=ZNDdaAv6wF3kY4+j09r13Zronbs=; b=JKDHIX3kDsMQh9F+54P2 dn9BlO3DcdmFvXcXHl2mGZhgcp+sTS5WhBzZuzd8MKe8OxRCSpf/WnkFc2jJIduv /yCPl1KBIwaj9eSzTo49Z+Cf5dgERuj5/TKQ0dnHtE/lK6D96W4x2yshrz57APHI Tx6jnp3heRNTOcPZw+HDPeQ= Received: (qmail 77078 invoked by alias); 15 Dec 2016 10:56:55 -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 77067 invoked by uid 89); 15 Dec 2016 10:56:54 -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= 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; Thu, 15 Dec 2016 10:56:44 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0151DADDA; Thu, 15 Dec 2016 10:56:41 +0000 (UTC) To: GCC Patches Cc: Richard Biener From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Fix optimized out volatile MEM_REF (PR, tree-optimization/78810) Message-ID: <69d5f3d0-9708-9b34-53a0-4e5853c6baa2@suse.cz> Date: Thu, 15 Dec 2016 11:56:41 +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 The patch adds TREE_THIS_VOLATILE check that was removed in r239778. Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin >From dc8ec6815fa51b352fe5f1a02d3510022053e0ad Mon Sep 17 00:00:00 2001 From: marxin Date: Wed, 14 Dec 2016 16:07:56 +0100 Subject: [PATCH] Fix optimized out volatile MEM_REF (PR tree-optimization/78810) gcc/testsuite/ChangeLog: 2016-12-14 Martin Liska PR tree-optimization/78810 * g++.dg/tree-ssa/pr78810.C: New test. gcc/ChangeLog: 2016-12-14 Martin Liska PR tree-optimization/78810 * tree-ssa.c (non_rewritable_mem_ref_base): Add TREE_THIS_VOLATILE check removed in r239778. --- gcc/testsuite/g++.dg/tree-ssa/pr78810.C | 26 ++++++++++++++++++++++++++ gcc/tree-ssa.c | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr78810.C diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr78810.C b/gcc/testsuite/g++.dg/tree-ssa/pr78810.C new file mode 100644 index 00000000000..1cda30c5bd8 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr78810.C @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +class NODE; +typedef unsigned long VALUE; + +struct parser_params +{ +}; + +struct parser_params *get_parser(); +NODE *yycompile(parser_params *parser, VALUE a, VALUE b); + +NODE* +rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start) +{ + struct parser_params *parser; + parser = get_parser(); + + NODE *node = yycompile(parser, fname, start); + (*({volatile VALUE *rb_gc_guarded_ptr = (&(vparser)); rb_gc_guarded_ptr;})); + + return node; +} + +/* { dg-final { scan-tree-dump "MEM\\\[\\\(volatile\\\ VALUE\\\ \\\*\\\)" "optimized" } } */ diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 62eea8bb8a4..b92513fcf23 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1385,7 +1385,8 @@ non_rewritable_mem_ref_base (tree ref) if (! DECL_P (decl)) return NULL_TREE; if (! is_gimple_reg_type (TREE_TYPE (base)) - || VOID_TYPE_P (TREE_TYPE (base))) + || VOID_TYPE_P (TREE_TYPE (base)) + || TREE_THIS_VOLATILE (decl) != TREE_THIS_VOLATILE (base)) return decl; if ((TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE || TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE) -- 2.11.0