[LLVMdev] Passing structures as pointers, MSVC x64 style
Carl Norum
carl.norum at apple.com
Mon Feb 21 17:31:16 PST 2011
On Feb 21, 2011, at 4:51 PM, NAKAMURA Takumi wrote:
> Carl,
>
> See clang/lib/CodeGen/TargetInfo.cpp.
>
> // FIXME: mingw64-gcc emits 128-bit struct as i128
> if (Size <= 128 &&
> (Size & (Size - 1)) == 0)
> return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(),
> Size));
>
> It was my workaround, sorry.
> Please check to tweak the clause (128 to 64) and lemme know.
Hi Takumi,
I think you hit the nail on the head with that one. Changing that constant to 64 seems to have done the trick. Here's the new disassembled output:
_byValue:
0000000000000000 pushq %rbp
0000000000000001 movq %rsp,%rbp
0000000000000004 subq $0x30,%rsp
0000000000000008 leaq 0xf0(%rbp),%rdx
000000000000000c movq 0x00000008(%rip),%rax
0000000000000013 movq %rax,0xf8(%rbp)
0000000000000017 movq 0x00000000(%rip),%rax
000000000000001e movq %rax,0xf0(%rbp)
0000000000000022 movl $0x00000001,%ecx
0000000000000027 callq 0x0000002c
000000000000002c addq $0x30,%rsp
0000000000000030 popq %rbp
0000000000000031 ret
%rdx is now getting the address of a copy of the struct! Patch attached; if it looks good to you I'll commit it.
-- Carl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: msabi_patch.txt
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110221/8968ede5/attachment.txt>
More information about the llvm-dev
mailing list