[c++] Don't emit exception tables for UI_NONE

Message ID 20180803094531.4ea4ao6mriam5nv2@delia
State New
Headers show
Series
  • [c++] Don't emit exception tables for UI_NONE
Related show

Commit Message

Tom de Vries Aug. 3, 2018, 9:45 a.m.
[ was: Re: [PATCH][nvptx] Ignore c++ exceptions ]

On Thu, Aug 02, 2018 at 06:10:50PM +0200, Tom de Vries wrote:
> On 08/02/2018 05:39 PM, Jakub Jelinek wrote:
> > On Thu, Aug 02, 2018 at 05:30:53PM +0200, Tom de Vries wrote:
> >> The nvptx port can't support exceptions using sjlj, because ptx does not
> >> support sjlj.  However, default_except_unwind_info still returns UI_SJLJ, even
> >> even if we configure with --disable-sjlj-exceptions, because UI_SJLJ is the
> >> fallback option.
> >>
> >> The reason default_except_unwind_info doesn't return UI_DWARF2 is because
> >> DWARF2_UNWIND_INFO is not defined in defaults.h, because
> >> INCOMING_RETURN_ADDR_RTX is not defined, because there's no ptx equivalent.
> >>
> >> Testcase libgomp.c++/for-15.C currently doesn't compile unless fno-exceptions
> >> is added because:
> >> - it tries to generate sjlj exception handling code, and
> >> - it tries to generate exception tables using label-addressed .byte sequence.
> >>   Ptx doesn't support generating random data at a label, nor being able to
> >>   load/write data relative to a label.
> >>
> >> This patch fixes the first problem by using UI_TARGET for nvptx.
> >>
> >> The second problem is worked around by generating all .byte sequences commented
> >> out.  It would be better to have a narrower workaround, and define
> >> TARGET_ASM_BYTE_OP to "error: .byte unsupported " or some such.
> > 
> > Hopefully this part is temporary and there is some way to figure this out
> > later.
> > 
> 
> I except that for UI_NONE we don't want to write out exception tables,
> so that's something we can fix, and then we can return UI_NONE in
> nvptx_except_unwind_info.
> 

Hi,

If a target does not support exceptions, it can indicate this by returning
UI_NONE in TARGET_EXCEPT_UNWIND_INFO.  Currently the compiler still emits
exception tables for such a target.

This patch makes sure that no exception tables are emitted if the target does
not support exceptions.  This allows us to remove a workaround in
TARGET_ASM_BYTE_OP in the nvptx port.

Build on x86_64 with nvptx accelerator, and tested libgomp.

OK for trunk if currently running bootstrap and reg-test on x86_64 succeeds?

Thanks,
- Tom

[c++] Don't emit exception tables for UI_NONE

2018-08-03  Tom de Vries  <tdevries@suse.de>

	* common/config/nvptx/nvptx-common.c (nvptx_except_unwind_info): Return
	UI_NONE.
	* config/nvptx/nvptx.c (TARGET_ASM_BYTE_OP): Remove define.
	* except.c (output_function_exception_table): Do early exit if
	targetm_common.except_unwind_info (&global_options) == UI_NONE.

---
 gcc/common/config/nvptx/nvptx-common.c | 2 +-
 gcc/config/nvptx/nvptx.c               | 3 ---
 gcc/except.c                           | 3 ++-
 3 files changed, 3 insertions(+), 5 deletions(-)

Comments

Jakub Jelinek Aug. 3, 2018, 9:52 a.m. | #1
On Fri, Aug 03, 2018 at 11:45:31AM +0200, Tom de Vries wrote:
> If a target does not support exceptions, it can indicate this by returning
> UI_NONE in TARGET_EXCEPT_UNWIND_INFO.  Currently the compiler still emits
> exception tables for such a target.
> 
> This patch makes sure that no exception tables are emitted if the target does
> not support exceptions.  This allows us to remove a workaround in
> TARGET_ASM_BYTE_OP in the nvptx port.
> 
> Build on x86_64 with nvptx accelerator, and tested libgomp.
> 
> OK for trunk if currently running bootstrap and reg-test on x86_64 succeeds?

LGTM (for UI_NONE there is no personality function either, so nothing to
decode .gcc_except_table ...).

> 2018-08-03  Tom de Vries  <tdevries@suse.de>
> 
> 	* common/config/nvptx/nvptx-common.c (nvptx_except_unwind_info): Return
> 	UI_NONE.
> 	* config/nvptx/nvptx.c (TARGET_ASM_BYTE_OP): Remove define.
> 	* except.c (output_function_exception_table): Do early exit if
> 	targetm_common.except_unwind_info (&global_options) == UI_NONE.

	Jakub

Patch

diff --git a/gcc/common/config/nvptx/nvptx-common.c b/gcc/common/config/nvptx/nvptx-common.c
index f31e0696281..3a124e8844d 100644
--- a/gcc/common/config/nvptx/nvptx-common.c
+++ b/gcc/common/config/nvptx/nvptx-common.c
@@ -33,7 +33,7 @@  along with GCC; see the file COPYING3.  If not see
 enum unwind_info_type
 nvptx_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED)
 {
-  return UI_TARGET;
+  return UI_NONE;
 }
 
 #undef TARGET_HAVE_NAMED_SECTIONS
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 62fefda8612..c0b0a2ec3ab 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -6051,9 +6051,6 @@  nvptx_can_change_mode_class (machine_mode, machine_mode, reg_class_t)
 #undef TARGET_HAVE_SPECULATION_SAFE_VALUE
 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
 
-#undef TARGET_ASM_BYTE_OP
-#define TARGET_ASM_BYTE_OP "// .byte "
-
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-nvptx.h"
diff --git a/gcc/except.c b/gcc/except.c
index 84666d9041e..728b1e1d349 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -3189,7 +3189,8 @@  output_function_exception_table (int section)
   rtx personality = get_personality_function (current_function_decl);
 
   /* Not all functions need anything.  */
-  if (!crtl->uses_eh_lsda)
+  if (!crtl->uses_eh_lsda
+      || targetm_common.except_unwind_info (&global_options) == UI_NONE)
     return;
 
   /* No need to emit any boilerplate stuff for the cold part.  */