Skip to content

Commit

Permalink
more arg passing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Oct 10, 2012
1 parent ca3f2ee commit 0747b15
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
7 changes: 7 additions & 0 deletions src/backend/cgcod.c
Expand Up @@ -1070,6 +1070,13 @@ void stackoffsets(int flags)

case SCshadowreg:
case SCparameter:
if (config.exe == EX_WIN64)
{
assert((Poffset & 7) == 0);
s->Soffset = Poffset;
Poffset += 8;
break;
}
Poffset = align(REGSIZE,Poffset); /* align on word stack boundary */
if (I64 && alignsize == 16 && Poffset & 8)
Poffset += 8;
Expand Down
31 changes: 21 additions & 10 deletions src/backend/cod1.c
Expand Up @@ -2424,20 +2424,31 @@ int FuncParamRegs::alloc(type *t, tym_t ty, reg_t *preg1, reg_t *preg2)
// If struct just wraps another type
if (tybasic(ty) == TYstruct && tybasic(t->Tty) == TYstruct)
{
type *targ1 = t->Ttag->Sstruct->Sarg1type;
type *targ2 = t->Ttag->Sstruct->Sarg2type;
if (targ1)
if (config.exe == EX_WIN64)
{
t = targ1;
ty = t->Tty;
if (targ2)
/* Structs occupy a general purpose register, regardless of the struct
* size or the number & types of its fields.
*/
t = NULL;
ty = TYnptr;
}
else
{
type *targ1 = t->Ttag->Sstruct->Sarg1type;
type *targ2 = t->Ttag->Sstruct->Sarg2type;
if (targ1)
{
t2 = targ2;
ty2 = t2->Tty;
t = targ1;
ty = t->Tty;
if (targ2)
{
t2 = targ2;
ty2 = t2->Tty;
}
}
else if (I64 && !targ2)
return 0;
}
else if (I64 && !targ2)
return 0;
}

reg_t *preg = preg1;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/cod3.c
Expand Up @@ -2999,7 +2999,7 @@ code* prolog_loadparams(tym_t tyf, bool pushalloc, regm_t* namedargs)

type *t = s->Stype;
type *t2 = NULL;
if (tybasic(t->Tty) == TYstruct)
if (tybasic(t->Tty) == TYstruct && config.exe != EX_WIN64)
{ type *targ1 = t->Ttag->Sstruct->Sarg1type;
t2 = t->Ttag->Sstruct->Sarg2type;
if (targ1)
Expand Down Expand Up @@ -3137,7 +3137,7 @@ code* prolog_loadparams(tym_t tyf, bool pushalloc, regm_t* namedargs)

type *t = s->Stype;
type *t2 = NULL;
if (tybasic(t->Tty) == TYstruct)
if (tybasic(t->Tty) == TYstruct && config.exe != EX_WIN64)
{ type *targ1 = t->Ttag->Sstruct->Sarg1type;
t2 = t->Ttag->Sstruct->Sarg2type;
if (targ1)
Expand Down
2 changes: 1 addition & 1 deletion test/runnable/test42.d
Expand Up @@ -668,7 +668,7 @@ int foo45(int i)

void test45()
{
version (Windows) // this test fails in -release because asserts will be removed
version (Win32) // this test fails in -release because asserts will be removed
{
assert(foo45(0)==2);
try{
Expand Down

0 comments on commit 0747b15

Please sign in to comment.