[LLVMbugs] [Bug 13627] New: powerpc64 parameter passing of small structs does not match PPC64 ELF ABI
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Aug 17 09:00:03 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13627
Bug #: 13627
Summary: powerpc64 parameter passing of small structs does not
match PPC64 ELF ABI
Product: new-bugs
Version: trunk
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: wschmidt at linux.vnet.ibm.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
On powerpc64-unknown-linux-gnu, passing of structs smaller than 8 bytes is not
always compatible with the 64-bit PowerPC ELF Application Binary Interface
Supplement (see
http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html). From
section 3.2.3: "An aggregate or union smaller than one doubleword in size is
padded so that it appears in the least significant bits of the doubleword. All
others are padded, if necessary, at their tail." So structs smaller than 8
bytes will be passed "right-adjusted" in a GPR.
Consider:
struct s {
char c;
short d;
};
struct s
test_struct_2 (struct s foo)
{
foo.c++;
foo.d++;
return foo;
}
LLVM generates:
.L.test_struct_2:
std 4, 56(1)
lbz 5, 56(1) <-- c is at leftmost position in GPR4, should be 60(1)
addi 5, 5, 1
stb 5, 56(1)
addi 4, 1, 56 <-- d is four bytes left of correct, should be 60 here
lhz 5, 2(4)
addi 5, 5, 1
sth 5, 2(4)
lwz 5, 56(1)
sth 5, 2(3)
srwi 5, 5, 16
sth 5, 0(3)
std 3, -8(1)
blr
Note that LLVM gets it right if "d" is omitted from the struct. "c" is then
passed rightmost in GPR4:
.L.test_struct_1:
stb 4, 59(1)
lbz 5, 59(1)
addi 5, 5, 1
stb 5, 59(1)
lbz 5, 59(1)
stb 5, 0(3)
addi 4, 1, 59
std 4, -8(1)
std 3, -16(1)
blr
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list