Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[OWBugzilla] [Bug 490] __stdcall should return small structs in EAX:EDX

1 view
Skip to first unread message

bugzill...@www.openwatcom.org

unread,
Sep 5, 2009, 8:30:36 AM9/5/09
to openwatco...@openwatcom.org
http://bugzilla.openwatcom.org/show_bug.cgi?id=490


mnec...@yahoo.com changed:

What |Removed |Added
----------------------------------------------------------------------------
Severity|critical |major
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1


------- Comment #3 from mnec...@yahoo.com 2009-09-05 05:30 PST8PDT -------
This is more of a problem with the code generator than the compiler(s). I can
confirm that the generated code is incorrect. This affects the __stdcall and
__fastcall calling convention which both return small structures in EDX:EAX.
Additionally, Microsoft's __cdecl also returns small structures in registers
and Open Watcom's doesn't.

Curiously, correct code is generated for structures that are only 32-bit. Those
will be returned in EAX, even if the code isn't quite as efficient as it could
be.

Hmm. For reasons totally unclear to me, in cg/intel/386/c/386ptype.c, line 111
is commented out. That prevents 8-byte structs from being returned in
registers, though 4-byte and smaller structs still will be returned in
registers. The commented out line has been there since Watcom 11.0, but there's
no hint as to why it's commented out. I wonder if it was copied from the i86
version, where it *should* be commented out.

The obvious problem with enabling 8-byte structures to be returned in registers
is that it will break binary compatibility with existing binaries in an
extremely nasty way. We might need a backwards compatibility switch to force
the old behavior. For __stdcall or __fastcall we might just say, OK, we fixed a
bug and don't care about old broken binaries. But the change would (and IMO
should!) also affect the default Watcom calling convention, and changing that
should not be undertaken lightly. My only hope is that returning 8-byte structs
is not that common.

16-bit calling conventions need to be investigated as well, although right now
I don't see any problem there; __fastcall is returning 4-byte structs in DX:AX
as it should. However, the default Watcom calling convention should do the
same... which would definitely mean breaking backwards compatibility. Sigh.

Comments welcome.


--
Configure bugmail: http://bugzilla.openwatcom.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

0 new messages