Bug 53381 - [4.8 Regression] Bootstrap fails building stage1 libgcc
Summary: [4.8 Regression] Bootstrap fails building stage1 libgcc
Status: RESOLVED DUPLICATE of bug 53373
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-16 20:26 UTC by John David Anglin
Modified: 2012-05-18 10:52 UTC (History)
2 users (show)

See Also:
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Candidate patch (306 bytes, patch)
2012-05-16 23:14 UTC, Bernd Schmidt
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2012-05-16 20:26:27 UTC
/home/dave/gnu/gcc/objdir/./gcc/xgcc -B/home/dave/gnu/gcc/objdir/./gcc/ -B/home/
dave/opt/gnu/gcc/gcc-4.8.0/hppa-linux-gnu/bin/ -B/home/dave/opt/gnu/gcc/gcc-4.8.
0/hppa-linux-gnu/lib/ -isystem /home/dave/opt/gnu/gcc/gcc-4.8.0/hppa-linux-gnu/i
nclude -isystem /home/dave/opt/gnu/gcc/gcc-4.8.0/hppa-linux-gnu/sys-include    -
g -O2 -O2  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-proto
types -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -D
ELF=1 -DLINUX=1 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fPIC -
DELF=1 -DLINUX=1 -I. -I. -I../.././gcc -I../../../gcc/libgcc -I../../../gcc/libg
cc/. -I../../../gcc/libgcc/../gcc -I../../../gcc/libgcc/../include  -DHAVE_CC_TL
S  -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c .
./../../gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
[...]
../../../gcc/libgcc/unwind-dw2.c: In function 'execute_cfa_program':
../../../gcc/libgcc/unwind-dw2.c:1159:1: internal compiler error: Segmentation fault
 }
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[3]: *** [unwind-dw2.o] Error 1

Program received signal SIGSEGV, Segmentation fault.
0x00184d98 in save_call_clobbered_regs () at ../../gcc/gcc/caller-save.c:877
877                       rtx pat = gen_rtx_SET (VOIDmode, cheap,
(gdb) bt
#0  0x00184d98 in save_call_clobbered_regs ()
    at ../../gcc/gcc/caller-save.c:877
#1  0x004b11f8 in reload (first=0x4144fb40, global=1)
    at ../../gcc/gcc/reload1.c:939
#2  0x003dcbd4 in do_reload () at ../../gcc/gcc/ira.c:4261
#3  rest_of_handle_reload () at ../../gcc/gcc/ira.c:4352
#4  0x0045b06c in execute_one_pass (pass=0xa6c050)
    at ../../gcc/gcc/passes.c:2183
#5  0x0045b318 in execute_pass_list (pass=0x0) at ../../gcc/gcc/passes.c:2238
#6  0x0045b318 in execute_pass_list (pass=0x0) at ../../gcc/gcc/passes.c:2238
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) disass $pc-16,$pc+16
Dump of assembler code from 0x184d88 to 0x184da8:
   0x00184d88 <save_call_clobbered_regs+1908>:  copy r7,r26
   0x00184d8c <save_call_clobbered_regs+1912>:  b,l 0x1814ac,rp
   0x00184d90 <save_call_clobbered_regs+1916>:  copy ret0,r25
   0x00184d94 <save_call_clobbered_regs+1920>:  b,l 0x1815ec,rp
=> 0x00184d98 <save_call_clobbered_regs+1924>:  ldw 4(ret0),r26
   0x00184d9c <save_call_clobbered_regs+1928>:  copy ret0,r4
   0x00184da0 <save_call_clobbered_regs+1932>:  b,l 0x181de4,rp
   0x00184da4 <save_call_clobbered_regs+1936>:  ldi 17,r26
End of assembler dump.
(gdb) p/x $ret0
$1 = 0x0

dave@lafayette:~/gnu/gcc/objdir/gcc$ ./xgcc -B./ -v
Reading specs from ./specs
COLLECT_GCC=./xgcc
COLLECT_LTO_WRAPPER=./lto-wrapper
Target: hppa-linux-gnu
Configured with: ../gcc/configure --with-gnu-as --with-gnu-ld --enable-shared --enable-multiarch --with-multiarch-defaults=hppa-linux-gnu --enable-linker-build-id --build=hppa-linux-gnu --host=hppa-linux-gnu --target=hppa-linux-gnu --prefix=/home/dave/opt/gnu/gcc/gcc-4.8.0 --with-local-prefix=/home/dave/opt/gnu --enable-threads=posix --enable-__cxa_atexit --build=hppa-linux-gnu --enable-clocale=gnu --enable-java-gc=boehm --enable-languages=c,c++,objc,fortran,obj-c++,java,lto
Thread model: posix
gcc version 4.8.0 20120516 (experimental) [trunk revision 187604] (GCC)
Comment 1 John David Anglin 2012-05-16 22:17:28 UTC
Introduced in revision 187459.
Comment 2 Bernd Schmidt 2012-05-16 22:30:53 UTC
What's it actually trying to access, and failing? Is dest NULL or something?
Comment 3 dave.anglin 2012-05-16 23:01:00 UTC
On 16-May-12, at 6:30 PM, bernds at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53381
>
> --- Comment #2 from Bernd Schmidt <bernds at gcc dot gnu.org>  
> 2012-05-16 22:30:53 UTC ---
> What's it actually trying to access, and failing? Is dest NULL or  
> something?


It's call_set that's NULL.

(gdb) p debug_rtx (insn)
(call_insn 563 562 565 41 (parallel [
             (set (reg:SI 4 %r4)
                 (reg:SI 19 %r19))
             (set (reg:SI 28 %r28)
                 (call (mem:SI (symbol_ref/v:SI ("@memcpy") [flags  
0x241] <function_decl 0x4163e980 memcpy>) [0 S4 A32])
                     (const_int 16 [0x10])))
             (clobber (reg:SI 1 %r1))
             (clobber (reg:SI 2 %r2))
             (use (reg:SI 4 %r4))
             (use (reg:SI 19 %r19))
             (use (const_int 0 [0]))
         ]) ../../../gcc/libgcc/unwind-dw2.c:1028 206  
{call_val_symref_pic}
      (expr_list:REG_RETURNED (reg/v/f:SI 20 %r20 [orig:99 new_rs ]  
[99])
         (expr_list:REG_DEAD (reg:SI 26 %r26)
             (expr_list:REG_DEAD (reg:SI 25 %r25)
                 (expr_list:REG_DEAD (reg:SI 24 %r24)
                     (expr_list:REG_UNUSED (reg:SI 28 %r28)
                         (expr_list:REG_EH_REGION (const_int 0 [0])
                             (nil)))))))
     (expr_list:REG_CC_SETTER (set (reg:SI 28 %r28)
             (reg:SI 26 %r26))
         (expr_list:REG_CC_SETTER (use (reg:SI 24 %r24))
             (expr_list:REG_CC_SETTER (use (reg:SI 25 %r25))
                 (expr_list:REG_CC_SETTER (use (reg:SI 26 %r26))
                     (nil))))))

--
John David Anglin	dave.anglin@bell.net
Comment 4 Bernd Schmidt 2012-05-16 23:14:32 UTC
Created attachment 27427 [details]
Candidate patch

Ok, seriously weird call insns. If you can fix that in the port, it'll benefit from the optimization. Otherwise, try the following which disables it for targets with strange call insns.

I won't be able to check this in until Monday; I think if it passes testing on your machine you can either check it in as obvious or wait a few days.
Comment 5 dave.anglin 2012-05-17 00:18:46 UTC
On 16-May-12, at 7:14 PM, bernds at gcc dot gnu.org wrote:

> Ok, seriously weird call insns. If you can fix that in the port,  
> it'll benefit
> from the optimization. Otherwise, try the following which disables  
> it for
> targets with strange call insns.

Agreed.  In PIC, the runtime architecture mandates that the PIC register
is saved and restored across function calls.  It's been quite a few  
years
since the current scheme was worked out.  There were previous  
implementations
where the save wasn't part of the call but there were always  
occasional cases
where the restore was lost resulting in wrong code.  Part of the  
problem is
not all uses of the PIC register are exposed prior to reload.  There are
splitters to optimize things a bit after reload.

I'm reluctant to change the current implementation because the situation
is quite tricky.

Dave
--
John David Anglin	dave.anglin@bell.net
Comment 6 dave.anglin 2012-05-17 01:52:03 UTC
On 16-May-12, at 7:14 PM, bernds at gcc dot gnu.org wrote:

> Ok, seriously weird call insns. If you can fix that in the port,  
> it'll benefit
> from the optimization. Otherwise, try the following which disables  
> it for
> targets with strange call insns.

I'll try this on the weekend.  It may be fairly easy.

--
John David Anglin	dave.anglin@bell.net
Comment 7 Jakub Jelinek 2012-05-17 06:44:35 UTC
Can't you instead of using single_set just find the single set with GET_CODE (SET_SRC (set)) == CALL (and only punt if there is none or more than one)?
That would handle e.g. the AVX marked call or this one just fine...
Comment 8 Jakub Jelinek 2012-05-17 06:48:31 UTC
Note that e.g. dse.c (scan_insn) handles the AVX mem* just fine, but won't handle this PA pattern because (set (reg) (call ...)) isn't the first thing in the parallel.  Any reason for that?
          rtx call = PATTERN (insn);
          if (GET_CODE (call) == PARALLEL)
            call = XVECEXP (call, 0, 0);
          if (GET_CODE (call) == SET)
            call = SET_SRC (call);
          if (GET_CODE (call) == CALL
              && MEM_P (XEXP (call, 0))
              && GET_CODE (XEXP (XEXP (call, 0), 0)) == SYMBOL_REF)
Comment 9 dave.anglin 2012-05-17 14:39:41 UTC
On 5/17/2012 2:48 AM, jakub at gcc dot gnu.org wrote:
> Note that e.g. dse.c (scan_insn) handles the AVX mem* just fine, but won't
> handle this PA pattern because (set (reg) (call ...)) isn't the first thing in
> the parallel.  Any reason for that?
There is no reason other than the RTL was trying to reflect the save and 
restore of the
PIC register.  I hacked the call patterns to completely hide the 
handling of the PIC register
until they are split after reload.  So far, testing looks ok.
Comment 10 Jakub Jelinek 2012-05-17 14:53:21 UTC
For DSE it would be enough if just the call was first in the parallel and the currently first set came after it.  All sets in a parallel happen at the same time...
Comment 11 Richard Biener 2012-05-18 10:52:03 UTC
duplicate btw.

*** This bug has been marked as a duplicate of bug 53373 ***