public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/44734]  New: GCC compiled to run on mips platform ICE's in def_builtin_1 ()
@ 2010-06-30 21:22 raj dot khem at gmail dot com
  2010-06-30 21:23 ` [Bug target/44734] " raj dot khem at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: raj dot khem at gmail dot com @ 2010-06-30 21:22 UTC (permalink / raw)
  To: gcc-bugs

There seems to be wrong code generated when cross-gcc (x86_64->mips) is used to
compile gcc for mips target.

Program received signal SIGSEGV, Segmentation fault.
0x004940ac in def_builtin_1 (fncode=BUILT_IN_HUGE_VAL, name=<value optimized
out>, 
    fnclass=BUILT_IN_NORMAL, fntype=<value optimized out>, libtype=0x0,
both_p=0 '\000', 
    fallback_p=0 '\000', nonansi_p=0 '\000', fnattrs=0x2adc42b8, implicit_p=1
'\001')
    at
/scratch/oe/work/mips-oe-linux-uclibc/gcc-4.5-r4.1+svnr161450/gcc-4.5/gcc/c-common.c:5186
5186      built_in_decls[(int) fncode] = decl;


When I debugged through it then I see that in this function def_builtin_1
its trying to access 'fncode' which comes in a0 into function it stores it into
s2 and then later it moves it into s5 and it uses s5 later to generate the
offset into the array built_in_decls[(int) fncode] but the this move into s5
doesnt happen in all execution paths and it gets a bogus high value into s5
which it thinks is an offset into array and then dies. The case where s5 is not
populated correctly is when in following assert (!both_p && fallback_p) is true
then it does not have to compute the || and it follows a different execution
path.

gcc_assert ((!both_p && fallback_p)                                             
              || !strncmp (name, "__builtin_",                                  
                           strlen ("__builtin_")));   


I have attached the objdump output of c-common.o


-- 
           Summary: GCC compiled to run on mips platform ICE's in
                    def_builtin_1 ()
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: raj dot khem at gmail dot com
 GCC build triplet: x86_64-linux
  GCC host triplet: x86_64-linux
GCC target triplet: mips-oe-linux-uclibc


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44734


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

* [Bug target/44734] GCC compiled to run on mips platform ICE's in def_builtin_1 ()
  2010-06-30 21:22 [Bug target/44734] New: GCC compiled to run on mips platform ICE's in def_builtin_1 () raj dot khem at gmail dot com
@ 2010-06-30 21:23 ` raj dot khem at gmail dot com
  2010-06-30 21:25 ` raj dot khem at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: raj dot khem at gmail dot com @ 2010-06-30 21:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from raj dot khem at gmail dot com  2010-06-30 21:22 -------
Created an attachment (id=21046)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21046&action=view)
objdump intermixed with source for the function


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44734


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

* [Bug target/44734] GCC compiled to run on mips platform ICE's in def_builtin_1 ()
  2010-06-30 21:22 [Bug target/44734] New: GCC compiled to run on mips platform ICE's in def_builtin_1 () raj dot khem at gmail dot com
  2010-06-30 21:23 ` [Bug target/44734] " raj dot khem at gmail dot com
@ 2010-06-30 21:25 ` raj dot khem at gmail dot com
  2010-06-30 21:32 ` raj dot khem at gmail dot com
  2010-06-30 21:33 ` raj dot khem at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: raj dot khem at gmail dot com @ 2010-06-30 21:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from raj dot khem at gmail dot com  2010-06-30 21:24 -------
Created an attachment (id=21047)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21047&action=view)
preprocessed c-common.c

to compile use 
mips-oe-linux-uclibc-gcc -march=mips32 -O c-common.i -S


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44734


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

* [Bug target/44734] GCC compiled to run on mips platform ICE's in def_builtin_1 ()
  2010-06-30 21:22 [Bug target/44734] New: GCC compiled to run on mips platform ICE's in def_builtin_1 () raj dot khem at gmail dot com
  2010-06-30 21:23 ` [Bug target/44734] " raj dot khem at gmail dot com
  2010-06-30 21:25 ` raj dot khem at gmail dot com
@ 2010-06-30 21:32 ` raj dot khem at gmail dot com
  2010-06-30 21:33 ` raj dot khem at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: raj dot khem at gmail dot com @ 2010-06-30 21:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from raj dot khem at gmail dot com  2010-06-30 21:31 -------
  gcc_assert ((!both_p && !fallback_p)                                          
    4a7c:       16800004        bnez    s4,4a90 <def_builtin_1+0x84>            
    4a80:       02002021        move a0,s0                                      
    4a84:       12c00051        beqz    s6,4bcc <def_builtin_1+0x1c0>    
=================> this jump is taken ============                           
    4a88:       0080a821        move    s5,a0                                   


.............


then it comes here
 libname = name + strlen ("__builtin_");                                        
  decl = add_builtin_function (name, fntype, fncode, fnclass,                   
    4bcc:       afa00010        sw      zero,16(sp)                             
    4bd0:       8fc20070        lw      v0,112(s8)                              
    4bd4:       afa20014        sw      v0,20(sp)                               
    4bd8:       00a02021        move    a0,a1                                   
    4bdc:       00e02821        move    a1,a3                                   
    4be0:       02403021        move    a2,s2                                   
    4be4:       02e03821        move    a3,s7                                   
    4be8:       8f990000        lw      t9,0(gp)                                
    4bec:       0320f809        jalr    t9                                      
    4bf0:       00000000        nop                                             
    4bf4:       8fdc0018        lw      gp,24(s8)                               
    4bf8:       080012e8        j       4ba0 <def_builtin_1+0x194>
====================> this jump takes it back to failing assignment             
    4bfc:       00408821        move    s1,v0                                   


....


  built_in_decls[(int) fncode] = decl;                                          
    4ba0:       00151080        sll     v0,s5,0x2                               
    4ba4:       8f830000        lw      v1,0(gp)                                
    4ba8:       00621021        addu    v0,v1,v0                                
    4bac:       ac510000        sw      s1,0(v0)  ====================> dies
here because this is invalid address in v0 now



in cases where the first branch is not taken it goes into



             || !strncmp (name, "__builtin_",                                   
                           strlen ("__builtin_")));                             

  libname = name + strlen ("__builtin_");                                       
  decl = add_builtin_function (name, fntype, fncode, fnclass,                   
    4ad4:       0240a821        move    s5,s2                                   
    4ad8:       00001021        move    v0,zero                                 
    4adc:       0276100b        movn    v0,s3,s6                                
    4ae0:       afa20010        sw      v0,16(sp)                               
    4ae4:       8fc20070        lw      v0,112(s8)                              
    4ae8:       afa20014        sw      v0,20(sp)                               
    4aec:       02002021        move    a0,s0                                   
    4af0:       02202821        move    a1,s1                                   
    4af4:       02403021        move    a2,s2                                   
    4af8:       02e03821        move    a3,s7                                   
    4afc:       8f990000        lw      t9,0(gp)                                
    4b00:       0320f809        jalr    t9                                      
    4b04:       00000000        nop                                             
    4b08:       8fdc0018        lw      gp,24(s8)                               


as you can see first instruction moves s2 into s5 and s2 holds the right value
so it works ok.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44734


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

* [Bug target/44734] GCC compiled to run on mips platform ICE's in def_builtin_1 ()
  2010-06-30 21:22 [Bug target/44734] New: GCC compiled to run on mips platform ICE's in def_builtin_1 () raj dot khem at gmail dot com
                   ` (2 preceding siblings ...)
  2010-06-30 21:32 ` raj dot khem at gmail dot com
@ 2010-06-30 21:33 ` raj dot khem at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: raj dot khem at gmail dot com @ 2010-06-30 21:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from raj dot khem at gmail dot com  2010-06-30 21:33 -------
just in case here is how the compiler was configured

Using built-in specs.
COLLECT_GCC=mips-oe-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/scratch/oe/cross/mips/libexec/gcc/mips-oe-linux-uclibc/4.5.1/lto-wrapper
Target: mips-oe-linux-uclibc
Configured with:
/scratch/oe/work/mips-oe-linux-uclibc/gcc-cross-4.5-r1+svnr161450/gcc-4.5/configure
--build=x86_64-linux --host=x86_64-linux --target=mips-oe-linux-uclibc
--prefix=/scratch/oe/cross/mips --exec_prefix=/scratch/oe/cross/mips
--bindir=/scratch/oe/cross/mips/bin --sbindir=/scratch/oe/cross/mips/bin
--libexecdir=/scratch/oe/cross/mips/libexec
--datadir=/scratch/oe/cross/mips/share --sysconfdir=/scratch/oe/cross/mips/etc
--sharedstatedir=/scratch/oe/cross/mips/com
--localstatedir=/scratch/oe/cross/mips/var --libdir=/scratch/oe/cross/mips/lib
--includedir=/scratch/oe/cross/mips/include
--oldincludedir=/scratch/oe/cross/mips/include
--infodir=/scratch/oe/cross/mips/share/info
--mandir=/scratch/oe/cross/mips/share/man --enable-clocale=generic
--with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix
--enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu
--enable-libstdcxx-pch --program-prefix=mips-oe-linux-uclibc-
--enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap
--disable-libgomp --disable-libmudflap
--with-local-prefix=/scratch/oe/sysroots/mips-oe-linux-uclibc/usr
--with-gxx-include-dir=/scratch/oe/sysroots/mips-oe-linux-uclibc//usr/include/c++
--with-sysroot=/scratch/oe/sysroots/mips-oe-linux-uclibc
--with-build-sysroot=/scratch/oe/sysroots/mips-oe-linux-uclibc
--disable-libunwind-exceptions
--with-mpfr=/scratch/oe/sysroots/x86_64-linux/usr --with-system-zlib
--disable-decimal-float --program-prefix=mips-oe-linux-uclibc-
--disable-__cxa_atexit --disable-nls
Thread model: posix
gcc version 4.5.1 20100627 (prerelease) (GCC) 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44734


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

end of thread, other threads:[~2010-06-30 21:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30 21:22 [Bug target/44734] New: GCC compiled to run on mips platform ICE's in def_builtin_1 () raj dot khem at gmail dot com
2010-06-30 21:23 ` [Bug target/44734] " raj dot khem at gmail dot com
2010-06-30 21:25 ` raj dot khem at gmail dot com
2010-06-30 21:32 ` raj dot khem at gmail dot com
2010-06-30 21:33 ` raj dot khem at gmail dot com

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