public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: Restore functional DONT_USE_BUILTIN_SETJMP support
Date: Sun, 08 Oct 2017 10:57:00 -0000	[thread overview]
Message-ID: <2067154.q9SCchci8G@polaris> (raw)

[-- Attachment #1: Type: text/plain, Size: 963 bytes --]

DONT_USE_BUILTIN_SETJMP is an old configuration macro that instructs the 
compiler to use the usual setjmp/longjmp routines instead of their built-in 
variants to implement SJLJ exceptions.  It's less efficient but, sometimes, 
the setjmp/longjmp routines have specific features that cannot be easily 
implemented by the built-in.  Only IA-64 and Aarch64 define it.

The support is currently broken at compile time (because of a broken CFG) and 
at link time (an unresolved symbol).  The attached small patch restores it.

Bootstrapped & tested on Aarch64/Linux with --enable-sjlj-exceptions, applied 
on the mainline as obvious.


2017-10-07  Eric Botcazou  <ebotcazou@adacore.com>

	* builtins.def (BUILT_IN_SETJMP): Declare as library builtin instead
	of GCC builtin if DONT_USE_BUILTIN_SETJMP is defined.
	* except.c (sjlj_emit_function_enter): If DONT_USE_BUILTIN_SETJMP is
	defined, force the creation of a new block for a dispatch label.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 2096 bytes --]

Index: builtins.def
===================================================================
--- builtins.def	(revision 253506)
+++ builtins.def	(working copy)
@@ -890,7 +890,11 @@ DEF_LIB_BUILTIN        (BUILT_IN_REALLOC
 DEF_GCC_BUILTIN        (BUILT_IN_RETURN, "return", BT_FN_VOID_PTR, ATTR_NORETURN_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UINT, ATTR_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL)
+#ifdef DONT_USE_BUILTIN_SETJMP
+DEF_LIB_BUILTIN        (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_RT_NOTHROW_LEAF_LIST)
+#else
 DEF_GCC_BUILTIN        (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_RT_NOTHROW_LEAF_LIST)
+#endif
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_NOTHROW_3_4)
 DEF_LIB_BUILTIN        (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_TM_PTR, ATTR_FORMAT_STRFTIME_NOTHROW_3_0)
 DEF_GCC_BUILTIN        (BUILT_IN_TRAP, "trap", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LEAF_COLD_LIST)
Index: except.c
===================================================================
--- except.c	(revision 253506)
+++ except.c	(working copy)
@@ -1209,6 +1209,28 @@ sjlj_emit_function_enter (rtx_code_label
 	  fn_begin_outside_block = false;
       }
 
+#ifdef DONT_USE_BUILTIN_SETJMP
+  if (dispatch_label)
+    {
+      /* The sequence contains a branch in the middle so we need to force
+	 the creation of a new basic block by means of BB_SUPERBLOCK.  */
+      if (fn_begin_outside_block)
+	{
+	  basic_block bb
+	    = split_edge (single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+	  if (JUMP_P (BB_END (bb)))
+	    emit_insn_before (seq, BB_END (bb));
+	  else
+	    emit_insn_after (seq, BB_END (bb));
+	}
+      else
+	emit_insn_after (seq, fn_begin);
+
+      single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))->flags |= BB_SUPERBLOCK;
+      return;
+    }
+#endif
+
   if (fn_begin_outside_block)
     insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
   else

             reply	other threads:[~2017-10-07 22:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-08 10:57 Eric Botcazou [this message]
2017-10-08 14:18 ` Andreas Schwab
2017-10-09  2:13   ` Joseph Myers
2017-10-08 16:38 ` Andreas Schwab
2017-10-08 20:52   ` Eric Botcazou
2017-10-09 22:56     ` Eric Botcazou
2017-10-10  8:44 Dominique d'Humières
2017-10-10 10:34 ` Eric Botcazou
2017-10-10 10:57   ` Dominique d'Humières
2017-10-10 11:59     ` Eric Botcazou

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=2067154.q9SCchci8G@polaris \
    --to=ebotcazou@adacore.com \
    --cc=gcc-patches@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).