From patchwork Wed Apr 29 08:01:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 465923 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 4F3F3140332 for ; Wed, 29 Apr 2015 18:02:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=K8Es9dqj; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=bH/bOU+g+vEKYZB0k+oQZpvfguZLVHEqrKSrkXPbAiJkmz/k9EkeP NjLA+rg1LmSl1i1ooxf5lbO40B/YkjpTmTe882j+cV7zVimIyy2JWX6SpJExpy5g b3lT9eDOim3Ds/H7z9VmjwlGBWnJE9rQI7Yg1THh91/M4Cf68FMznQ= 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:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=x/H367s3WPH59nnWLkPyiuX9oBg=; b=K8Es9dqjfObpqeM9N515 5S8Z8W4ouw7L1vRQrqSsW8pDkAB24XYNjtY9HR8OddOVqDy2eLFyklILUocege0U Ht0mu7XLhYWjQvfbPeszFE37XpWFhIp13Gi1pZhZ7ydFM1lk+yw9zeQzpD1AyQ/8 vBq14v/RGsen6YvbqocxEKk= Received: (qmail 67723 invoked by alias); 29 Apr 2015 08:02:00 -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 67697 invoked by uid 89); 29 Apr 2015 08:01:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f51.google.com Received: from mail-wg0-f51.google.com (HELO mail-wg0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 29 Apr 2015 08:01:57 +0000 Received: by wgyo15 with SMTP id o15so19155365wgy.2 for ; Wed, 29 Apr 2015 01:01:54 -0700 (PDT) X-Received: by 10.194.236.225 with SMTP id ux1mr39949915wjc.52.1430294514780; Wed, 29 Apr 2015 01:01:54 -0700 (PDT) Received: from s42.loc (91-119-126-175.dynamic.xdsl-line.inode.at. [91.119.126.175]) by mx.google.com with ESMTPSA id e10sm20000234wij.11.2015.04.29.01.01.53 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 29 Apr 2015 01:01:53 -0700 (PDT) Received: from cow by s42.loc with local (Exim 4.80) (envelope-from ) id 1YnMwK-0004mp-Nu; Wed, 29 Apr 2015 10:01:52 +0200 From: Bernhard Reutner-Fischer To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer Subject: [PATCH] gimple-walk.c #include TLC Date: Wed, 29 Apr 2015 10:01:50 +0200 Message-Id: <1430294510-18361-2-git-send-email-rep.dot.nop@gmail.com> In-Reply-To: <1430294510-18361-1-git-send-email-rep.dot.nop@gmail.com> References: <1430294510-18361-1-git-send-email-rep.dot.nop@gmail.com> X-IsSubscribed: yes Hi there, I noticed that gimple-walk.c has a creative list of #includes. Furthermore, in walk_gimple_asm parse_{in,out}put_constraint was called even if neither allows_mem, allows_reg nor is_inout were used -- i.e. if wi is NULL -- and the return value of the constraint parsing was not taken into account which looks wrong or at least odd. Note that several other spots in the tree do ignore the parse_{in,out}put_constraint return values and should be adjusted too AFAIU. Otherwise we might attempt (and use!) to extract information from otherwise illegal constraints, it seems? Bootstrapped and regtested on x86_64-unknown-linux with no regressions. Ok for trunk? gcc/ChangeLog: * gimple-walk.c: Prune duplicate or unneeded includes. (walk_gimple_asm): Only call parse_input_constraint or parse_output_constraint if their findings are used. Honour parse_input_constraint and parse_output_constraint result. diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index 45ff859..53462b5 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -2,75 +2,69 @@ Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by Aldy Hernandez This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ #include "config.h" #include "system.h" #include "coretypes.h" #include "tm.h" #include "hash-set.h" -#include "machmode.h" #include "vec.h" #include "double-int.h" #include "input.h" #include "alias.h" #include "symtab.h" -#include "wide-int.h" #include "inchash.h" #include "tree.h" -#include "fold-const.h" -#include "stmt.h" #include "predict.h" #include "hard-reg-set.h" -#include "input.h" #include "function.h" -#include "basic-block.h" -#include "tree-ssa-alias.h" -#include "internal-fn.h" #include "gimple-expr.h" #include "is-a.h" +#include "tree-ssa-alias.h" +#include "basic-block.h" +#include "fold-const.h" #include "gimple.h" #include "gimple-iterator.h" #include "gimple-walk.h" -#include "gimple-walk.h" -#include "demangle.h" +#include "stmt.h" /* Walk all the statements in the sequence *PSEQ calling walk_gimple_stmt on each one. WI is as in walk_gimple_stmt. If walk_gimple_stmt returns non-NULL, the walk is stopped, and the value is stored in WI->CALLBACK_RESULT. Also, the statement that produced the value is returned if this statement has not been removed by a callback (wi->removed_stmt). If the statement has been removed, NULL is returned. Otherwise, all the statements are walked and NULL returned. */ gimple walk_gimple_seq_mod (gimple_seq *pseq, walk_stmt_fn callback_stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi) { gimple_stmt_iterator gsi; for (gsi = gsi_start (*pseq); !gsi_end_p (gsi); ) { tree ret = walk_gimple_stmt (&gsi, callback_stmt, callback_op, wi); if (ret) { /* If CALLBACK_STMT or CALLBACK_OP return a value, WI must exist to hold it. */ @@ -107,71 +101,76 @@ walk_gimple_seq (gimple_seq seq, walk_stmt_fn callback_stmt, /* Helper function for walk_gimple_stmt. Walk operands of a GIMPLE_ASM. */ static tree walk_gimple_asm (gasm *stmt, walk_tree_fn callback_op, struct walk_stmt_info *wi) { tree ret, op; unsigned noutputs; const char **oconstraints; unsigned i, n; const char *constraint; bool allows_mem, allows_reg, is_inout; noutputs = gimple_asm_noutputs (stmt); oconstraints = (const char **) alloca ((noutputs) * sizeof (const char *)); if (wi) wi->is_lhs = true; for (i = 0; i < noutputs; i++) { op = gimple_asm_output_op (stmt, i); constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); oconstraints[i] = constraint; - parse_output_constraint (&constraint, i, 0, 0, &allows_mem, &allows_reg, - &is_inout); if (wi) - wi->val_only = (allows_reg || !allows_mem); + { + if (parse_output_constraint (&constraint, i, 0, 0, &allows_mem, + &allows_reg, &is_inout)) + wi->val_only = (allows_reg || !allows_mem); + } ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); if (ret) return ret; } n = gimple_asm_ninputs (stmt); for (i = 0; i < n; i++) { op = gimple_asm_input_op (stmt, i); constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (op))); - parse_input_constraint (&constraint, 0, 0, noutputs, 0, - oconstraints, &allows_mem, &allows_reg); + if (wi) { - wi->val_only = (allows_reg || !allows_mem); - /* Although input "m" is not really a LHS, we need a lvalue. */ - wi->is_lhs = !wi->val_only; + if (parse_input_constraint (&constraint, 0, 0, noutputs, 0, + oconstraints, &allows_mem, &allows_reg)) + { + wi->val_only = (allows_reg || !allows_mem); + /* Although input "m" is not really a LHS, we need a lvalue. */ + wi->is_lhs = !wi->val_only; + } } ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); if (ret) return ret; } if (wi) { wi->is_lhs = false; wi->val_only = true; } n = gimple_asm_nlabels (stmt); for (i = 0; i < n; i++) { op = gimple_asm_label_op (stmt, i); ret = walk_tree (&TREE_VALUE (op), callback_op, wi, NULL); if (ret) return ret; } return NULL_TREE; }