public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA encode_section_info (PR bootstrap/34003)
@ 2007-12-14 19:07 Jakub Jelinek
  2007-12-14 19:18 ` John David Anglin
  2007-12-15 23:14 ` Joseph S. Myers
  0 siblings, 2 replies; 5+ messages in thread
From: Jakub Jelinek @ 2007-12-14 19:07 UTC (permalink / raw)
  To: Joseph Myers, John David Anglin; +Cc: gcc-patches

Hi!

Dan's tree union reorganization patch
http://gcc.gnu.org/ml/gcc-patches/2005-06/msg02029.html
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.674&r2=1.675
removed COPY_DECL_RTL in C merge_decls, so now duplicate_decls always throws
rtls on the floor and leaves them to be recreated again if needed.
I didn't find any such intent in that patch.  merge_decls still has
  /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
     so that encode_section_info has a chance to look at the new decl
     flags and attributes.  */
  if (DECL_RTL_SET_P (olddecl)
      && (TREE_CODE (olddecl) == FUNCTION_DECL
          || (TREE_CODE (olddecl) == VAR_DECL
              && TREE_STATIC (olddecl))))
    make_decl_rtl (olddecl);
chunk at the end, but because of the missed COPY_DECL_RTL and as
this is after memcpy from newdecl to olddecl, this can't ever hit
(DECL_RTL_SET_P will be always false).  While for most targets this
is just an compile time pessimization, the rtl needs to be recreated,
on PA with its SYMBOL_FLAG_REFERENCED it means that flag is lost during
this and so in -fno-unit-at-a-time
extern void foo (void);
int bar (void) { foo (); return 1; }
extern void foo (void);
foo is not considered referenced, which leads to .IMPORT foo,CODE directive
omission, and leads to linker errors.  So, gcc-4.3 can't be bootstrapped
with gcc-4.3 on hppa-hpux, because first stage is built at -O0.  In addition
to the c-decl.c fix I had to also fix pa_encode_section_info to preserve
that flag if !first.

I have bootstrapped/regtested this on x86_64-linux and i686-linux, ok for
trunk if somebody (Dave, the reporter, ...) tests it on hppa-hpux?

2007-12-14  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/34003
	* c-decl.c (merge_decls): Copy RTL from olddecl to newdecl.
	* config/pa/pa.c (pa_encode_section_info): If !first, preserve
	SYMBOL_FLAG_REFERENCED flag.

	* gcc.dg/pr34003-1.c: New test.
	* gcc.dg/pr34003-2.c: New.

--- gcc/c-decl.c.jj	2007-11-26 22:14:08.000000000 +0100
+++ gcc/c-decl.c	2007-12-13 20:11:33.000000000 +0100
@@ -1670,6 +1670,9 @@ merge_decls (tree newdecl, tree olddecl,
 	}
     }
 
+  /* Keep the old rtl since we can safely use it.  */
+  if (HAS_RTL_P (olddecl))
+    COPY_DECL_RTL (olddecl, newdecl);
 
   /* Merge the type qualifiers.  */
   if (TREE_READONLY (newdecl))
--- gcc/config/pa/pa.c.jj	2007-12-13 18:56:21.000000000 +0100
+++ gcc/config/pa/pa.c	2007-12-13 20:32:04.000000000 +0100
@@ -7834,6 +7834,12 @@ hppa_encode_label (rtx sym)
 static void
 pa_encode_section_info (tree decl, rtx rtl, int first)
 {
+  int old_referenced = 0;
+
+  if (!first && MEM_P (rtl) && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF)
+    old_referenced
+      = SYMBOL_REF_FLAGS (XEXP (rtl, 0)) & SYMBOL_FLAG_REFERENCED;
+
   default_encode_section_info (decl, rtl, first);
 
   if (first && TEXT_SPACE_P (decl))
@@ -7842,6 +7848,8 @@ pa_encode_section_info (tree decl, rtx r
       if (TREE_CODE (decl) == FUNCTION_DECL)
 	hppa_encode_label (XEXP (rtl, 0));
     }
+  else if (old_referenced)
+    SYMBOL_REF_FLAGS (XEXP (rtl, 0)) |= old_referenced;
 }
 
 /* This is sort of inverse to pa_encode_section_info.  */
--- gcc/testsuite/gcc.dg/pr34003-1.c.jj	2007-12-13 21:07:51.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr34003-1.c	2007-12-13 21:07:15.000000000 +0100
@@ -0,0 +1,8 @@
+/* PR bootstrap/34003 */
+/* { dg-do link } */
+/* { dg-options "-O0" } */
+/* { dg-additional-sources "pr34003-2.c" } */
+
+extern void foo (void);
+int bar (void) { foo (); return 1; }
+extern void foo (void);
--- gcc/testsuite/gcc.dg/pr34003-2.c.jj	2007-12-13 21:07:59.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr34003-2.c	2007-12-13 21:09:35.000000000 +0100
@@ -0,0 +1,20 @@
+/* PR bootstrap/34003 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+extern void abort (void);
+
+int seen = 0;
+
+void foo (void)
+{
+  ++seen;
+}
+
+int main (void)
+{
+  extern int bar (void);
+  if (bar () != 1 || seen != 1)
+    abort ();
+  return 0;
+}

	Jakub

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

* Re: [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA encode_section_info (PR bootstrap/34003)
  2007-12-14 19:07 [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA encode_section_info (PR bootstrap/34003) Jakub Jelinek
@ 2007-12-14 19:18 ` John David Anglin
  2007-12-15 23:14 ` Joseph S. Myers
  1 sibling, 0 replies; 5+ messages in thread
From: John David Anglin @ 2007-12-14 19:18 UTC (permalink / raw)
  To: jakub; +Cc: joseph, gcc-patches

> I have bootstrapped/regtested this on x86_64-linux and i686-linux, ok for
> trunk if somebody (Dave, the reporter, ...) tests it on hppa-hpux?

Testing is almost complete on hppa2.0w-hp-hpux11.11.  Compared to
yesterdays build, I see the following new testsuite fails:

FAIL: gcc.dg/struct/wo_prof_global_var.c execution test
FAIL: gcc.dg/struct/wo_prof_local_var.c execution test
FAIL: gcc.dg/struct/wo_prof_two_strs.c (internal compiler error)
FAIL: gcc.dg/struct/wo_prof_two_strs.c (test for excess errors)
WARNING: gcc.dg/struct/wo_prof_two_strs.c compilation failed to produce executable
FAIL: gcc.dg/struct/wo_prof_two_strs.c scan-ipa-dump ipa_struct_reorg "Number of structures to transform is 2"
FAIL: gcc.dg/struct/w_prof_global_var.c execution,    -O3 -fwhole-program -combine -fipa-type-escape -fprofile-use -fipa-struct-reorg -fdump-ipa-all
FAIL: gcc.dg/struct/w_prof_local_var.c execution,    -O3 -fwhole-program -combine -fipa-type-escape -fprofile-use -fipa-struct-reorg -fdump-ipa-all
FAIL: gcc.dg/struct/w_prof_two_strs.c compilation,  -O3 -fwhole-program -combine -fipa-type-escape -fprofile-use -fipa-struct-reorg -fdump-ipa-all (internal compiler error)

These fails appear unrelated.  Testing failed on hppa-unknown-linux-gnu
due to a new ada bug.  On the positive side, the two new tests in the
patch pass.  So, the PA part to preserve the flag is ok.

I'm thinking I also want to remove the double deferral.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

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

* Re: [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA  encode_section_info (PR bootstrap/34003)
  2007-12-14 19:07 [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA encode_section_info (PR bootstrap/34003) Jakub Jelinek
  2007-12-14 19:18 ` John David Anglin
@ 2007-12-15 23:14 ` Joseph S. Myers
  2007-12-15 23:43   ` [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA John David Anglin
  1 sibling, 1 reply; 5+ messages in thread
From: Joseph S. Myers @ 2007-12-15 23:14 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: John David Anglin, gcc-patches

On Fri, 14 Dec 2007, Jakub Jelinek wrote:

> 2007-12-14  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR bootstrap/34003
> 	* c-decl.c (merge_decls): Copy RTL from olddecl to newdecl.

The C front-end change is OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA
  2007-12-15 23:14 ` Joseph S. Myers
@ 2007-12-15 23:43   ` John David Anglin
  2007-12-15 23:58     ` Joseph S. Myers
  0 siblings, 1 reply; 5+ messages in thread
From: John David Anglin @ 2007-12-15 23:43 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: jakub, gcc-patches

> On Fri, 14 Dec 2007, Jakub Jelinek wrote:
> 
> > 2007-12-14  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	PR bootstrap/34003
> > 	* c-decl.c (merge_decls): Copy RTL from olddecl to newdecl.
> 
> The C front-end change is OK.

Since this is a regression, would the same change be ok on the 4.2
branch?  I will test it.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

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

* Re: [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA
  2007-12-15 23:43   ` [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA John David Anglin
@ 2007-12-15 23:58     ` Joseph S. Myers
  0 siblings, 0 replies; 5+ messages in thread
From: Joseph S. Myers @ 2007-12-15 23:58 UTC (permalink / raw)
  To: John David Anglin; +Cc: jakub, gcc-patches

On Sat, 15 Dec 2007, John David Anglin wrote:

> > On Fri, 14 Dec 2007, Jakub Jelinek wrote:
> > 
> > > 2007-12-14  Jakub Jelinek  <jakub@redhat.com>
> > > 
> > > 	PR bootstrap/34003
> > > 	* c-decl.c (merge_decls): Copy RTL from olddecl to newdecl.
> > 
> > The C front-end change is OK.
> 
> Since this is a regression, would the same change be ok on the 4.2
> branch?  I will test it.

Yes, it would be OK for 4.2 branch as well if it fixes the regression 
there.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

end of thread, other threads:[~2007-12-15 23:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-14 19:07 [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA encode_section_info (PR bootstrap/34003) Jakub Jelinek
2007-12-14 19:18 ` John David Anglin
2007-12-15 23:14 ` Joseph S. Myers
2007-12-15 23:43   ` [PATCH] Don't throw away DECL_RTL in C merge_decls, fix PA John David Anglin
2007-12-15 23:58     ` Joseph S. Myers

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