[LLVMbugs] [Bug 19612] New: bad codegen on MIPS va_arg
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Apr 29 17:46:25 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19612
Bug ID: 19612
Summary: bad codegen on MIPS va_arg
Product: clang
Version: trunk
Hardware: Other
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: msebor at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140430/d53abfd9/attachment.html>
More information about the llvm-bugs
mailing list