From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65874 invoked by alias); 17 May 2016 21:36:19 -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 65169 invoked by uid 89); 17 May 2016 21:36:18 -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.3 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=kit, continuation X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com From: David Malcolm To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 0/3] Support for mandatory tail calls Date: Fri, 01 Jan 2016 00:00:00 -0000 Message-Id: <1463522492-43504-1-git-send-email-dmalcolm@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 17 May 2016 21:36:06 +0000 (UTC) X-SW-Source: 2016-q2/txt/msg00030.txt.bz2 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. Patch 3 implements the libgccjit.h API support to allow client code to set the flag. [1] https://gcc.gnu.org/ml/jit/2016-q2/msg00010.html David Malcolm (3): Introduce can_implement_as_sibling_call_p Implement CALL_EXPR_MUST_TAIL_CALL jit: implement gcc_jit_rvalue_set_bool_require_tail_call gcc/calls.c | 211 +++++++++++++++++---- gcc/cfgexpand.c | 1 + gcc/gimple-pretty-print.c | 2 + gcc/gimple.c | 1 + gcc/gimple.h | 20 ++ gcc/jit/docs/topics/compatibility.rst | 7 + gcc/jit/docs/topics/expressions.rst | 24 +++ gcc/jit/jit-common.h | 1 + gcc/jit/jit-playback.c | 23 ++- gcc/jit/jit-playback.h | 9 +- gcc/jit/jit-recording.c | 60 ++++-- gcc/jit/jit-recording.h | 46 +++-- gcc/jit/libgccjit.c | 20 ++ gcc/jit/libgccjit.h | 13 ++ gcc/jit/libgccjit.map | 5 + gcc/print-tree.c | 2 +- gcc/testsuite/gcc.dg/plugin/must-tail-call-1.c | 22 +++ gcc/testsuite/gcc.dg/plugin/must-tail-call-2.c | 58 ++++++ .../gcc.dg/plugin/must_tail_call_plugin.c | 76 ++++++++ gcc/testsuite/gcc.dg/plugin/plugin.exp | 3 + gcc/testsuite/jit.dg/all-non-failing-tests.h | 10 + .../jit.dg/test-error-impossible-must-tail-call.c | 93 +++++++++ .../jit.dg/test-factorial-must-tail-call.c | 109 +++++++++++ gcc/tree-core.h | 3 + gcc/tree.h | 5 + 25 files changed, 744 insertions(+), 80 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/plugin/must-tail-call-1.c create mode 100644 gcc/testsuite/gcc.dg/plugin/must-tail-call-2.c create mode 100644 gcc/testsuite/gcc.dg/plugin/must_tail_call_plugin.c create mode 100644 gcc/testsuite/jit.dg/test-error-impossible-must-tail-call.c create mode 100644 gcc/testsuite/jit.dg/test-factorial-must-tail-call.c -- 1.8.5.3