From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103660 invoked by alias); 19 May 2016 13:33:27 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 103635 invoked by uid 89); 19 May 2016 13:33:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.1 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mail-oi0-f41.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zD87WjYmZbVwvGDAMkn1YjlNeANbFx/Jge2fDQgvcFA=; b=kYYYDx4I9FqHlL24wA7+mD5hiZUv01OCCkq+A/HTKkRxtmbKcMUBDlzJYBS3ew5duX Nmod0IGrkDEtwW2sH3QZVqI0elI9P8gg8t7MsTDC5ZMC0yxvM1OjeiPK3J6RzD3E1XMv 5MecwqW102pARoy4hMvksCXRSTDkZhlXwBavr1QzjWQPMrn2CpMYqJb/sXohcbLG0QkQ ArvAgQwgX9hYA2qhMg1Nz4+62Ny6D6g6DHUMsRTUo0NGHeKY8UBffXBdXiuefT0+IcY+ jzAiI2+pBjG9XxogmHqJIO/tMHjhQZc78CuwNPFBeKXHtK2z3gaT8xx8WdY4ytvcS4gq Z3uw== X-Gm-Message-State: AOPr4FWb729shhk47bADlaMfTl719JjpapqT4dOesE0hCPXnEQTfCGpXmQgn5c2+inFDEccMGpAfahsrAM8/gvwt X-Received: by 10.202.222.197 with SMTP id v188mr7016351oig.82.1463664794039; Thu, 19 May 2016 06:33:14 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1463522492-43504-1-git-send-email-dmalcolm@redhat.com> <01e0bf4f-c713-a84e-dc5d-d9c2ef43e09b@redhat.com> <573D4182.1020507@starynkevitch.net> From: Jason Merrill Date: Fri, 01 Jan 2016 00:00:00 -0000 Message-ID: Subject: Re: [PATCH 0/3] Support for mandatory tail calls To: Richard Biener Cc: Basile Starynkevitch , Jeff Law , David Malcolm , gcc-patches List , jit@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-q2/txt/msg00039.txt.bz2 On Thu, May 19, 2016 at 9:28 AM, Richard Biener wrote: > On Thu, May 19, 2016 at 3:19 PM, Jason Merrill wrote: >> On Thu, May 19, 2016 at 12:30 AM, Basile Starynkevitch >> wrote: >>> On 05/19/2016 12:12 AM, Jeff Law wrote: >>>> >>>> On 05/17/2016 04:01 PM, David Malcolm wrote: >>>>> >>>>> There have been requests [1] for libgccjit to better support >>>>> functional programming by supporting the contination-passing style, >>>>> in which every function "returns" by calling a "continuation" >>>>> function pointer. >>>>> >>>>> These calls must be guaranteed to be implemented as a jump, >>>>> otherwise the program could consume an arbitrary amount of stack >>>>> space as it executed. >>>>> >>>>> This patch kit implements this. >>>>> >>>>> Patch 1 is a preliminary tweak to calls.c >>>>> >>>>> Patch 2 implements a new flag in tree.h: CALL_EXPR_MUST_TAIL_CALL, >>>>> which makes calls.c try harder to implement a flagged call as a >>>>> tail-call/sibling call, and makes it issue an error if >>>>> the optimization is impossible. It doesn't implement any >>>>> frontend support for setting the flag (instead using a plugin >>>>> to test it). We had some discussion on the jit list about possibly >>>>> introducing a new builtin for this, but the patch punts on this >>>>> issue. >>>> >>>> I wonder if we should have an attribute so that the flag can be set for >>>> C/C++ code. I've seen requests for forcing tail calls in C/C++ code several >>>> times in the past, precisely to support continuations. >>> >>> Why an attribute? Attributes are on declarations. I think it should better >>> be some pragma like _Pragma(GCC tail cail, foo(x,y)) or some builtin (or >>> else some syntax extension like goto return foo(x,y); ...) because what we >>> really want is to annotate a particular call to be tail-recursive. >> >> C++11 attributes can apply to expression-statements as well, e.g. >> >> [[gnu::tail_call]] fn(); >> >> though not to sub-expressions. > > That's nice. Can they apply to things like loops? > > [[gnu::no_unroll]] for (int i=0; i<4; ++i) > a[i] = 0; Yes, to any statement. Jason