[Bug target/53219] New: inline function erroneously clobbers %i0 register on 64 bit sparc comiple of perls regcomp.c

martin at netbsd dot org gcc-bugzilla@gcc.gnu.org
Thu May 3 19:43:00 GMT 2012


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

             Bug #: 53219
           Summary: inline function erroneously clobbers %i0 register on
                    64 bit sparc comiple of perls regcomp.c
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: martin@netbsd.org


gcc 4.5.3 on NetBSD/sparc64 miscompiles perl's regcomp.c file.
Inside the big Perl_re_compile() function with %i0 being "my_perl", the context
for the whole function, it inlines this tiny function:

72      PERL_STATIC_INLINE regex_charset
73      get_regex_charset(const U32 flags)
74      {
75          /* Returns the enum corresponding to the character set in 'flags'
*/
76      
77          return (regex_charset) ((flags & RXf_PMf_CHARSET) >>
_RXf_PMf_CHARSET_SHIFT);
78      }

This is the generated assembler code:

   0x4058f560 <Perl_re_compile+128>:    
    brnz  %g1, 0x4058f570 <Perl_re_compile+144>
   0x4058f564 <Perl_re_compile+132>:    add  %l3, %g1, %l5
   0x4058f568 <Perl_re_compile+136>:    clr  [ %fp + 0x66b ]
   0x4058f56c <Perl_re_compile+140>:    clr  [ %fp + 0x88f ], %i0
   0x4058f574 <Perl_re_compile+148>:    and  %i0, 0xe0, %g1
   0x4058f578 <Perl_re_compile+152>:    srl  %g1, 5, %g1
   0x4058f57c <Perl_re_compile+156>:    cmp  %g1, 1
   0x4058f580 <Perl_re_compile+160>:    
    be,pn   %icc, 0x40590ecc <Perl_re_compile+6636>

Note at the ==> marker, %i0 is reloaded without save before nor any restore
later. This causes a crash shortly later.

Simple test:

   perl -e '/(?{"{"})/'



More information about the Gcc-bugs mailing list