From 77e0a97acf7b00c1e68e4738fdf275a4cffc2e50 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 2 Aug 2018 15:59:01 +0000 Subject: [PATCH] [nvptx] Ignore c++ exceptions 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. This patch does not enable exceptions for nvptx, it merely allows c++ programs to run correctly if they do no use exception handling. Build and reg-tested on x86_64 with nvptx accelerator. 2018-08-02 Tom de Vries PR target/86660 * common/config/nvptx/nvptx-common.c (nvptx_except_unwind_info): New function. Return UI_TARGET unconditionally. (TARGET_EXCEPT_UNWIND_INFO): Redefine to nvptx_except_unwind_info. * config/nvptx/nvptx.c (TARGET_ASM_BYTE_OP): Emit commented out '.byte'. * testsuite/libgomp.oacc-c++/routine-1-auto.C: Remove -fno-exceptions. * testsuite/libgomp.oacc-c++/routine-1-template-auto.C: Same. * testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C: Same. * testsuite/libgomp.oacc-c++/routine-1-template.C: Same. * testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C: Same. * testsuite/libgomp.oacc-c-c++-common/routine-1.c: Same. From-SVN: r263265 --- gcc/ChangeLog | 8 ++++++++ gcc/common/config/nvptx/nvptx-common.c | 9 +++++++++ gcc/config/nvptx/nvptx.c | 3 +++ libgomp/ChangeLog | 11 +++++++++++ libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C | 2 -- .../libgomp.oacc-c++/routine-1-template-auto.C | 2 -- .../routine-1-template-trailing-return-type.C | 2 -- .../testsuite/libgomp.oacc-c++/routine-1-template.C | 2 -- .../libgomp.oacc-c++/routine-1-trailing-return-type.C | 2 -- .../testsuite/libgomp.oacc-c-c++-common/routine-1.c | 2 -- 10 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be8ba03f9df..4a6ef9207d0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-08-02 Tom de Vries + + PR target/86660 + * common/config/nvptx/nvptx-common.c (nvptx_except_unwind_info): New + function. Return UI_TARGET unconditionally. + (TARGET_EXCEPT_UNWIND_INFO): Redefine to nvptx_except_unwind_info. + * config/nvptx/nvptx.c (TARGET_ASM_BYTE_OP): Emit commented out '.byte'. + 2018-08-02 Richard Sandiford * genemit.c (print_overload_test): Fix typo. diff --git a/gcc/common/config/nvptx/nvptx-common.c b/gcc/common/config/nvptx/nvptx-common.c index 27a4f4675d0..f31e0696281 100644 --- a/gcc/common/config/nvptx/nvptx-common.c +++ b/gcc/common/config/nvptx/nvptx-common.c @@ -30,10 +30,19 @@ along with GCC; see the file COPYING3. If not see #include "opts.h" #include "flags.h" +enum unwind_info_type +nvptx_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED) +{ + return UI_TARGET; +} + #undef TARGET_HAVE_NAMED_SECTIONS #define TARGET_HAVE_NAMED_SECTIONS false #undef TARGET_DEFAULT_TARGET_FLAGS #define TARGET_DEFAULT_TARGET_FLAGS MASK_ABI64 +#undef TARGET_EXCEPT_UNWIND_INFO +#define TARGET_EXCEPT_UNWIND_INFO nvptx_except_unwind_info + struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index c0b0a2ec3ab..62fefda8612 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -6051,6 +6051,9 @@ 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/libgomp/ChangeLog b/libgomp/ChangeLog index 1a361337f90..a44dc7c90d0 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,14 @@ +2018-08-02 Tom de Vries + + PR target/86660 + * testsuite/libgomp.oacc-c++/routine-1-auto.C: Remove -fno-exceptions. + * testsuite/libgomp.oacc-c++/routine-1-template-auto.C: Same. + * testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C: + Same. + * testsuite/libgomp.oacc-c++/routine-1-template.C: Same. + * testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C: Same. + * testsuite/libgomp.oacc-c-c++-common/routine-1.c: Same. + 2018-08-01 Cesar Philippidis Thomas Schwinge diff --git a/libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C b/libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C index f4b54e55fa7..771a2734306 100644 --- a/libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C +++ b/libgomp/testsuite/libgomp.oacc-c++/routine-1-auto.C @@ -1,7 +1,5 @@ // Routine with "auto" return type. -// { dg-additional-options "-fno-exceptions" } - #define TEMPLATE #define TYPE int #define RETURN_1 auto diff --git a/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-auto.C b/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-auto.C index 444f1f32a76..17bdaa0c1c1 100644 --- a/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-auto.C +++ b/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-auto.C @@ -1,7 +1,5 @@ // Templated routine with "auto" return type. -// { dg-additional-options "-fno-exceptions" } - #define TEMPLATE template #define RETURN_1 auto #define RETURN_2 diff --git a/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C b/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C index bfe2787d931..99faa865041 100644 --- a/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C +++ b/libgomp/testsuite/libgomp.oacc-c++/routine-1-template-trailing-return-type.C @@ -1,7 +1,5 @@ // Templated routine using trailing return type syntax. -// { dg-additional-options "-fno-exceptions" } - #define TEMPLATE template #define RETURN_1 auto #define RETURN_2 -> TYPE diff --git a/libgomp/testsuite/libgomp.oacc-c++/routine-1-template.C b/libgomp/testsuite/libgomp.oacc-c++/routine-1-template.C index a7e0323d44f..89defb196b1 100644 --- a/libgomp/testsuite/libgomp.oacc-c++/routine-1-template.C +++ b/libgomp/testsuite/libgomp.oacc-c++/routine-1-template.C @@ -1,7 +1,5 @@ // Templated routine. -// { dg-additional-options "-fno-exceptions" } - #define TEMPLATE template #define RETURN_1 TYPE #define RETURN_2 diff --git a/libgomp/testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C b/libgomp/testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C index 3074ba47c2a..767e0ce4666 100644 --- a/libgomp/testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C +++ b/libgomp/testsuite/libgomp.oacc-c++/routine-1-trailing-return-type.C @@ -1,7 +1,5 @@ // Routine using trailing return type syntax. -// { dg-additional-options "-fno-exceptions" } - #define TEMPLATE #define TYPE int #define RETURN_1 auto diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c index 2a36b3b1fac..0f70e264240 100644 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c @@ -1,5 +1,3 @@ -// { dg-additional-options "-fno-exceptions" } - // Defaults, if not "#include"d from ../libgomp.oacc-c++/routine-1-*.C. #ifndef TEMPLATE # define TEMPLATE -- 2.30.2