This is an archive of the discontinued LLVM Phabricator instance.

[X86][ABI] Do not return float/double from x87 registers when x87 is disabled
ClosedPublic

Authored by pengfei on Oct 20 2021, 8:32 AM.

Details

Summary

This is aligned with GCC's behavior.
Also, alias -mno-fp-ret-in-387 to -mno-x87, by which we can fix pr51498.

Diff Detail

Event Timeline

pengfei created this revision.Oct 20 2021, 8:32 AM
pengfei requested review of this revision.Oct 20 2021, 8:32 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 20 2021, 8:32 AM
pengfei planned changes to this revision.Oct 20 2021, 7:25 PM

Found a mistake, working on that.

pengfei updated this revision to Diff 381179.Oct 21 2021, 1:47 AM

Fix bugs. Ready for review now.

Yes. I mentioned pr51498 in commit message :)

sorry, I missed the PR # in the description; my mistake.

clang/test/Driver/x86-target-features.c
5

If you split this test and the above change to clang/include/clang/Driver/Options.td into a separate patch on Phab, I'd be happy to accept that!

Otherwise someone more familiar with x86 will have to take a look at the below changes.

pengfei added inline comments.Nov 15 2021, 4:47 AM
clang/test/Driver/x86-target-features.c
5

This is a simple alias. Spliting it doesn't solve the initial problem. I think it's better to commit it together with the backend change.

nickdesaulniers accepted this revision.Nov 16 2021, 12:55 PM

Just a comment on the ECX bit, otherwise this patch looks fine to me. Someone with more x86 knowledge may want to take a look though. Thanks for the patch!

llvm/lib/Target/X86/X86CallingConv.td
279

Is there a test case that exercises the assignment to %ecx?

This revision is now accepted and ready to land.Nov 16 2021, 12:55 PM
pengfei updated this revision to Diff 387855.Nov 17 2021, 12:32 AM
  1. Add support for f80.
  2. Add test case for 3 return values.
pengfei added inline comments.Nov 17 2021, 12:38 AM
llvm/lib/Target/X86/X86CallingConv.td
279

Add one test case for it, though I don't believe we can really generate it from frontend.

nickdesaulniers accepted this revision.Nov 17 2021, 10:24 AM
nickdesaulniers added inline comments.
llvm/test/CodeGen/X86/no-ret-in-x87-reg.ll
148–151

:(

Thanks for the review!

llvm/test/CodeGen/X86/no-ret-in-x87-reg.ll
148–151

Will fix it as a follow up. D100091 aims to fix these problems.