From patchwork Mon Nov 18 10:37:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 292015 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 59A212C007C for ; Mon, 18 Nov 2013 21:40:15 +1100 (EST) 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=FhgR4XXeQz258hXnLD0oLG05aVbOcATvBNkWScz9hp4h5JaFC+uiJ +jJL3F5jAz39Od/W+27h3JPVThcVrnx1HMbGttspRjD4QbdpQTZ4WKQtJeKXNtDS L59aCP1dvPZ668nUJ9in2rpAXhfezJCLAn5AXM09P2xX5w5xwVKm6I= 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=0sarwc6SSbKWBHQ+sBKndCXW5GQ=; b=e/vt8QoSPB/NSR7bsdzO iFIXMroI2sS+MuI7AZwvdfsjoVfSzLVvzqpLaGNfTOBa5fZML16r9CVStEwXaTON 77+w0zhpyYC+efmTAiFJp0oJbmHACvfP94ciySUNFa73hli8qvOfdjIxbgaefuID DAp08UNkZQE0T83LOdkjAxE= Received: (qmail 24773 invoked by alias); 18 Nov 2013 10:38:28 -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 24654 invoked by uid 89); 18 Nov 2013 10:38:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-pa0-f52.google.com Received: from Unknown (HELO mail-pa0-f52.google.com) (209.85.220.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 18 Nov 2013 10:38:26 +0000 Received: by mail-pa0-f52.google.com with SMTP id ld10so1959755pab.25 for ; Mon, 18 Nov 2013 02:38:18 -0800 (PST) X-Received: by 10.69.31.1 with SMTP id ki1mr12914727pbd.124.1384771098601; Mon, 18 Nov 2013 02:38:18 -0800 (PST) Received: from msticlxl57.ims.intel.com ([192.55.54.41]) by mx.google.com with ESMTPSA id gg10sm22495438pbc.46.2013.11.18.02.38.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 18 Nov 2013 02:38:18 -0800 (PST) Date: Mon, 18 Nov 2013 14:37:33 +0400 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, MPX, 2/X] Pointers Checker [16/25] Tail recursion Message-ID: <20131118103733.GJ21297@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, Here is a patch to disable tail recursion transformation when bounds are passed by call. The reason is BUILT_IN_CHKP_ARG_BND which should always get default SSA_NAME of PARM_DECL as an argument. Thanks, Ilya --- 2013-11-15 Ilya Enkovich * tree-tailcall.c: Include tree-chkp.h. (suitable_for_tail_opt_p): Disable tail recursion for instrumented functions with bounded args. diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 185bf16..59845950 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "common/common-target.h" #include "ipa-utils.h" +#include "tree-chkp.h" /* The file implements the tail recursion elimination. It is also used to analyze the tail calls in general, passing the results to the rtl level @@ -141,6 +142,20 @@ suitable_for_tail_opt_p (void) if (cfun->stdarg) return false; + /* Tail recursion elimination may cause arg_bnd builtins to be called + not for PARM_DECL which is not allowed now. Avoid optimization + in such cases for now. */ + if (chkp_function_instrumented_p (current_function_decl)) + { + tree param; + + for (param = DECL_ARGUMENTS (current_function_decl); + param; + param = DECL_CHAIN (param)) + if (BOUNDED_P (param)) + return false; + } + return true; } /* Returns false when the function is not suitable for tail call optimization