New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-6142] structs are incorrectly exploded with $@convention(c) on some targets #48697
Comments
reduced.swift:
Inputs/usr/include/SRoA.h:
Inputs/usr/include/module.map:
|
cc @rjmccall, aschwaighofer@apple.com (JIRA User) |
Currently, IRGen (in GenCall.cpp) will unconditionally explode llvm::StructTypes if the clang::CodeGen::ABIArgInfo type is Direct. John explained to me that clang::CodeGen::ABIArgInfo has extra state whether this expansion is allowed to happen (ABIArgInfo::getCanBeFlattened). I can see three places in GenCall.cpp that need to be modified to respect this flag: emitDirectForeignParameter, expandExternalSignatureTypes, emitDirectExternalArgument. |
Yeah, I was using `getCanBeFlattened`. However, I am having some issues with the threading of the `ArgInfo`. Note that this also causes some issues since I saw cases of `getCanBeFlattened` returning `true` for `i8*`. |
'i8*' is an llvm::PointerType not an llvm::StructType. clang's lib/CodeGen/CGCall.cpp is instructive. llvm::StructType *STy = dyn_cast<llvm::StructType>(AI.getCoerceToType());
if (AI.isDirect() && AI.getCanBeFlattened() && STy) {
... |
Agreed; I figured that out later, I just meant that we need a bit more checking 🙂 |
BTW, changing just one site was sufficient; however, that would still cause issues in `visitFullApplySite`. IRGenSIL is where I was missing access to the the `ArgABIInfo`. |
#12525 should address this issue, but there are a couple of failing tests it seems. |
Thank you! |
Additional Detail from JIRA
md5: 74f9d9208c50e942836c6b8c51917f6b
Issue Description:
IRGenCall currently explodes fields of structures when doing a FFI call into a function with the C calling convention. This would break on at least Linux ARM (hard float ABI), Windows ARM, PowerPC64, S390x all of which pass arguments differently. Linux ARM and Windows ARM pass the argument as a first class structure type (
struct {float, float}
) and PowerPC64 and s390x pass it as a singlei64
type.The text was updated successfully, but these errors were encountered: