From patchwork Thu Aug 28 13:34:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 383839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D7E61400E0 for ; Thu, 28 Aug 2014 23:38:02 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=WkhHCEi1CVe+OfoctkQmLK0Uq5rxeZxaUxArzdNnTVF9YlB1IkJJe iSh+ViffpHv5mL3lraAIaYmGgA2/Z2TfCN7cgGbHRKyE6Vsdp0zodkeSxcC1V7SW k/mIqtICC89IR8YfJmyXtqHzdqmuoXsB4a8FSTJOZ+EEn7eR1R+ibk= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=tPNJ5n3jXsf/oNQCGoMW7KzYiRk=; b=NoqpjbgthIY0gVade/1i wuIGbUUAtArVW1BvGi9tNp+ME2a8TBe9uU1OXSyP4Xcvbi5fhyXN0ln3EFPhF/bw K4tTL1YDtyE0WLXhNGvsaIQ/XnZWxFGaEy6eouMoAykxiTHfkmGWTr75JmT4aG20 wGyxRHxbqF9PM5Xb2qXPUCo= Received: (qmail 12264 invoked by alias); 28 Aug 2014 13:37:43 -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 12255 invoked by uid 89); 28 Aug 2014 13:37:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 28 Aug 2014 13:37:42 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 11758ACCC for ; Thu, 28 Aug 2014 13:37:39 +0000 (UTC) Date: Thu, 28 Aug 2014 15:34:17 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][match-and-simplify] Fix NON_LVALUE_EXPR leaking Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 This tries to prevent NON_LVALUE_EXPR from leaking in to GIMPLE (happens on trunk also, but mostly savaged by re-gimplifying GENERIC folding results which strips them). We need a better solution in the end (fix the C++ frontend), but for now the following should fix things enough. (fingers crossing) Committed. I plan to push the tree-cfg.c hunk to trunk as well (once it passed bootstrap/testing there) - expand_debug_expr will ICE on NON_LVALUE_EXPRs (which is where I noticed the above). Richard. 2014-08-28 Richard Biener * tree-cfg.c (verify_gimple_assign_unary): Do not allow NON_LVALUE_EXPR in gimple. * genmatch.c (main): Always define GENERIC and GIMPLE. * match-constant-folding.pd (x OP 0): Constrain when we generate NON_LVALUE_EXPR further. Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 214677) +++ gcc/tree-cfg.c (working copy) @@ -3572,7 +3572,6 @@ verify_gimple_assign_unary (gimple stmt) case ABS_EXPR: case BIT_NOT_EXPR: case PAREN_EXPR: - case NON_LVALUE_EXPR: case CONJ_EXPR: break; Index: gcc/genmatch.c =================================================================== --- gcc/genmatch.c (revision 214677) +++ gcc/genmatch.c (working copy) @@ -2544,6 +2544,7 @@ main(int argc, char **argv) if (!cpp_read_main_file (r, input)) return 1; cpp_define (r, gimple ? "GIMPLE=1": "GENERIC=1"); + cpp_define (r, gimple ? "GENERIC=0": "GIMPLE=0"); /* Pre-seed operators. */ operators = new hash_table (1024); Index: gcc/match-constant-folding.pd =================================================================== --- gcc/match-constant-folding.pd (revision 214677) +++ gcc/match-constant-folding.pd (working copy) @@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. (for op in plus pointer_plus minus bit_ior bit_xor (simplify (op @0 integer_zerop) - (if (!in_gimple_form) + (if (GENERIC && !in_gimple_form) /* ??? fold_binary adds non_lvalue here and "fixes" the C++ run of Wsizeof-pointer-memaccess1.c, preserving enough of sizeof (&a) + 0 because sizeof (&a) is maybe_lvalue_p ()