From patchwork Wed Oct 11 20:56:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 824568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463979-incoming=patchwork.ozlabs.org@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.b="sfkhocLt"; dkim-atps=neutral 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 3yC5rN4YSvz9sNw for ; Thu, 12 Oct 2017 07:56:49 +1100 (AEDT) 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=Wlf0PXObJhXgVU7B3oSkmcFvFSTzS 5UkIXHhry39MCyQ/XvjrTqn9Qy7hV6g1frOAtNITFOqhCRaRf8aCZU8x+7PW03wf riZSg09IkQk/sZV4eUbcphsI9BySLyf5Fo8N8pZYtX4eyG+V2yIwJ4LJKD5aoLbf 9Ca6kBkKrEXK34= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=MaQ8WssXSaoVsssuxRSAkAKiCoU=; b=sfk hocLt6Uuf+uWRqbE7wieAyJwM7smrABkjfvUAVFA2+D4NPSLB3/5kSr4xaNcwwxC dyUx4S7DazsLpvmSgSP8k/SHH3modwt0DGlkz75U+wE2Ck7sqhvkDVALVx1Wbdrc 18Ha/fBelM2y7pbDIf6QHGLE0A4L4TNomYh8Ym2Y= Received: (qmail 99851 invoked by alias); 11 Oct 2017 20:56:40 -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 99173 invoked by uid 89); 11 Oct 2017 20:56:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1380 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Oct 2017 20:56:38 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE0E168D3; Wed, 11 Oct 2017 20:56:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE0E168D3 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub@redhat.com Received: from tucnak.zalov.cz (ovpn-116-223.ams2.redhat.com [10.36.116.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 40B7C17C00; Wed, 11 Oct 2017 20:56:34 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v9BKuVbm024398; Wed, 11 Oct 2017 22:56:32 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v9BKuVix024397; Wed, 11 Oct 2017 22:56:31 +0200 Date: Wed, 11 Oct 2017 22:56:31 +0200 From: Jakub Jelinek To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Add further VEC_SELECT verification Message-ID: <20171011205631.GO14653@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! This patch adds verification that vec_select in *.md files doesn't have any out of bounds indices in the selector. Bootstrapped/regtested on x86_64-linux and i686-linux, tested by building cc1 of aarch64, arm, powerpc64le and s390x cross, and tested by hacking up sse.md to have an out of bounds access there, ok for trunk? 2017-10-11 Jakub Jelinek * genrecog.c (validate_pattern): For VEC_SELECT verify that CONST_INT selectors are 0 to GET_MODE_NUNITS (imode) - 1. Jakub --- gcc/genrecog.c.jj 2017-09-01 09:25:40.000000000 +0200 +++ gcc/genrecog.c 2017-10-11 17:53:20.107198630 +0200 @@ -751,6 +751,21 @@ validate_pattern (rtx pattern, md_rtx_in error_at (info->loc, "vec_select parallel with %d elements, expected %d", XVECLEN (XEXP (pattern, 1), 0), expected); + else if (VECTOR_MODE_P (imode)) + { + unsigned int nelems = GET_MODE_NUNITS (imode); + int i; + for (i = 0; i < expected; ++i) + if (CONST_INT_P (XVECEXP (XEXP (pattern, 1), 0, i)) + && (UINTVAL (XVECEXP (XEXP (pattern, 1), 0, i)) + >= nelems)) + error_at (info->loc, + "out of bounds selector %u in vec_select, " + "expected at most %u", + (unsigned) + UINTVAL (XVECEXP (XEXP (pattern, 1), 0, i)), + nelems - 1); + } } if (imode != VOIDmode && !VECTOR_MODE_P (imode)) error_at (info->loc, "%smode of first vec_select operand is not a "