public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Support for mandatory tail calls
@ 2016-01-01  0:00 David Malcolm
  2016-01-01  0:00 ` [PATCH 2/3] Implement CALL_EXPR_MUST_TAIL_CALL David Malcolm
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: David Malcolm @ 2016-01-01  0:00 UTC (permalink / raw)
  To: gcc-patches, jit; +Cc: David Malcolm

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-06-09 21:00 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01  0:00 [PATCH 0/3] Support for mandatory tail calls David Malcolm
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
2016-01-01  0:00 ` [PATCH 0/3] Support for mandatory tail calls 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

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).