From patchwork Sat Mar 20 14:53:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1456117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=OLUN5KWT; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F2kKl2QlPz9sTD for ; Sun, 21 Mar 2021 01:53:45 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A1BF3858001; Sat, 20 Mar 2021 14:53:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A1BF3858001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1616252021; bh=RYOc2GrhGtM3SK0CYNOUIwv9Os0rcvwLXuG4a5N43/k=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OLUN5KWTObAqVkCZTKNTS5DOfS7psuEr1bF2LCt32vzcuRO0TlIrzbKfWKDN2FvF/ 1ZPa8kcDdRnGjyRWGejsjmGuIUFTE8KHc6NnUasCHUZBEySR+ztjug7b6ojDLwyrtk 0vk2kgQTULtz8Z0T44o5jzFlEWeHZENgQ+OLSIeQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 960663858D33 for ; Sat, 20 Mar 2021 14:53:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 960663858D33 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-186-bPyXkqBHMWyOXKo1Nz9kDw-1; Sat, 20 Mar 2021 10:53:34 -0400 X-MC-Unique: bPyXkqBHMWyOXKo1Nz9kDw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F8D887A83B for ; Sat, 20 Mar 2021 14:53:33 +0000 (UTC) Received: from [10.10.116.84] (ovpn-116-84.rdu2.redhat.com [10.10.116.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0951260C04 for ; Sat, 20 Mar 2021 14:53:32 +0000 (UTC) Subject: [committed] [PR99680] Check empty constraint before using CONSTRAINT_LEN. To: "gcc-patches@gcc.gnu.org" Message-ID: <34941134-4f9f-29f5-18f1-af218824da24@redhat.com> Date: Sat, 20 Mar 2021 10:53:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Vladimir Makarov via Gcc-patches From: Vladimir Makarov Reply-To: Vladimir Makarov Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99680 The patch was successfully bootstrapped on x86-64. commit c1ab0c0336d85f5e97739060ecf77fd05ac86d2a Author: Vladimir N. Makarov Date: Sat Mar 20 10:50:03 2021 -0400 [PR99680] Check empty constraint before using CONSTRAINT_LEN. It seems CONSTRAINT_LEN treats constraint '\0' as one having length 1. Therefore we read after the constraint string. The patch fixes it. gcc/ChangeLog: PR rtl-optimization/99680 * lra-constraints.c (skip_contraint_modifiers): Rename to skip_constraint_modifiers. (process_address_1): Check empty constraint before using CONSTRAINT_LEN. diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 698d8d04a1e..fdfe953bcf5 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -3395,12 +3395,12 @@ equiv_address_substitution (struct address_info *ad) /* Skip all modifiers and whitespaces in constraint STR and return the result. */ static const char * -skip_contraint_modifiers (const char *str) +skip_constraint_modifiers (const char *str) { for (;;str++) switch (*str) { - case '+' : case '&' : case '=': case '*': case ' ': case '\t': + case '+': case '&' : case '=': case '*': case ' ': case '\t': case '$': case '^' : case '%': case '?': case '!': break; default: return str; @@ -3451,13 +3451,13 @@ process_address_1 (int nop, bool check_only_p, return false; constraint - = skip_contraint_modifiers (curr_static_id->operand[nop].constraint); + = skip_constraint_modifiers (curr_static_id->operand[nop].constraint); if (IN_RANGE (constraint[0], '0', '9')) { char *end; unsigned long dup = strtoul (constraint, &end, 10); constraint - = skip_contraint_modifiers (curr_static_id->operand[dup].constraint); + = skip_constraint_modifiers (curr_static_id->operand[dup].constraint); } cn = lookup_constraint (*constraint == '\0' ? "X" : constraint); /* If we have several alternatives or/and several constraints in an @@ -3465,10 +3465,10 @@ process_address_1 (int nop, bool check_only_p, use unknown constraint. The exception is an address constraint. If operand has one address constraint, probably all others constraints are address ones. */ - if (get_constraint_type (cn) != CT_ADDRESS - && *skip_contraint_modifiers (constraint - + CONSTRAINT_LEN (constraint[0], - constraint)) != '\0') + if (constraint[0] != '\0' && get_constraint_type (cn) != CT_ADDRESS + && *skip_constraint_modifiers (constraint + + CONSTRAINT_LEN (constraint[0], + constraint)) != '\0') cn = CONSTRAINT__UNKNOWN; if (insn_extra_address_constraint (cn) /* When we find an asm operand with an address constraint that