https://bugs.llvm.org/show_bug.cgi?id=47465
Bug ID: 47465
Summary: [Windows][AArch64] Arguments not passed in the correct
register
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangb...@nondot.org
Reporter: richard.towns...@arm.com
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
Created attachment 23938
--> https://bugs.llvm.org/attachment.cgi?id=23938&action=edit
Reproducer
When compiling the attached file (constructed from a failing Chromium test),
Clang allocates space for the return value in X8 when calling the
RetValShouldNotBePassedInX8 instance member function (compiled with clang
--target=aarch64-windows-msvc -Os, reproducer at https://godbolt.org/z/rG5vqj).
main: ; @main
sub sp, sp, #80 ; =80
str x30, [sp, #64] ; 8-byte Folded Spill
adrp x8, "??_7B@@6B@"
add x8, x8, "??_7B@@6B@"
str x8, [sp, #72]
add x0, sp, #72 ; =72 (x0 contains $this)
add x8, sp, #8 ; =8 (Return space allocated in
x8)
bl "?RetValShouldNotBePassedInX8@B@@UEAA?AUBAR_STRUCT@@XZ"
ldr w0, [sp, #8]
ldr x30, [sp, #64] ; 8-byte Folded Reload
add sp, sp, #80 ; =80
ret
MSVC's output (https://godbolt.org/z/x9aPjG):
|main| PROC
|$LN8|
str lr,[sp,#-0x10]!
sub sp,sp,#0x40
add x1,sp,#8 (Return space allocated in x1)
mov x0,sp (x0 contains $this)
bl |virtual BAR_STRUCT B::RetValShouldNotBePassedInX8(void)
__ptr64|
ldr w0,[sp,#8]
add sp,sp,#0x40
ldr lr,[sp],#0x10
ret
I reached out to Microsoft and they've confirmed that non-static member
functions always pass the return address in x1, and not x8[1]. They've updated
the official ABI documentation[2] to reflect this. This issue doesn't appear to
crop up very much in production because normally the value that's returned is
not aggregate by their definition (in which case, the return value address is
passed in x1 and everything's fine), but some Chromium/Edge components (in
particular the dawn_end2end_tests test suite) are affected and crash because of
this.
[1]
https://developercommunity.visualstudio.com/content/problem/1152955/arm64-abi-inconsistent-handling-of-abi-structs.html
[2]
https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=vs-2019#return-values
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs