Skip to content

[X86] Align f128 to 16 bytes when passing on x86-32 #138092

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented May 1, 2025

LLVM does not seem to enforce the required 16-byte alignment, which is causing an ABI mismatch.

This is not yet working locally.

Fixes: #77401

LLVM does not seem to enforce the required 16-byte alignment, which is
causing an ABI mismatch.

This is not yet working locally.
@tgross35 tgross35 changed the title Align f128 to 16 bytes when passing on x86 [X86] Align f128 to 16 bytes when passing on x86-32 May 1, 2025
@tgross35
Copy link
Contributor Author

tgross35 commented May 1, 2025

I'm not sure why this seems to have no effect; the tests at llvm/test/CodeGen/X86/fp128-abi.ll should fail since they need to be updated, but there is no change in codegen. I wonder if this is getting fixed up somewhere.

@arsenm
Copy link
Contributor

arsenm commented May 1, 2025

I'm not sure why this seems to have no effect; the tests at llvm/test/CodeGen/X86/fp128-abi.ll should fail since they need to be updated, but there is no change in codegen. I wonder if this is getting fixed up somewhere.

fp128 is not a legal type, so this won't reach here (this is a super frustrating detail of how calling convention handling is implemented, it would be easier if the backend directly consumed the original type)

@tgross35
Copy link
Contributor Author

tgross35 commented May 1, 2025

Should it be made a legal type? I’m not sure what the exact definition of that is, but it is in the i386 ABI as of recent versions to be returned and (presumably, since I haven’t seen otherwise) passed in memory.

@arsenm
Copy link
Contributor

arsenm commented May 1, 2025

Should it be made a legal type?

No. There are no f128 registers or operations

@tgross35
Copy link
Contributor Author

tgross35 commented May 1, 2025

How does stack alignment get handled for non-legal types, or where does this need to get fixed up? I’m surprised passing doesn’t use the type’s natural alignment.

@arsenm
Copy link
Contributor

arsenm commented May 1, 2025

How does stack alignment get handled for non-legal types, or where does this need to get fixed up? I’m surprised passing doesn’t use the type’s natural alignment.

The type is broken up into legal pieces according to getRegisterTypeForCallingConv + getNumRegistersForCallingConv, and those pieces are processed by the call lowering. This code is entirely disconnected from the decision of where to pass the value, in a register or at some stack offset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[X86][clang] 128bit floating-point operations in x86 machines
2 participants