[LLVMbugs] [Bug 11688] New: i386-pc-win32 struct by value return does not match MSVC calling convention
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jan 1 11:53:12 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=11688
Bug #: 11688
Summary: i386-pc-win32 struct by value return does not match
MSVC calling convention
Product: clang
Version: 3.0
Platform: PC
OS/Version: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: arcata at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
When targeting i?86-pc-win32, Clang returns all structs by hidden pointer,
although MSVC returns structs sized {8,4,3,2,1} bytes in registers, as
documented at http://msdn.microsoft.com/en-us/library/984x0h58.aspx .
A simple test case:
---
#include <stdint.h>
struct Struct1 {
uint64_t a;
};
struct Struct2 {
uint32_t a;
};
struct Struct3 {
char a, b, c;
};
struct Struct1 c_return_1(void) {
struct Struct1 r = { 0xC1A4C1A4C1A4C1A4ULL };
return r;
}
struct Struct2 c_return_2(void) {
struct Struct2 r = { 0xC1A4C1A4U };
return r;
}
struct Struct3 c_return_3(void) {
struct Struct3 r = { 0xAA, 0xBB, 0xCC };
return r;
}
---
cl.exe generates the following asm for c_return_1:
---
_c_return_1 PROC
; File
c:\users\joe\documents\code\clay\test\externals\abi\common\external_test1.c
; Line 15
push ebp
mov ebp, esp
sub esp, 8
; Line 16
mov DWORD PTR _r$[ebp], -1046167132 ; c1a4c1a4H
mov DWORD PTR _r$[ebp+4], -1046167132 ; c1a4c1a4H
; Line 17
mov eax, DWORD PTR _r$[ebp]
mov edx, DWORD PTR _r$[ebp+4]
; Line 18
mov esp, ebp
pop ebp
ret 0
_c_return_1 ENDP
---
You can see under "Line 17" that it moves the return value into
edx:eax. By contrast, clang expects a hidden pointer argument:
---
_c_return_1: # @c_return_1
# BB#0:
subl $12, %esp
movl 16(%esp), %eax
movsd L_c_return_1.r, %xmm0
movsd %xmm0, (%esp)
movsd %xmm0, (%eax)
addl $12, %esp
ret $4
---
Similar discrepancies occur for c_return_2 and c_return_3.
--
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