<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Mips Backend generates wrong code for vaarg"
   href="http://llvm.org/bugs/show_bug.cgi?id=15389">15389</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Mips Backend generates wrong code for vaarg
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>n.stavropoulos@think-silicon.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10105" name="attach_10105" title="assembly code for mipsel. bug between lines 253 -259">attachment 10105</a> <a href="attachment.cgi?id=10105&action=edit" title="assembly code for mipsel. bug between lines 253 -259">[details]</a></span>
assembly code for mipsel. bug between lines 253 -259

typedef integer I;
void test1(I p0, I p1, I p2, I p3, I p4, I p5, I p6, I p7, I p8, ...)
{
  va_list select;

  va_start (select, p8);

  report( va_arg(select,I) );
  report( va_arg(select,I) );
  report( va_arg(select,I) );

  va_end (select);
}


typedef long long L;

void test2(auto L p0, auto L p1, auto L p2, auto L p4, ...)
{
  va_list select;

  va_start (select, p4);

  report( va_arg(select,L) );
  report( va_arg(select,I) );
  report( va_arg(select,L) );

  va_end (select);
}

int main(void)
{
    test1(0L, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
    test2(1, 2, 3, 4, 5LL, 6, 7LL);
    return 0;
}
report is just print function
in this code mipsel backend fails to generate correct code

attached mipsel.s code generated with command


"llc -O1  -march=mipsel -relocation-model=static -asm-verbose
-mattr=+condmov,-muldivadd,+single-float,-fp64,+o32,-bitcount"

this bug is generated for every -O argument

in test2 function,we have to report a long long value then an integer and
finally a long long.
for some reason backend does addiu $3, $2, 4 and the last argument is not read
correctly. 

        addiu   $sp, $sp, -24
        sw      $ra, 20($sp)            # 4-byte Folded Spill
        addiu   $2, $sp, 56
        sw      $2, 16($sp)
        addiu   $2, $2, 8
        sw      $2, 16($sp)
        lw      $5, 60($sp)
        lw      $4, 56($sp)
        jal     _Z6reportx
        nop
        lw      $2, 16($sp)

###possible bug 
        addiu   $3, $2, 4
###possible bug 

        sw      $3, 16($sp)
        lw      $4, 0($2)
        jal     _Z6reporti
        nop
        lw      $2, 16($sp)
        addiu   $3, $2, 8
        sw      $3, 16($sp)
        lw      $5, 4($2)
        lw      $4, 0($2)</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>