Skip to content

Commit

Permalink
gsroa: allow anything that fits in a slice to be a slice
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 21, 2019
1 parent 0a8fdf2 commit fb9b6db
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/dmd/backend/gsroa.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ extern (D) private void sliceStructs_Gather(const symtab_t* symtab, SymInfo[] si
ty = TYnptr;
}
sia[si].accessSlice = true;
sia[si].ty[n] = tybasic(e.Ety);
if (sz == SLICESIZE)
sia[si].ty[n] = tybasic(e.Ety);
}
else
{
Expand Down Expand Up @@ -214,7 +215,7 @@ extern (D) private void sliceStructs_Replace(symtab_t* symtab, const SymInfo[] s
else // the nth slice
{
e.EV.Vsym = symtab.tab[sia[si].si0 + n];
e.EV.Voffset = 0;
e.EV.Voffset -= n * SLICESIZE;
//printf("replaced with:\n");
//elem_print(e);
}
Expand Down Expand Up @@ -269,6 +270,7 @@ void sliceStructs(symtab_t* symtab, block* startblock)
//printf("slice1: %s\n", s.Sident.ptr);

if (!(s.Sflags & SFLunambig)) // if somebody took the address of s
//if ((s.Sflags & (GTregcand | SFLunambig)) != (GTregcand | SFLunambig))
{
sia[si].canSlice = false;
continue;
Expand Down Expand Up @@ -409,13 +411,17 @@ enum NOTSLICE = -1;
int nthSlice(const(elem)* e)
{
const sz = tysize(e.Ety);
if (sz == SLICESIZE)
{
if (e.EV.Voffset == 0)
return 0;
if (e.EV.Voffset == SLICESIZE)
return 1;
}
const sliceSize = SLICESIZE;

/* See if e fits in a slice
*/
const lwr = e.EV.Voffset;
const upr = lwr + sz;
if (0 <= lwr && upr <= sliceSize)
return 0;
if (sliceSize <= lwr && upr <= sliceSize * 2)
return 1;

return NOTSLICE;
}

Expand Down

0 comments on commit fb9b6db

Please sign in to comment.