diff mbox series

[PR,c++/83667] Fix tree_dump ICE

Message ID 9629705c-8fb0-925a-0119-86af248f9354@acm.org
State New
Headers show
Series [PR,c++/83667] Fix tree_dump ICE | expand

Commit Message

Nathan Sidwell Jan. 3, 2018, 3:58 p.m. UTC
This fixes a tree dumping ICE involving static thunk fns.  Copying the 
thunked-to fn's context suffices.

nathan

Comments

Rainer Orth Jan. 4, 2018, 8:55 a.m. UTC | #1
Hi Nathan,

> This fixes a tree dumping ICE involving static thunk fns.  Copying the
> thunked-to fn's context suffices.

the new test FAILs on Solaris/SPARC:

FAIL: g++.dg/ipa/pr83667.C  -std=gnu++11  scan-ipa-dump inline "summary for void c::\\\\*.LTHUNK0"
FAIL: g++.dg/ipa/pr83667.C  -std=gnu++14  scan-ipa-dump inline "summary for void c::\\\\*.LTHUNK0"
FAIL: g++.dg/ipa/pr83667.C  -std=gnu++98  scan-ipa-dump inline "summary for void c::\\\\*.LTHUNK0"

The dump has

IPA function summary for void c::*.LLTHUNK0(...)/1

instead.

	Rainer
Jakub Jelinek Jan. 4, 2018, 9:07 a.m. UTC | #2
On Thu, Jan 04, 2018 at 09:55:10AM +0100, Rainer Orth wrote:
> Hi Nathan,
> 
> > This fixes a tree dumping ICE involving static thunk fns.  Copying the
> > thunked-to fn's context suffices.
> 
> the new test FAILs on Solaris/SPARC:
> 
> FAIL: g++.dg/ipa/pr83667.C  -std=gnu++11  scan-ipa-dump inline "summary for void c::\\\\*.LTHUNK0"
> FAIL: g++.dg/ipa/pr83667.C  -std=gnu++14  scan-ipa-dump inline "summary for void c::\\\\*.LTHUNK0"
> FAIL: g++.dg/ipa/pr83667.C  -std=gnu++98  scan-ipa-dump inline "summary for void c::\\\\*.LTHUNK0"
> 
> The dump has
> 
> IPA function summary for void c::*.LLTHUNK0(...)/1

Note, it will also fail on all targets where
TARGET_USE_LOCAL_THUNK_ALIAS_P isn't true.

The reason it fails on solaris/sparc is:
#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)   \
  sprintf ((LABEL), "*.L%s%lu", (PREFIX), (unsigned long)(NUM))
where it adds yet another L, unlike say standard config/elfos.h
#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)         \
  do                                                            \
    {                                                           \
      char *__p;                                                \
      (LABEL)[0] = '*';                                         \
      (LABEL)[1] = '.';                                         \
      __p = stpcpy (&(LABEL)[2], PREFIX);                       \
      sprint_ul (__p, (unsigned long) (NUM));                   \
    }                                                           \
  while (0)

Perhaps guard the test with a couple of selected targets known to
have TARGET_USE_LOCAL_THUNK_ALIAS_P support as well as standard elfos.h
ASM_GENERATE_INTERNAL_LABEL ?

	Jakub
Nathan Sidwell Jan. 4, 2018, 3:02 p.m. UTC | #3
On 01/04/2018 03:55 AM, Rainer Orth wrote:
> Hi Nathan,
> 
>> This fixes a tree dumping ICE involving static thunk fns.  Copying the
>> thunked-to fn's context suffices.
> 

> The dump has
> 
> IPA function summary for void c::*.LLTHUNK0(...)/1

thanks.

does this patch work for you?

nathan
Rainer Orth Jan. 4, 2018, 3:40 p.m. UTC | #4
Hi Nathan,

> On 01/04/2018 03:55 AM, Rainer Orth wrote:
>> Hi Nathan,
>>
>>> This fixes a tree dumping ICE involving static thunk fns.  Copying the
>>> thunked-to fn's context suffices.
>>
>
>> The dump has
>>
>> IPA function summary for void c::*.LLTHUNK0(...)/1
>
> thanks.
>
> does this patch work for you?

worked like a charm on both sparc-sun-solaris2.11 and i386-pc-solaris2.11.

Thanks.
        Rainer
diff mbox series

Patch

2018-01-03  Nathan Sidwell  <nathan@acm.org>

	PR c++/83667
	* method.c (make_alias_for): Copy DECL_CONTEXT.

	PR c++/83667
	* g++.dg/ipa/pr83667.C: New.

Index: cp/method.c
===================================================================
--- cp/method.c	(revision 256175)
+++ cp/method.c	(working copy)
@@ -206,7 +206,7 @@  make_alias_for (tree target, tree newid)
 			   TREE_CODE (target), newid, TREE_TYPE (target));
   DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (target);
   cxx_dup_lang_specific_decl (alias);
-  DECL_CONTEXT (alias) = NULL;
+  DECL_CONTEXT (alias) = DECL_CONTEXT (target);
   TREE_READONLY (alias) = TREE_READONLY (target);
   TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (target);
   TREE_PUBLIC (alias) = 0;
Index: testsuite/g++.dg/ipa/pr83667.C
===================================================================
--- testsuite/g++.dg/ipa/pr83667.C	(revision 0)
+++ testsuite/g++.dg/ipa/pr83667.C	(working copy)
@@ -0,0 +1,23 @@ 
+/* { dg-options "-fdump-ipa-inline" } */
+// c++/83667 ICE dumping a static thunk
+
+struct a
+{
+  virtual ~a ();
+};
+
+struct b
+{
+  virtual void d (...);
+};
+
+struct c : a, b
+{
+  void d (...)
+  {
+  }
+};
+
+c c;
+
+// { dg-final { scan-ipa-dump "summary for void c::\\*.LTHUNK0" "inline" } }