Skip to content
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

Issue 13955 - 64 bit C ABI not followed for passing structs with mixed floating types #4265

Merged
merged 1 commit into from
Jan 8, 2015

Conversation

yebblies
Copy link
Member

@yebblies yebblies commented Jan 8, 2015

Check code in argtypes.c should be checking that both types can be passed in xmm registers.

https://issues.dlang.org/show_bug.cgi?id=13955

@@ -429,7 +429,8 @@ TypeTuple *toArgTypes(Type *t)
{
if (t1->isfloating() && t2->isfloating())
{
if (t1->ty == Tfloat64 && t2->ty == Tfloat64)
if ((t1->ty == Tfloat32 || t1->ty == Tfloat64) &&
(t2->ty == Tfloat32 | t2->ty == Tfloat64))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the xor here is a typo, and it should instead be logical or.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yeah, fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bitwise or... I always get my or's mixed up. :)

…mixed floating types

Check code in argtypes.c should be checking that both types can be passed in xmm registers.
@ibuclaw
Copy link
Member

ibuclaw commented Jan 8, 2015

Auto-merge toggled on

ibuclaw added a commit that referenced this pull request Jan 8, 2015
Issue 13955 - 64 bit C ABI not followed for passing structs with mixed floating types
@ibuclaw ibuclaw merged commit ccec6fb into dlang:master Jan 8, 2015
@dnadlinger
Copy link
Member

@yebblies: Did you find this using a fuzzer? Then I don't need to finish mine. ;)

@yebblies yebblies deleted the issue13955 branch January 9, 2015 02:34
@yebblies
Copy link
Member Author

yebblies commented Jan 9, 2015

@klickverbot Yep, here it is:

https://gist.github.com/yebblies/a848bd1326b380b471e8

@ibuclaw Thanks.

@dnadlinger
Copy link
Member

@yebblies: Thanks, this will come in handy for me soon.

kinke referenced this pull request in kinke/ldc Feb 7, 2015
…ng point numbers.

DMD is clearly wrong here for structs > 8 bytes and <= 16 bytes.
It passes the whole struct in memory if either exactly one field is a fp number
or if both fields are fp numbers and they are not both doubles.
The official docs (and Clang) don't have such a restriction. A simple struct
{ double a; int b; } is passed as if it were two separate arguments; a in a FP
register if available, b in a GP register if available.

This change probably leads to issues when trying to fetch such a struct passed
as vararg via va_arg; druntime (core.stdc.stdarg and core.vararg) would most
likely need to be fixed too.
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.

3 participants