From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 0/3] Support for mandatory tail calls
Date: Fri, 01 Jan 2016 00:00:00 -0000 [thread overview]
Message-ID: <1463522492-43504-1-git-send-email-dmalcolm@redhat.com> (raw)
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
next reply other threads:[~2016-05-17 21:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-01 0:00 David Malcolm [this message]
2016-01-01 0:00 ` Jeff Law
2016-01-01 0:00 ` Basile Starynkevitch
2016-01-01 0:00 ` Jason Merrill
2016-01-01 0:00 ` Richard Biener
2016-01-01 0:00 ` Jason Merrill
2016-01-01 0:00 ` [PATCH 2/3] Implement CALL_EXPR_MUST_TAIL_CALL David Malcolm
2016-01-01 0:00 ` Jeff Law
2016-01-01 0:00 ` Andreas Schwab
2016-01-01 0:00 ` Andreas Schwab
2016-01-01 0:00 ` [PATCH] Fixes to must-tail-call tests David Malcolm
2016-01-01 0:00 ` Rainer Orth
2016-01-01 0:00 ` Thomas Preudhomme
2016-01-01 0:00 ` David Malcolm
2016-01-01 0:00 ` Jeff Law
2016-01-01 0:00 ` [PATCH 1/3] Introduce can_implement_as_sibling_call_p David Malcolm
2016-01-01 0:00 ` Kyrill Tkachov
2016-01-01 0:00 ` [PATCH] calls.c: fix warning on targets without REG_PARM_STACK_SPACE David Malcolm
2016-01-01 0:00 ` [PATCH 1/3] Introduce can_implement_as_sibling_call_p Jeff Law
2016-01-01 0:00 ` [PATCH 3/3] jit: implement gcc_jit_rvalue_set_bool_require_tail_call David Malcolm
2016-01-01 0:00 ` Trevor Saunders
2016-01-01 0:00 ` David Malcolm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463522492-43504-1-git-send-email-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jit@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).