From patchwork Wed Feb 25 14:25:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 443417 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 089D1140083 for ; Thu, 26 Feb 2015 01:26:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=pNsd5pjI; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=vW/n2zzdCVswVNJxTAfxbI2WVFXQ5oUtJNDKjuheS8H6K3IHSJgwd fjvR228zLfjH6kiNy3yDweaq9cBAomumqQlYn72/s7ioctQgXuMUiue/Zp8tfeSl 5NO79lR6VFFDal2zJin+Y372TT/stjli8E3kg9DIhDDVQ1KwE/HgSI= 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:subject:message-id:mime-version:content-type; s= default; bh=zhOZT9Qi5ZHoIAmxo2IH6UTKock=; b=pNsd5pjIPLxsgiMMqepV OUdxr8i6eBQNV9lNcCUfUGqFPNzEQ8paeuwxwzAjGqdj/JhJ+xPSOq+nWrQMG1Gj 3QWvkobr6yHf9dPov9ng+NH7MiLxJu9pJheCjFhfEcpvBKOPHazcCkk4wHRN3noX BLjj75mdmyhjHp3HSAoYfSU= Received: (qmail 27814 invoked by alias); 25 Feb 2015 14:26:15 -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 27803 invoked by uid 89); 25 Feb 2015 14:26:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_FROM_URIBL_PCCC, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wi0-f173.google.com Received: from mail-wi0-f173.google.com (HELO mail-wi0-f173.google.com) (209.85.212.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 25 Feb 2015 14:26:13 +0000 Received: by mail-wi0-f173.google.com with SMTP id bs8so33789564wib.0 for ; Wed, 25 Feb 2015 06:26:10 -0800 (PST) X-Received: by 10.180.189.203 with SMTP id gk11mr6983501wic.32.1424874370625; Wed, 25 Feb 2015 06:26:10 -0800 (PST) Received: from msticlxl57.ims.intel.com ([192.55.55.41]) by mx.google.com with ESMTPSA id u16sm25869306wjr.5.2015.02.25.06.26.08 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 06:26:10 -0800 (PST) Date: Wed, 25 Feb 2015 17:25:59 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, CHKP, i386, PR target/65184] Fix pass_by_reference for MS ABI for bounds Message-ID: <20150225142559.GC65329@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, Currenly ix86_pass_by_reference may return 1 for bounds if MS ABI is used. This patch explicitly says bounds are never passed by reference. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Ilya --- gcc/ 2015-02-25 Ilya Enkovich PR target/65184 * gcc/config/i386/i386.c (ix86_pass_by_reference) Bounds are never passed by reference. gcc/testsuite/ 2015-02-25 Ilya Enkovich PR target/65184 * gcc.target/i386/pr65184.c: New. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 71a5b22..28242d7 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -7859,6 +7859,11 @@ ix86_pass_by_reference (cumulative_args_t cum_v, machine_mode mode, { CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); + /* Bounds are never passed by reference. */ + if ((type && POINTER_BOUNDS_TYPE_P (type)) + || POINTER_BOUNDS_MODE_P (mode)) + return false; + /* See Windows x64 Software Convention. */ if (TARGET_64BIT && (cum ? cum->call_abi : ix86_abi) == MS_ABI) { diff --git a/gcc/testsuite/gcc.target/i386/pr65184.c b/gcc/testsuite/gcc.target/i386/pr65184.c new file mode 100644 index 0000000..0355f29 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr65184.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mpx } */ +/* { dg-options "-O2 -mabi=ms -fcheck-pointer-bounds -mmpx" } */ + +void +foo (int *a) +{ + if (a[0] != a[1] * 2333) + __builtin_abort (); +} + +void +bar (int *a) +{ + if (a[0] != a[1] * 2333) + __builtin_abort (); +}