From patchwork Sat Dec 2 00:14:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 843838 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-468380-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="bctSgSz4"; 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 3ypWps3qf8z9sCZ for ; Sat, 2 Dec 2017 11:14:29 +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=MEJL2xDUEnHgo+s4GAYBz46FDnf5e e6pIIj/BO+4KIofuQd6hQ5q08aBj1S0XdzvklJdsLpR5SXCqryoXsxii8RdpGUtJ VMIOB6eHO8b5E8uDm80FpJUkHX713Mk+IKt/0UgQcf5nCjCbT46Zsksk9hQm/BTL 9UlgAEsDI+KzR4= 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=Vg7c4/XDigrPvRyTjc8yzDrfhiA=; b=bct SgSz4AqGuDGj+2RZs9KtVYVbGJRzKzZFMDQI3zbzHnxk23rFG0fukLuaS/1Leeqp phJDUwSRjpgBG1PNOC7hoCOu3qk5ds3qqoWfRzPufQVPqIU7AJDsvN6kcjyHjyUJ i8t0Ogvbw/IZSiB91iTz/N6EOqgfFyJg4x8l4Z70= Received: (qmail 118227 invoked by alias); 2 Dec 2017 00:14:10 -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 118109 invoked by uid 89); 2 Dec 2017 00:14:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= 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; Sat, 02 Dec 2017 00:14:08 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE15E356C1; Sat, 2 Dec 2017 00:14:07 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-77.ams2.redhat.com [10.36.116.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 54BB95C544; Sat, 2 Dec 2017 00:14:07 +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 vB20E4xr027535; Sat, 2 Dec 2017 01:14:05 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id vB20E4Vr027534; Sat, 2 Dec 2017 01:14:04 +0100 Date: Sat, 2 Dec 2017 01:14:03 +0100 From: Jakub Jelinek To: Richard Biener , Ilya Enkovich , Kirill Yukhin Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Handle POINTER_DIFF_EXPR in chkp Message-ID: <20171202001403.GD2353@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! The following testcase shows that chkp_compute_bounds_for_assignment should know about POINTER_DIFF_EXPR and handle it like it used to handle MINUS_EXPR of 2 pointers in the past. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-12-01 Jakub Jelinek * tree-chkp.c (chkp_compute_bounds_for_assignment): Handle POINTER_DIFF_EXPR. * gcc.target/i386/mpx/pointer-diff-1.c: New test. Jakub --- gcc/tree-chkp.c.jj 2017-11-13 09:31:29.000000000 +0100 +++ gcc/tree-chkp.c 2017-12-01 15:11:40.331410514 +0100 @@ -2762,6 +2762,7 @@ chkp_compute_bounds_for_assignment (tree case FLOAT_EXPR: case REALPART_EXPR: case IMAGPART_EXPR: + case POINTER_DIFF_EXPR: /* No valid bounds may be produced by these exprs. */ bounds = chkp_get_invalid_op_bounds (); break; --- gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c.jj 2017-12-01 15:18:52.805002275 +0100 +++ gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c 2017-12-01 15:17:35.000000000 +0100 @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mmpx -fcheck-pointer-bounds" } */ + +char * +foo (char *p, char *q) +{ + return (char *) (p - q); /* { dg-bogus "pointer bounds were lost due to unexpected expression" } */ +}