public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] amdgcn: Add stub personality function
@ 2020-04-22 21:10 Kwok Cheung Yeung
  2020-04-23  8:15 ` Andrew Stubbs
  0 siblings, 1 reply; 6+ messages in thread
From: Kwok Cheung Yeung @ 2020-04-22 21:10 UTC (permalink / raw)
  To: GCC Patches, Andrew Stubbs

Hello

This patch adds a stub implementation of __gxx_personality_v0, which is used in 
C++ exception handling. AMD GCN currently does not actually support exception 
handling (the unwind functions are all stubs too), so adding an extra stub 
function does not regress the current level of functionality any. This allows 
the following tests in the libgomp testsuite that were previously failing with a 
linker error to compile and run, provided that they do not throw any exceptions:

libgomp.c-c++-common/function-not-offloaded.c
libgomp.c++/for-15.C
libgomp.c++/for-24.C
libgomp.oacc-c-c++-common/routine-1.c
libgomp.oacc-c++/pr71959.C
libgomp.oacc-c++/routine-1-auto.C
libgomp.oacc-c++/routine-1-template-auto.C
libgomp.oacc-c++/routine-1-template-trailing-return-type.C
libgomp.oacc-c++/routine-1-template.C
libgomp.oacc-c++/routine-1-trailing-return-type.C

Tested with offloaded and standalone builds of GCC for AMD GCN. Okay for trunk?

Kwok

2020-04-22  Kwok Cheung Yeung  <kcy@codesourcery.com>

	libgcc/
	* config/gcn/unwind-gcn.c (__gxx_personality_v0): New.

diff --git a/libgcc/config/gcn/unwind-gcn.c b/libgcc/config/gcn/unwind-gcn.c
index 813f03f..6508b45 100644
--- a/libgcc/config/gcn/unwind-gcn.c
+++ b/libgcc/config/gcn/unwind-gcn.c
@@ -35,3 +35,13 @@ _Unwind_GetIPInfo (struct _Unwind_Context *c, int 
*ip_before_insn)
  {
    return 0;
  }
+
+_Unwind_Reason_Code
+__gxx_personality_v0 (int version,
+		      _Unwind_Action actions,
+		      _Unwind_Exception_Class exception_class,
+		      struct _Unwind_Exception *ue_header,
+		      struct _Unwind_Context *context)
+{
+  return 0;
+}

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

* Re: [PATCH] amdgcn: Add stub personality function
  2020-04-22 21:10 [PATCH] amdgcn: Add stub personality function Kwok Cheung Yeung
@ 2020-04-23  8:15 ` Andrew Stubbs
  2020-04-23 11:05   ` Thomas Schwinge
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Stubbs @ 2020-04-23  8:15 UTC (permalink / raw)
  To: Kwok Cheung Yeung, GCC Patches

On 22/04/2020 22:10, Kwok Cheung Yeung wrote:
> Hello
> 
> This patch adds a stub implementation of __gxx_personality_v0, which is 
> used in C++ exception handling. AMD GCN currently does not actually 
> support exception handling (the unwind functions are all stubs too), so 
> adding an extra stub function does not regress the current level of 
> functionality any. This allows the following tests in the libgomp 
> testsuite that were previously failing with a linker error to compile 
> and run, provided that they do not throw any exceptions:
> 
> libgomp.c-c++-common/function-not-offloaded.c
> libgomp.c++/for-15.C
> libgomp.c++/for-24.C
> libgomp.oacc-c-c++-common/routine-1.c
> libgomp.oacc-c++/pr71959.C
> libgomp.oacc-c++/routine-1-auto.C
> libgomp.oacc-c++/routine-1-template-auto.C
> libgomp.oacc-c++/routine-1-template-trailing-return-type.C
> libgomp.oacc-c++/routine-1-template.C
> libgomp.oacc-c++/routine-1-trailing-return-type.C
> 
> Tested with offloaded and standalone builds of GCC for AMD GCN. Okay for 
> trunk?
> 
> Kwok
> 
> 2020-04-22  Kwok Cheung Yeung  <kcy@codesourcery.com>
> 
>      libgcc/
>      * config/gcn/unwind-gcn.c (__gxx_personality_v0): New.
> 
> diff --git a/libgcc/config/gcn/unwind-gcn.c 
> b/libgcc/config/gcn/unwind-gcn.c
> index 813f03f..6508b45 100644
> --- a/libgcc/config/gcn/unwind-gcn.c
> +++ b/libgcc/config/gcn/unwind-gcn.c
> @@ -35,3 +35,13 @@ _Unwind_GetIPInfo (struct _Unwind_Context *c, int 
> *ip_before_insn)
>   {
>     return 0;
>   }
> +
> +_Unwind_Reason_Code
> +__gxx_personality_v0 (int version,
> +              _Unwind_Action actions,
> +              _Unwind_Exception_Class exception_class,
> +              struct _Unwind_Exception *ue_header,
> +              struct _Unwind_Context *context)
> +{
> +  return 0;
> +}
> 

OK.

Andrew

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

* Re: [PATCH] amdgcn: Add stub personality function
  2020-04-23  8:15 ` Andrew Stubbs
@ 2020-04-23 11:05   ` Thomas Schwinge
  2020-04-23 11:21     ` Kwok Cheung Yeung
  2020-04-29  8:35     ` [gcn] Set 'UI_NONE' for 'TARGET_EXCEPT_UNWIND_INFO' [PR94282] (was: [PATCH] amdgcn: Add stub personality function) Thomas Schwinge
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Schwinge @ 2020-04-23 11:05 UTC (permalink / raw)
  To: Andrew Stubbs, Kwok Cheung Yeung, gcc-patches

Hi!

On 2020-04-23T09:15:29+0100, Andrew Stubbs <ams@codesourcery.com> wrote:
> On 22/04/2020 22:10, Kwok Cheung Yeung wrote:
>> This patch adds a stub implementation of __gxx_personality_v0, which is
>> used in C++ exception handling. AMD GCN currently does not actually
>> support exception handling

So we should simply disable it properly (see below)...

>> (the unwind functions are all stubs too), so
>> adding an extra stub function does not regress the current level of
>> functionality any.

... instead of adding such stub functions.

>> This allows the following tests in the libgomp
>> testsuite that were previously failing with a linker error to compile
>> and run, provided that they do not throw any exceptions:
>>
>> libgomp.c-c++-common/function-not-offloaded.c
>> libgomp.c++/for-15.C
>> libgomp.c++/for-24.C
>> libgomp.oacc-c-c++-common/routine-1.c
>> libgomp.oacc-c++/pr71959.C
>> libgomp.oacc-c++/routine-1-auto.C
>> libgomp.oacc-c++/routine-1-template-auto.C
>> libgomp.oacc-c++/routine-1-template-trailing-return-type.C
>> libgomp.oacc-c++/routine-1-template.C
>> libgomp.oacc-c++/routine-1-trailing-return-type.C

That's <https://gcc.gnu.org/PR94282> "[amdgcn] ld: error: undefined
symbol: __gxx_personality_v0", by the way, so should be referenced in the
ChangeLog.

>> Tested with offloaded and standalone builds of GCC for AMD GCN. Okay for
>> trunk?

>>      libgcc/
>>      * config/gcn/unwind-gcn.c (__gxx_personality_v0): New.

>> --- a/libgcc/config/gcn/unwind-gcn.c
>> +++ b/libgcc/config/gcn/unwind-gcn.c

>> +_Unwind_Reason_Code
>> +__gxx_personality_v0 (int version,
>> +              _Unwind_Action actions,
>> +              _Unwind_Exception_Class exception_class,
>> +              struct _Unwind_Exception *ue_header,
>> +              struct _Unwind_Context *context)
>> +{
>> +  return 0;
>> +}

What does a 'return 0' semantically mean here?  Shouldn't this rather
return some '_URC_*' code -- or even abort (given that we're not
supporting unwinding)?

> OK.

I suggest we instead apply what I'd proposed a month ago in
<https://gcc.gnu.org/PR94282> "[amdgcn] ld: error: undefined symbol:
__gxx_personality_v0", and now yesterday (coincidentally) posted.

    +static enum unwind_info_type
    +gcn_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED)
    +{
    +  return UI_NONE;
    +}

    +#undef  TARGET_EXCEPT_UNWIND_INFO
    +#define TARGET_EXCEPT_UNWIND_INFO gcn_except_unwind_info


Grüße
 Thomas
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

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

* Re: [PATCH] amdgcn: Add stub personality function
  2020-04-23 11:05   ` Thomas Schwinge
@ 2020-04-23 11:21     ` Kwok Cheung Yeung
  2020-04-23 12:15       ` Andrew Stubbs
  2020-04-29  8:35     ` [gcn] Set 'UI_NONE' for 'TARGET_EXCEPT_UNWIND_INFO' [PR94282] (was: [PATCH] amdgcn: Add stub personality function) Thomas Schwinge
  1 sibling, 1 reply; 6+ messages in thread
From: Kwok Cheung Yeung @ 2020-04-23 11:21 UTC (permalink / raw)
  To: Thomas Schwinge, Andrew Stubbs, gcc-patches

On 23/04/2020 12:05 pm, Thomas Schwinge wrote:
> So we should simply disable it properly (see below)...
> 
> ... instead of adding such stub functions.
> 
> 
> I suggest we instead apply what I'd proposed a month ago in
> <https://gcc.gnu.org/PR94282> "[amdgcn] ld: error: undefined symbol:
> __gxx_personality_v0", and now yesterday (coincidentally) posted.
> 
>      +static enum unwind_info_type
>      +gcn_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED)
>      +{
>      +  return UI_NONE;
>      +}
> 
>      +#undef  TARGET_EXCEPT_UNWIND_INFO
>      +#define TARGET_EXCEPT_UNWIND_INFO gcn_except_unwind_info
> 

I agree that not generating the problematic code in the first place is the 
better approach. Does that mean we can now remove libgcc/config/gcn/unwind-gcn.c 
completely?

Thanks

Kwok

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

* Re: [PATCH] amdgcn: Add stub personality function
  2020-04-23 11:21     ` Kwok Cheung Yeung
@ 2020-04-23 12:15       ` Andrew Stubbs
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Stubbs @ 2020-04-23 12:15 UTC (permalink / raw)
  To: Kwok Cheung Yeung, Thomas Schwinge, gcc-patches

On 23/04/2020 12:21, Kwok Cheung Yeung wrote:
> I agree that not generating the problematic code in the first place is 
> the better approach. Does that mean we can now remove 
> libgcc/config/gcn/unwind-gcn.c completely?

That was added for the benefit of libgfortran, not C++. It's used by the 
backtrace code called from the stop handler, among other places, and I 
don't believe there was another workaround for that (without adding 
extra config checks to libgfortran).

I had not got to Thomas's patch yet, so I hadn't noticed they solved the 
same problem.

It probably is better to use Thomas's patch. I'm just worried that it'll 
catch me out when we do implement this stuff, in a way that the stub 
would not.

Andrew

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

* [gcn] Set 'UI_NONE' for 'TARGET_EXCEPT_UNWIND_INFO' [PR94282] (was: [PATCH] amdgcn: Add stub personality function)
  2020-04-23 11:05   ` Thomas Schwinge
  2020-04-23 11:21     ` Kwok Cheung Yeung
@ 2020-04-29  8:35     ` Thomas Schwinge
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Schwinge @ 2020-04-29  8:35 UTC (permalink / raw)
  To: Andrew Stubbs, Kwok Cheung Yeung, gcc-patches

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

Hi!

On 2020-04-23T13:05:33+0200, I wrote:
> On 2020-04-23T09:15:29+0100, Andrew Stubbs <ams@codesourcery.com> wrote:
>> On 22/04/2020 22:10, Kwok Cheung Yeung wrote:
>>> [...] allows the following tests in the libgomp
>>> testsuite that were previously failing with a linker error to compile
>>> and run, provided that they do not throw any exceptions:
>>>
>>> libgomp.c-c++-common/function-not-offloaded.c
>>> libgomp.c++/for-15.C
>>> libgomp.c++/for-24.C
>>> libgomp.oacc-c-c++-common/routine-1.c
>>> libgomp.oacc-c++/pr71959.C
>>> libgomp.oacc-c++/routine-1-auto.C
>>> libgomp.oacc-c++/routine-1-template-auto.C
>>> libgomp.oacc-c++/routine-1-template-trailing-return-type.C
>>> libgomp.oacc-c++/routine-1-template.C
>>> libgomp.oacc-c++/routine-1-trailing-return-type.C
>
> That's <https://gcc.gnu.org/PR94282> "[amdgcn] ld: error: undefined
> symbol: __gxx_personality_v0"

> I suggest we [...] apply what I'd proposed a month ago in
> <https://gcc.gnu.org/PR94282> "[amdgcn] ld: error: undefined symbol:
> __gxx_personality_v0", and now yesterday (coincidentally) posted.

Now pushed to master branch in commit
7f1989249e25af6fc0f124452efa24b3796b767a "[gcn] Set 'UI_NONE' for
'TARGET_EXCEPT_UNWIND_INFO' [PR94282]", see attached.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gcn-Set-UI_NONE-for-TARGET_EXCEPT_UNWIND_INFO-PR9428.patch --]
[-- Type: text/x-diff, Size: 3173 bytes --]

From 7f1989249e25af6fc0f124452efa24b3796b767a Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 21 Apr 2020 22:39:33 +0200
Subject: [PATCH] [gcn] Set 'UI_NONE' for 'TARGET_EXCEPT_UNWIND_INFO' [PR94282]

In libgomp offloading testing, this resolves all the 'ld: error: undefined
symbol: __gxx_personality_v0' FAILs.

	gcc/
	PR target/94282
	* common/config/gcn/gcn-common.c (gcn_except_unwind_info): New
	function.
	(TARGET_EXCEPT_UNWIND_INFO): Define.
	libgomp/
	PR target/94282
	* testsuite/libgomp.c-c++-common/function-not-offloaded.c: Remove
	'dg-allow-blank-lines-in-output'.
---
 gcc/ChangeLog                                            | 7 +++++++
 gcc/common/config/gcn/gcn-common.c                       | 9 +++++++++
 libgomp/ChangeLog                                        | 4 ++++
 .../libgomp.c-c++-common/function-not-offloaded.c        | 1 -
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3321e8839707..2ba39f67200f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2020-04-29  Thomas Schwinge  <thomas@codesourcery.com>
+
+	PR target/94282
+	* common/config/gcn/gcn-common.c (gcn_except_unwind_info): New
+	function.
+	(TARGET_EXCEPT_UNWIND_INFO): Define.
+
 2020-04-29  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/94248
diff --git a/gcc/common/config/gcn/gcn-common.c b/gcc/common/config/gcn/gcn-common.c
index 84a567b2bbbb..9642f9cc5a6c 100644
--- a/gcc/common/config/gcn/gcn-common.c
+++ b/gcc/common/config/gcn/gcn-common.c
@@ -34,4 +34,13 @@ static const struct default_options gcn_option_optimization_table[] =
 #undef  TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE gcn_option_optimization_table
 
+static enum unwind_info_type
+gcn_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED)
+{
+  return UI_NONE;
+}
+
+#undef  TARGET_EXCEPT_UNWIND_INFO
+#define TARGET_EXCEPT_UNWIND_INFO gcn_except_unwind_info
+
 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index cfe6e0653c92..1a7046f2fc64 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,9 @@
 2020-04-29  Thomas Schwinge  <thomas@codesourcery.com>
 
+	PR target/94282
+	* testsuite/libgomp.c-c++-common/function-not-offloaded.c: Remove
+	'dg-allow-blank-lines-in-output'.
+
 	* oacc-init.c (get_openacc_name): Handle 'gcn'.
 	* testsuite/lib/libgomp.exp
 	(offload_target_to_openacc_device_type) [amdgcn*]: Return
diff --git a/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c b/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c
index f01a64e72c07..9e59ef8864e7 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/function-not-offloaded.c
@@ -1,6 +1,5 @@
 /* { dg-do link } */
 /* { dg-excess-errors "unresolved symbol foo, lto1, mkoffload and lto-wrapper fatal errors" { target offload_device_nonshared_as } } */
-/* { dg-allow-blank-lines-in-output 1 } */
 /* { dg-additional-sources "function-not-offloaded-aux.c" } */
 
 #pragma omp declare target
-- 
2.26.2


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

end of thread, other threads:[~2020-04-29  8:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22 21:10 [PATCH] amdgcn: Add stub personality function Kwok Cheung Yeung
2020-04-23  8:15 ` Andrew Stubbs
2020-04-23 11:05   ` Thomas Schwinge
2020-04-23 11:21     ` Kwok Cheung Yeung
2020-04-23 12:15       ` Andrew Stubbs
2020-04-29  8:35     ` [gcn] Set 'UI_NONE' for 'TARGET_EXCEPT_UNWIND_INFO' [PR94282] (was: [PATCH] amdgcn: Add stub personality function) Thomas Schwinge

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