<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:markmi@dsl-only.net" title="Mark Millard <markmi@dsl-only.net>"> <span class="fn">Mark Millard</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Clang 4.0.0's "Target: powerpc-unknown-freebsd11.0" code generation is violating the SVR4 ABI (SEGV can result)"
   href="https://bugs.llvm.org/show_bug.cgi?id=26519">bug 26519</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>FIXED
           </td>
           <td>---
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Clang 4.0.0's "Target: powerpc-unknown-freebsd11.0" code generation is violating the SVR4 ABI (SEGV can result)"
   href="https://bugs.llvm.org/show_bug.cgi?id=26519#c24">Comment # 24</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Clang 4.0.0's "Target: powerpc-unknown-freebsd11.0" code generation is violating the SVR4 ABI (SEGV can result)"
   href="https://bugs.llvm.org/show_bug.cgi?id=26519">bug 26519</a>
              from <span class="vcard"><a class="email" href="mailto:markmi@dsl-only.net" title="Mark Millard <markmi@dsl-only.net>"> <span class="fn">Mark Millard</span></a>
</span></b>
        <pre>(In reply to Krzysztof Parzyszek from <a href="show_bug.cgi?id=26519#c19">comment #19</a>)
<span class="quote">> Committed a fix in r302183.</span >

Bad news: Another code generation error, this
time demonstrated in compiling part of perl5. . .
(I tried to build a port that indirectly
tried build perl5 but perl5's miniperl crashes.)

/usr/obj/portswork/usr/ports/lang/perl5.24/work/perl-5.24.1/numeric.c

has Perl_cast_iv(NV f) for which clang double stores
two different things to one address [24(r1)]. Below
the => lines are the double store, the second
destroying the r30 value that was saved in the first:

Dump of assembler code for function Perl_cast_iv:
   0x0196a114 <+0>:     mflr    r0
   0x0196a118 <+4>:     stw     r0,4(r1)
   0x0196a11c <+8>:     stwu    r1,-32(r1)
   0x0196a120 <+12>:    stw     r31,28(r1)
=>   0x0196a124 <+16>:  stw     r30,24(r1)
   0x0196a128 <+20>:    mr      r31,r1
   0x0196a12c <+24>:    mfcr    r12
=>   0x0196a130 <+28>:  stw     r12,24(r31)

Note: r31 == r1 for that second "=>" line.

The return code sequence has a similar
problem: two loads from the same address.

Note: r31 == r1 here too.

=>   0x0196a1bc <+168>: lwz     r12,24(r31)
   0x0196a1c0 <+172>:   lwz     r0,36(r1)
   0x0196a1c4 <+176>:   lwz     r31,28(r1)
=>   0x0196a1c8 <+180>: lwz     r30,24(r1)
   0x0196a1cc <+184>:   mtcrf   32,r12
   0x0196a1d0 <+188>:   addi    r1,r1,32
   0x0196a1d4 <+192>:   mtlr    r0
   0x0196a1d8 <+196>:   blr

The Perl_cast_iv source code looks like:

IV
Perl_cast_iv(NV f)
{
  if (f < IV_MAX_P1)
    return f < IV_MIN ? IV_MIN : (IV) f;
  if (f < UV_MAX_P1) {
#if CASTFLAGS & 2
    /* For future flexibility allowing for sizeof(UV) >= sizeof(IV)  */
    if (f < UV_MAX_P1_HALF)
      return (IV)(UV) f;
    f -= UV_MAX_P1_HALF;
    return (IV)(((UV) f) | (1 + (UV_MAX >> 1)));
#else
    return (IV)(UV) f;
#endif
  }
  return f > 0 ? (IV)UV_MAX : 0 /* NaN */;
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>