<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 --- - bad codegen on MIPS va_arg"
href="http://llvm.org/bugs/show_bug.cgi?id=19612">19612</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>bad codegen on MIPS va_arg
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>msebor@gmail.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>Compiling the following function for MIPS N32 or N64 with clang 3.4 or the
latest trunk results in incorrect object code that ends up extracting zeros
instead of the values passed in through the variable argument list.
int foo (int a, ...)
{
__builtin_va_list va;
__builtin_va_start (va, a);
int n = __builtin_va_arg (va, int);
__builtin_va_end (va);
return n;
}
In the generated object code, note the sd instruction at foo+1c which stores a
double word at the destination address on the stack, and the lw instruction at
foo+30 which reads a word from the same address. Since only the high word of
the stored double word is read, the low half which contains the value of the
argument is discarded.
00000000 <foo>:
0: 27bdffc0 addiu sp,sp,-64
4: ffab0038 sd a7,56(sp)
8: ffaa0030 sd a6,48(sp)
c: ffa90028 sd a5,40(sp)
10: ffa80020 sd a4,32(sp)
14: ffa70018 sd a3,24(sp)
18: ffa60010 sd a2,16(sp)
1c: ffa50008 sd a1,8(sp) ; note sd
20: 27a20008 addiu v0,sp,8
24: afa20004 sw v0,4(sp)
28: 24420008 addiu v0,v0,8
2c: afa20004 sw v0,4(sp)
30: 8fa20008 lw v0,8(sp) ; note lw
34: 03e00008 jr ra
38: 27bd0040 addiu sp,sp,64
0000003c <$tmp1>:
3c: 00000000 nop
The following options were used to compile the function:
clang -O2 --target=mips64-unknown-linux-gnu -c -mabi=n32 t.c</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>