Open lhallam opened 4 years ago
@llvm/issue-subscribers-backend-x86
We just got bit by this as well where we linked to a MSVC compiled library that returned a SIMD type. I would like to fix this so that since I think not being compatible with the MSVC ABI is a bug.
If someone can point me in the right direction of where to look I can try to put up a PR.
cc @rnk @efriedma-quic @aganea
MicrosoftCXXABI::classifyReturnType in clang/lib/CodeGen/MicrosoftCXXABI.cpp is the code that handles this sort of thing. Assuming I'm understanding the issue correctly; this is specifically for instance methods of C++ classes, right?
Here is a simplified repro: https://godbolt.org/z/TM6rW738v
I think this is a better godbolt reproducer: https://godbolt.org/z/adxj84Tjq
The __m128
naming is significant, because that is a struct definition provided by xmmintrin.h
, which is different between MSVC and Clang.
We could return all vector types from C++ instance methods indirectly, but that includes user-defined vector types, which are not required to be ABI-compatible with MSVC. We probably can't reliably differentiate vector types provided by intrinsic headers, so that's probably the correct solution. Code is here: https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/MicrosoftCXXABI.cpp#L1177
Maybe this is a good first issue for a potential contributor.
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
test/
create fine-grained testing targets, so you can e.g. use make check-clang-ast
to only run Clang's AST tests.git clang-format HEAD~1
to format your changes.If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Lewis Hallam (lhallam)
clang-cl
returns inxmm0
, msvc takes a second hidden parameter to write to, so when the caller and callee come from objects created by different compilers any integer parameters are offset and the return value is incorrect.The visual studio documentation (https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-2019#return-values) seem to imply that clang's behaviour is correct, unless __m128 etc are considered user defined types.