<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 --- - small arguments stored on stack in high words on MIPS64"
href="http://llvm.org/bugs/show_bug.cgi?id=20302">20302</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>small arguments stored on stack in high words on MIPS64
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>SGI
</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>When passing more than 8 scalar arguments to a function on big-endian MIPS64
(both the N32 and N64 ABIs), the ninth and subsequent arguments are spilled to
the stack (the first 8 arguments are passed in 64-bit integer registers).
Arguments that are smaller than 64-bits such as int must be stored by the
caller in and retrieved by the callee from the low word of the corresponding
stack slot. The test case below shows that Clang stores them in and retrieves
them from the high word, generating ABI-incompatible code. See also clang <a class="bz_bug_link
bz_status_ASSIGNED "
title="ASSIGNED --- - bad codegen on MIPS va_arg"
href="show_bug.cgi?id=19612">bug
19612</a> for a related problem involving vararg functions.
$ cat u.c && /auto/binos-tools/llvm-3.4.0/bin/clang -DFOO -O2 -S
--target=mips64 u.c && cat u.s
extern int foo (int, int, int, int, int, int, int, int, int);
int bar (int a, int b, int c, int d, int e, int f, int g, int h, int i) {
return i;
}
int baz (void) { return foo (1, 2, 3, 4, 5, 6, 7, 8, 9); }
.abicalls
.section .mdebug.abi64
.previous
.file "u.c"
.text
.globl bar
.align 3
.type bar,@function
.set nomips16
.ent bar
bar:
.frame $fp,16,$ra
.mask 0x00000000,0
.fmask 0x40000000,-4
.set noreorder
.set nomacro
.set noat
daddiu $sp, $sp, -16
sd $fp, 8($sp)
move $fp, $sp
lw $2, 16($fp) <<< SHOULD BE lw $2, 20($sp)
move $sp, $fp
ld $fp, 8($sp)
jr $ra
daddiu $sp, $sp, 16
.set at
.set macro
.set reorder
.end bar
$tmp3:
.size bar, ($tmp3)-bar
.globl baz
.align 3
.type baz,@function
.set nomips16
.ent baz
baz:
.frame $fp,48,$ra
.mask 0x00000000,0
.fmask 0xd0000000,-4
.set noreorder
.set nomacro
.set noat
daddiu $sp, $sp, -48
sd $ra, 40($sp)
sd $fp, 32($sp)
sd $gp, 24($sp)
move $fp, $sp
lui $1, %hi(%neg(%gp_rel(baz)))
daddu $1, $1, $25
daddiu $1, $1, %lo(%neg(%gp_rel(baz)))
addiu $2, $zero, 9
sw $2, 0($sp) <<< SHOULD BE sw $2, 4($sp)
ld $25, %call16(foo)($1)
addiu $4, $zero, 1
addiu $5, $zero, 2
addiu $6, $zero, 3
addiu $7, $zero, 4
addiu $8, $zero, 5
addiu $9, $zero, 6
addiu $10, $zero, 7
addiu $11, $zero, 8
jalr $25
move $gp, $1
move $sp, $fp
ld $gp, 24($sp)
ld $fp, 32($sp)
ld $ra, 40($sp)
jr $ra
daddiu $sp, $sp, 48
.set at
.set macro
.set reorder
.end baz
$tmp7:
.size baz, ($tmp7)-baz
.ident "clang version 3.4 (ssh://wwwin-git-sjc-2/git/llvm/clang.git
74a0c210785e337b942d9393e6e2ab26dda43f63) (llvm/llvm.git
795cabf67df5d572c26296f83b34e247284bcabd)"</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>