Package: gcc-3.3
Version: 1:3.3.4-13
Tags: patch

This was sent to debian-ia64, I'm filing the appropriate bugs for it.
Including this patch would be a great help.

----- Forwarded message from David Mosberger <[EMAIL PROTECTED]> -----

I have grown increasingly concerned that even with the current
Debian/unstable, there are several failures reported by "make check"
in libunwind.  This is disappointing because most of the necessary
toolchain/libc fixes have been out there for a long time but things
just haven't moved far along enough yet for Debian to pick them up in
the normal course of syncing with upstream.  To make matters worse, I
recently found on a SuSE 9 system that even with the existing fixes in
place, there were two other unwind-related bugs in GCC.  Those have
been fixed in upstream now and as of now, there are no known
unwind-related bugs left.  Thus, it would be really good to get the
Debian toolchain in sync.  Since Debian won't upgrade to gcc-3.4 and
the latest libc over night, I thought I'd spend the effort to backport
the minimal fixes to get things working right.  The result is the 3
patches below, which fix, respectively, GCC v3.3, libc6.1, and
binutils.

Now the problem is that I'd really need help to get these patches
integrated into Debian.  Any help in that direction would be greatly
appreciated (especially since I'll be distracted with my move back to
California over the next few days).

In terms of the safety of these patches: they all have been checked
into the mainline CVS trees and most have been there for months.  I'm
convinced they're all safe for ia64 and even more so for all other
arches (since they're for the most part 100% unaffected).  So really
hope that these could be merged quickly.  Of course, I'd be happy to
answer any questions in case something comes up.

Also, it would be good if GCC on ia64 could be built against
libunwind.  To do so, we'd probably want to make sure that Debian has
libunwind v0.98.2 (which I'll release next week and contains just two
minor bug fixes vs. v0.98.1) installed when building GCC and glibc.
The rest should be automatic.

With the patches below installed, "make check" in libunwind completes
without failures.  Also, I single-stepped a test-program
(test-ptrace-misc) from beginning to end, unwinding after each
instruction and no failures where detected!  Also, the GCC patches
fixes the 2 remaining unexpected libjava in GCC 3.3.5 (with no other
changes), so I really do think this gets Debian/ia64 into much better
shape.

Anybody willing to help getting these into Debian?

        --david


Content-Description: GCC fixes
 config/ia64/crtbegin.asm |   22 ++++++++++++++++------
 config/ia64/crtend.asm   |    4 ++++
 config/ia64/ia64.c       |   36 +++++++++++++++++++++++++-----------
 emit-rtl.c               |    5 +++++
 gcc.c                    |    3 +++
 5 files changed, 53 insertions(+), 17 deletions(-)

diff -urN orig/gcc-3.3-3.3.5/src/gcc/config/ia64/crtbegin.asm 
gcc-3.3-3.3.5/src/gcc/config/ia64/crtbegin.asm
--- orig/gcc-3.3-3.3.5/src/gcc/config/ia64/crtbegin.asm 2003-01-25 
09:28:42.000000000 -0800
+++ gcc-3.3-3.3.5/src/gcc/config/ia64/crtbegin.asm      2004-10-28 
09:30:53.000000000 -0700
@@ -48,8 +48,9 @@
        data8   __dso_handle#
 #else
        .section .bss
+       .align 8
 __dso_handle:
-       data8   0
+       .skip   8
 #endif
        .hidden __dso_handle#
 
@@ -116,11 +117,15 @@
        .align  16
        .proc   __do_global_dtors_aux#
 __do_global_dtors_aux:
+       .prologue
 #ifndef SHARED
        { .mii
+         .save ar.pfs, r35
          alloc loc3 = ar.pfs, 0, 4, 1, 0
          addl loc0 = @gprel(dtor_ptr#), gp
+         .save rp, loc1
          mov loc1 = b0
+         .body
        }
        { .mib
          mov loc2 = gp
@@ -133,6 +138,7 @@
                  __cxa_finalize(__dso_handle)
        */
        { .mii
+         .save ar.pfs, r35
          alloc loc3 = ar.pfs, 0, 4, 1, 0
          addl loc0 = @gprel(dtor_ptr#), gp
          addl r16 = @ltoff(@fptr(__cxa_finalize#)), gp
@@ -148,16 +154,17 @@
        { .mmi
          ld8 out0 = [out0]
 (p7)     ld8 r18 = [r16], 8
+         .save rp, loc1
          mov loc1 = b0
          ;;
        }
-       { .mfi
+       { .mmi
          mov loc2 = gp
+(p7)     ld8 gp = [r16]
 (p7)     mov b6 = r18
        }
        {
          .mfb
-(p7)     ld8 gp = [r16]
 (p7)     br.call.sptk.many b0 = b6
        }
        { .mfb
@@ -189,15 +196,14 @@
          adds r15 = 8, r15
          ;;
        }
-       { .mmi
+       { .mii
          ld8 r16 = [r16]
-         mov gp = loc2
          mov b0 = loc1
+         mov ar.pfs = loc3
          ;;
        }
        { .mib
          cmp.ne p6, p0 = r0, r16
-         mov ar.pfs = loc3
 (p6)     br.cond.sptk.few 0b
        }
        { .bbb
@@ -209,7 +215,9 @@
        .align  16
        .proc   __do_jv_register_classes#
 __do_jv_register_classes:
+       .prologue
        { .mlx
+         .save ar.pfs, r34
          alloc loc2 = ar.pfs, 0, 3, 1, 0
          movl out0 = @gprel(__JCR_LIST__)
          ;;
@@ -232,7 +240,9 @@
        }
        { .mii
          ld8 r15 = [r14], 8
+         .save rp, loc0
          mov loc0 = b0
+         .body
          mov loc1 = gp
          ;;
        }
diff -urN orig/gcc-3.3-3.3.5/src/gcc/config/ia64/crtend.asm 
gcc-3.3-3.3.5/src/gcc/config/ia64/crtend.asm
--- orig/gcc-3.3-3.3.5/src/gcc/config/ia64/crtend.asm   2003-01-25 
09:28:42.000000000 -0800
+++ gcc-3.3-3.3.5/src/gcc/config/ia64/crtend.asm        2004-10-28 
09:30:53.000000000 -0700
@@ -74,18 +74,22 @@
 #endif
        .proc __do_global_ctors_aux#
 __do_global_ctors_aux:
+       .prologue
        /*
                for (loc0 = __CTOR_END__-1; *p != -1; --p)
                  (*p) ();
        */
        { .mlx
+         .save ar.pfs, r36
          alloc loc4 = ar.pfs, 0, 5, 0, 0
          movl loc0 = @gprel(__CTOR_END__# - 8)
          ;;
        }
        { .mmi
          add loc0 = loc0, gp
+         .save rp, loc1
          mov loc1 = b0
+         .body
          ;;
        }
        {
diff -urN orig/gcc-3.3-3.3.5/src/gcc/config/ia64/ia64.c 
gcc-3.3-3.3.5/src/gcc/config/ia64/ia64.c
--- orig/gcc-3.3-3.3.5/src/gcc/config/ia64/ia64.c       2004-09-17 
10:56:32.000000000 -0700
+++ gcc-3.3-3.3.5/src/gcc/config/ia64/ia64.c    2004-10-28 09:30:53.000000000 
-0700
@@ -2884,10 +2884,13 @@
         preserve those input registers used as arguments to the sibling call.
         It is unclear how to compute that number here.  */
       if (current_frame_info.n_input_regs != 0)
-       emit_insn (gen_alloc (gen_rtx_REG (DImode, fp),
-                             GEN_INT (0), GEN_INT (0),
-                             GEN_INT (current_frame_info.n_input_regs),
-                             GEN_INT (0)));
+       {
+         rtx n_inputs = GEN_INT (current_frame_info.n_input_regs);
+         insn = emit_insn (gen_alloc (gen_rtx_REG (DImode, fp),
+                               GEN_INT (0), GEN_INT (0),
+                               n_inputs, GEN_INT (0)));
+         RTX_FRAME_RELATED_P (insn) = 1;
+       }
     }
 }
 
@@ -7451,13 +7454,24 @@
     {
       dest_regno = REGNO (dest);
 
-      /* If this isn't the final destination for ar.pfs, the alloc
-        shouldn't have been marked frame related.  */
-      if (dest_regno != current_frame_info.reg_save_ar_pfs)
-       abort ();
-
-      fprintf (asm_out_file, "\t.save ar.pfs, r%d\n",
-              ia64_dbx_register_number (dest_regno));
+      /* If this is the final destination for ar.pfs, then this must
+        be the alloc in the prologue.  */
+      if (dest_regno == current_frame_info.reg_save_ar_pfs)
+       fprintf (asm_out_file, "\t.save ar.pfs, r%d\n",
+                ia64_dbx_register_number (dest_regno));
+      else
+       {
+         /* This must be an alloc before a sibcall.  We must drop the
+            old frame info.  The easiest way to drop the old frame
+            info is to ensure we had a ".restore sp" directive
+            followed by a new prologue.  If the procedure doesn't
+            have a memory-stack frame, we'll issue a dummy ".restore
+            sp" now.  */
+         if (current_frame_info.total_size == 0)
+           /* if haven't done process_epilogue() yet, do it now */
+           process_epilogue ();
+         fprintf (asm_out_file, "\t.prologue\n");
+       }
       return 1;
     }
 
diff -urN orig/gcc-3.3-3.3.5/src/gcc/emit-rtl.c gcc-3.3-3.3.5/src/gcc/emit-rtl.c
--- orig/gcc-3.3-3.3.5/src/gcc/emit-rtl.c       2004-10-29 09:09:46.799764298 
-0700
+++ gcc-3.3-3.3.5/src/gcc/emit-rtl.c    2004-10-28 05:49:16.000000000 -0700
@@ -5586,6 +5586,11 @@
 
   INSN_SCOPE (new) = INSN_SCOPE (insn);
 
+  /* If the old insn is frame related, then so is the new one.  This is
+     primarily needed for IA-64 unwind info which marks epilogue insns,
+     which may be duplicated by the basic block reordering code.  */
+  RTX_FRAME_RELATED_P (new) = RTX_FRAME_RELATED_P (insn);
+
   /* Copy all REG_NOTES except REG_LABEL since mark_jump_label will
      make them.  */
   for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
diff -urN orig/gcc-3.3-3.3.5/src/gcc/gcc.c gcc-3.3-3.3.5/src/gcc/gcc.c
--- orig/gcc-3.3-3.3.5/src/gcc/gcc.c    2004-10-29 09:09:46.860310347 -0700
+++ gcc-3.3-3.3.5/src/gcc/gcc.c 2004-10-28 09:33:42.000000000 -0700
@@ -1577,6 +1577,9 @@
 #else
                            "-lgcc_s%M"
 #endif
+#ifdef USE_LIBUNWIND_EXCEPTIONS
+                           " -lunwind"
+#endif
                            ,
                            "-lgcc",
                            "-lgcc_eh"

----- End forwarded message -----

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain


Reply via email to