From patchwork Thu Jun 18 10:22:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 486252 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 765AA14027C for ; Thu, 18 Jun 2015 20:22:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nloQG1Xm; 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=plZ0cpLI/FpoyS8P2BWdsf72OBa5A0+682Omlh6bDD6vzsnq5GPRt EUy/bgF/hbhbTyBVamdtPukCy1wBpie5Dnb1XMoUJrt7TjbmqdJ78372HvNugMiw 2pYlyJWUNTxOqgikGkqaBeAlZ7MLrqULVesR4Wi7F71QeHyh14cCEA= 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=cmuEJ2Qe62oKDMRrpFHoUaSSj+I=; b=nloQG1Xm7hnun7Y3I4rk pqWnmsELSc7gNFLQAXB5Ae0NAplxU6dUM68h0H4PJNCmD363Kv98zlF+0lTHQPtB OBwyGl/LxtDhGc28hWgABgZ7ZOydb+xbQr4Y1bEh9MRYz18aS+JeMoVK5CPDeg/k iFToJqZsGN+Hg0JgsemS7y0= Received: (qmail 79421 invoked by alias); 18 Jun 2015 10:22:25 -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 79405 invoked by uid 89); 18 Jun 2015 10:22:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f171.google.com Received: from mail-qk0-f171.google.com (HELO mail-qk0-f171.google.com) (209.85.220.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 18 Jun 2015 10:22:23 +0000 Received: by qkbp125 with SMTP id p125so37100495qkb.2 for ; Thu, 18 Jun 2015 03:22:21 -0700 (PDT) X-Received: by 10.141.28.195 with SMTP id f186mr14394765qhe.31.1434622941276; Thu, 18 Jun 2015 03:22:21 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.40]) by mx.google.com with ESMTPSA id 29sm3634065qkr.47.2015.06.18.03.22.18 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jun 2015 03:22:20 -0700 (PDT) Date: Thu, 18 Jun 2015 13:22:08 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, CHKP, PR target/66569] Fix internal compiler error: in assign_by_spills Message-ID: <20150618102208.GD28183@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, this patch changes an order of bounds params expand for vararg function. This is neede for vararg function which have bounds passed for named args but these bounds are nor passed i nregisters. In this case we try to load them from bounds table but all registers are used for vararg bounds and we have no register to use. Patch delays expand of non register named bounds until vararg bounds are expanded. Bootstrapped and regtested for x86_64-unknown-linux-gnu. Applied to trunk. Is it OK for gcc-5-branch? Thanks, Ilya --- gcc/ 2015-06-18 Ilya Enkovich PR target/66569 * function.c (assign_bounds): Add arguments assign_regs, assign_special, assign_bt. (assign_parms): For vararg functions handle bounds in BT and special slots after incoming vararg bounds. gcc/testsuite/ 2015-06-18 Ilya Enkovich PR target/66569 * gcc.target/i386/mpx/chkp-vararg.c: New test. diff --git a/gcc/function.c b/gcc/function.c index 8baaed7..4d564fe 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3490,9 +3490,11 @@ assign_parm_load_bounds (struct assign_parm_data_one *data, static void assign_bounds (vec &bndargs, - struct assign_parm_data_all &all) + struct assign_parm_data_all &all, + bool assign_regs, bool assign_special, + bool assign_bt) { - unsigned i, pass, handled = 0; + unsigned i, pass; bounds_parm_data *pbdata; if (!bndargs.exists ()) @@ -3506,17 +3508,20 @@ assign_bounds (vec &bndargs, { /* Pass 0 => regs only. */ if (pass == 0 - && (!pbdata->parm_data.entry_parm - || GET_CODE (pbdata->parm_data.entry_parm) != REG)) + && (!assign_regs + ||(!pbdata->parm_data.entry_parm + || GET_CODE (pbdata->parm_data.entry_parm) != REG))) continue; /* Pass 1 => slots only. */ else if (pass == 1 - && (!pbdata->parm_data.entry_parm - || GET_CODE (pbdata->parm_data.entry_parm) == REG)) + && (!assign_special + || (!pbdata->parm_data.entry_parm + || GET_CODE (pbdata->parm_data.entry_parm) == REG))) continue; /* Pass 2 => BT only. */ else if (pass == 2 - && pbdata->parm_data.entry_parm) + && (!assign_bt + || pbdata->parm_data.entry_parm)) continue; if (!pbdata->parm_data.entry_parm @@ -3537,14 +3542,7 @@ assign_bounds (vec &bndargs, else assign_parm_setup_stack (&all, pbdata->bounds_parm, &pbdata->parm_data); - - /* Count handled bounds to make sure we miss nothing. */ - handled++; } - - gcc_assert (handled == bndargs.length ()); - - bndargs.release (); } /* Assign RTL expressions to the function's parameters. This may involve @@ -3669,12 +3667,14 @@ assign_parms (tree fndecl) /* We expect this is the last parm. Otherwise it is wrong to assign bounds right now. */ gcc_assert (i == (fnargs.length () - 1)); - assign_bounds (bndargs, all); + assign_bounds (bndargs, all, true, false, false); targetm.calls.setup_incoming_vararg_bounds (all.args_so_far, data.promoted_mode, data.passed_type, &pretend_bytes, false); + assign_bounds (bndargs, all, false, true, true); + bndargs.release (); } } @@ -3686,7 +3686,8 @@ assign_parms (tree fndecl) bound_no++; } - assign_bounds (bndargs, all); + assign_bounds (bndargs, all, true, true, true); + bndargs.release (); if (targetm.calls.split_complex_arg) assign_parms_unsplit_complex (&all, fnargs); diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66569.c b/gcc/testsuite/gcc.target/i386/mpx/pr66569.c new file mode 100644 index 0000000..ba2023c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/pr66569.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +struct s1 { + int *p; + int i; +}; + +struct s2 { + struct s1 s; + int i; +}; + +int test (struct s2 s, ...) { }