From patchwork Thu Jul 16 13:16:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 496689 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 E64001402B2 for ; Thu, 16 Jul 2015 23:17:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=oMmVFod/; 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=ixxBJhud3WSs8xyi 8B6FDwROMOjMIhyERVUZ659D44jT9shS/fh3I1leiRtAQUW3y7/FhdEr/cvadup4 8nqlpCySKMkrFAjIOWLSM4f0hxJVnimeCAD3+APSmKPaLe0hGkHoeWwdFuBmlVcS 8rSdS/K+5bucTG2n17fs4TfDam0= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=Ul+squg8hQ2LGQdUEHhunX PTRlM=; b=oMmVFod/Z9PHgVwoKq4tLRQNS/WLCR0QtdEUlUS8V6NnbF/1mUA+3Q AxXmr71Bt8CcfDSUCKwWBLbcUQW8MbzBWEsg9xH43hSxBPO/sDTTagS+suGTpKAk a8E1/fUt7eLDkmz0ClDb5X49WugeJmc9R0Jyb2OE3YR5agRMiiHWY= Received: (qmail 110098 invoked by alias); 16 Jul 2015 13:17:05 -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 110023 invoked by uid 89); 16 Jul 2015 13:17:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jul 2015 13:17:01 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-17-rhVK5nMnQ6GE5MM3_0xXGQ-1; Thu, 16 Jul 2015 14:16:57 +0100 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Jul 2015 14:16:56 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] Remove unnecessary null checks from genattrtab.c User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) Date: Thu, 16 Jul 2015 14:16:56 +0100 Message-ID: <877fq0jl87.fsf@e105548-lin.cambridge.arm.com> MIME-Version: 1.0 X-MC-Unique: rhVK5nMnQ6GE5MM3_0xXGQ-1 check_attr_value and make_canonical have some checks for null attr arguments, but all callers would segfault if the argument really were null. This is preparing for some improvements to the source location tracking in gen*. Series bBootstrapped & regression-tested on x86_64-linux-gnu. I built gcc before and after the series for one target per CPU directory and checked that the output was the same (except for some filename fixes later in the series.) Applied. Thanks, Richard gcc/ * genattrtab.c (check_attr_value): Remove handling of null attrs. (make_canonical): Likewise. Index: gcc/genattrtab.c =================================================================== --- gcc/genattrtab.c 2015-07-05 22:19:53.407810340 +0100 +++ gcc/genattrtab.c 2015-07-06 21:42:39.666899334 +0100 @@ -899,7 +899,7 @@ check_attr_test (rtx exp, int is_const, /* Given an expression, ensure that it is validly formed and that all named attribute values are valid for the given attribute. Issue a fatal error - if not. If no attribute is specified, assume a numeric attribute. + if not. Return a perhaps modified replacement expression for the value. */ @@ -913,7 +913,7 @@ check_attr_value (rtx exp, struct attr_d switch (GET_CODE (exp)) { case CONST_INT: - if (attr && ! attr->is_numeric) + if (!attr->is_numeric) { error_with_line (attr->lineno, "CONST_INT not valid for non-numeric attribute %s", @@ -934,15 +934,15 @@ check_attr_value (rtx exp, struct attr_d if (! strcmp (XSTR (exp, 0), "*")) break; - if (attr == 0 || attr->is_numeric) + if (attr->is_numeric) { p = XSTR (exp, 0); for (; *p; p++) if (! ISDIGIT (*p)) { - error_with_line (attr ? attr->lineno : 0, + error_with_line (attr->lineno, "non-numeric value for numeric attribute %s", - attr ? attr->name : "internal"); + attr->name); break; } break; @@ -956,13 +956,12 @@ check_attr_value (rtx exp, struct attr_d if (av == NULL) error_with_line (attr->lineno, "unknown value `%s' for `%s' attribute", - XSTR (exp, 0), attr ? attr->name : "internal"); + XSTR (exp, 0), attr->name); break; case IF_THEN_ELSE: - XEXP (exp, 0) = check_attr_test (XEXP (exp, 0), - attr ? attr->is_const : 0, - attr ? attr->lineno : 0); + XEXP (exp, 0) = check_attr_test (XEXP (exp, 0), attr->is_const, + attr->lineno); XEXP (exp, 1) = check_attr_value (XEXP (exp, 1), attr); XEXP (exp, 2) = check_attr_value (XEXP (exp, 2), attr); break; @@ -972,7 +971,7 @@ check_attr_value (rtx exp, struct attr_d case MULT: case DIV: case MOD: - if (attr && !attr->is_numeric) + if (!attr->is_numeric) { error_with_line (attr->lineno, "invalid operation `%s' for non-numeric" @@ -1007,8 +1006,8 @@ check_attr_value (rtx exp, struct attr_d for (i = 0; i < XVECLEN (exp, 0); i += 2) { XVECEXP (exp, 0, i) = check_attr_test (XVECEXP (exp, 0, i), - attr ? attr->is_const : 0, - attr ? attr->lineno : 0); + attr->is_const, + attr->lineno); XVECEXP (exp, 0, i + 1) = check_attr_value (XVECEXP (exp, 0, i + 1), attr); } @@ -1020,15 +1019,13 @@ check_attr_value (rtx exp, struct attr_d { struct attr_desc *attr2 = find_attr (&XSTR (exp, 0), 0); if (attr2 == NULL) - error_with_line (attr ? attr->lineno : 0, - "unknown attribute `%s' in ATTR", + error_with_line (attr->lineno, "unknown attribute `%s' in ATTR", XSTR (exp, 0)); - else if (attr && attr->is_const && ! attr2->is_const) + else if (attr->is_const && ! attr2->is_const) error_with_line (attr->lineno, "non-constant attribute `%s' referenced from `%s'", XSTR (exp, 0), attr->name); - else if (attr - && attr->is_numeric != attr2->is_numeric) + else if (attr->is_numeric != attr2->is_numeric) error_with_line (attr->lineno, "numeric attribute mismatch calling `%s' from `%s'", XSTR (exp, 0), attr->name); @@ -1042,7 +1039,7 @@ check_attr_value (rtx exp, struct attr_d return attr_rtx (SYMBOL_REF, XSTR (exp, 0)); default: - error_with_line (attr ? attr->lineno : 0, + error_with_line (attr->lineno, "invalid operation `%s' for attribute value", GET_RTX_NAME (GET_CODE (exp))); break; @@ -1199,7 +1196,7 @@ make_canonical (struct attr_desc *attr, case CONST_STRING: if (! strcmp (XSTR (exp, 0), "*")) { - if (attr == 0 || attr->default_val == 0) + if (attr->default_val == 0) fatal ("(attr_value \"*\") used in invalid context"); exp = attr->default_val->value; }