From patchwork Fri Mar 10 13:15:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 737409 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 3vfnnw62T8z9ryQ for ; Sat, 11 Mar 2017 00:16:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GwzQDbBl"; 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 :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=AdSgWBlj7nh7bfqjKzGysj9zHP0ASJwUJMCdRisq0plzMWlW7nflu rxoUOGP9YRSwiASj01UYgMK4TDqdtuhEl4rITPs+OM/+lo2LJrDsJEcUqAUq6Aq9 IKZcxrY4X3PYlp/Erzwqlrj774Ua20Y5wW5ZmBVJETSWRccsdRQ+Ts= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=paxkzWHFryzSfDUAXwGS9HKsuVo=; b=GwzQDbBl08TpfgS147S+ tkOcs/2FPLoPD5/fJ0CUE2HtpMZkAnAIqV/qSnZzd24nJtb0LfONaTKaX/bB/FRd /dN4iTe+FpSJqyfITt1iuvxglBhEBcKPPbI+Zh9YOS9KnIjkFkkHR6pAATZLu7pU qmfGvs46PRfvquNEWmlW+ZY= Received: (qmail 20118 invoked by alias); 10 Mar 2017 13:15:49 -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 19613 invoked by uid 89); 10 Mar 2017 13:15:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2984 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Mar 2017 13:15:20 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 33ED7AD82 for ; Fri, 10 Mar 2017 13:15:16 +0000 (UTC) From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] MPX: fix PR middle-end/79753 To: GCC Patches Message-ID: <09ca632c-23c6-4731-ab99-4fefc5e6de4e@suse.cz> Date: Fri, 10 Mar 2017 14:15:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 X-IsSubscribed: yes Hello. Currently, __builtin_ia32_bndret is used for all functions that have non-void return type. I think the right fix is to return bounds just for a bounded type. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Martin From f4ad5003a42ca95187305a9b201656c7da2aaa01 Mon Sep 17 00:00:00 2001 From: marxin Date: Thu, 9 Mar 2017 15:42:49 +0100 Subject: [PATCH] MPX: fix PR middle-end/79753 gcc/ChangeLog: 2017-03-09 Martin Liska PR middle-end/79753 * tree-chkp.c (chkp_build_returned_bound): Do not build returned bounds for a LHS that's not a BOUNDED_P type. gcc/testsuite/ChangeLog: 2017-03-10 Martin Liska * gcc.target/i386/mpx/pr79753.c: New test. --- gcc/testsuite/gcc.target/i386/mpx/pr79753.c | 14 ++++++++++++++ gcc/tree-chkp.c | 11 ++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79753.c diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79753.c b/gcc/testsuite/gcc.target/i386/mpx/pr79753.c new file mode 100644 index 00000000000..9b7bc52e1ed --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/pr79753.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ + +int +foo (void) +{ + return 0; +} + +void +bar (int **p) +{ + *p = (int *) (__UINTPTR_TYPE__) foo (); +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index acd57eac5ef..c057b977342 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -2218,6 +2218,7 @@ chkp_build_returned_bound (gcall *call) gimple *stmt; tree fndecl = gimple_call_fndecl (call); unsigned int retflags; + tree lhs = gimple_call_lhs (call); /* To avoid fixing alloca expands in targets we handle it separately. */ @@ -2227,9 +2228,8 @@ chkp_build_returned_bound (gcall *call) || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_ALLOCA_WITH_ALIGN)) { tree size = gimple_call_arg (call, 0); - tree lb = gimple_call_lhs (call); gimple_stmt_iterator iter = gsi_for_stmt (call); - bounds = chkp_make_bounds (lb, size, &iter, true); + bounds = chkp_make_bounds (lhs, size, &iter, true); } /* We know bounds returned by set_bounds builtin call. */ else if (fndecl @@ -2282,9 +2282,10 @@ chkp_build_returned_bound (gcall *call) bounds = chkp_find_bounds (gimple_call_arg (call, argno), &iter); } - else if (chkp_call_returns_bounds_p (call)) + else if (chkp_call_returns_bounds_p (call) + && BOUNDED_P (lhs)) { - gcc_assert (TREE_CODE (gimple_call_lhs (call)) == SSA_NAME); + gcc_assert (TREE_CODE (lhs) == SSA_NAME); /* In general case build checker builtin call to obtain returned bounds. */ @@ -2311,7 +2312,7 @@ chkp_build_returned_bound (gcall *call) print_gimple_stmt (dump_file, call, 0, TDF_VOPS|TDF_MEMSYMS); } - bounds = chkp_maybe_copy_and_register_bounds (gimple_call_lhs (call), bounds); + bounds = chkp_maybe_copy_and_register_bounds (lhs, bounds); return bounds; } -- 2.11.1