Skip to content

Commit 13ed588

Browse files
committed
3rd attempt to make Bsucc an array
1 parent 2990bc7 commit 13ed588

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

compiler/src/dmd/backend/blockopt.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ void block_free(ref BlockOpt bo, block* b)
307307
if (b.Belem)
308308
el_free(b.Belem);
309309
list_free(&b.Bsucc,FPNULL);
310+
b.Bsucca.dtor();
310311
b.Bpred.dtor();
311312
if (OPTIMIZER)
312313
block_optimizer_free(b);

compiler/src/dmd/backend/cc.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ nothrow:
205205
block* Bnext; // pointer to next block in list
206206
list_t Bsucc; // linked list of pointers to successors
207207
// of this block
208+
Barray!(block*) Bsucca; // and the successor array copy of Bsucc
208209
Barray!(block*) Bpred; // and the predecessor array
209210
int Bindex; // into created object stack
210211
int Bendindex; // index at end of block

compiler/src/dmd/backend/x86/cgcod.d

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void codgen(Symbol* sfunc)
8888
/***********************
8989
* Same as codgen(), but adding in CGstate argument
9090
* Params:
91-
* cg = code generator state
91+
* cg = code generator state
9292
* sfunc = function to generate code for
9393
*/
9494
private @trusted
@@ -98,6 +98,14 @@ void codgenx(ref CGstate cg, Symbol* sfunc)
9898
assert(sfunc == funcsym_p);
9999
assert(cseg == funcsym_p.Sseg);
100100

101+
// Convert Bsucc to Bsucca
102+
for (block* b = bo.startblock; b; b = b.Bnext)
103+
{
104+
foreach (bp; ListRange(b.Bsucc))
105+
b.Bsucca.push(list_block(bp));
106+
assert(list_nitems(b.Bsucc) == b.Bsucca.length);
107+
}
108+
101109
cgreg_init();
102110
CSE.initialize();
103111

@@ -2131,7 +2139,7 @@ bool cssave(elem* e, regm_t regm, bool opsflag)
21312139
/*if (e.Ecount && e.Ecount == e.Ecomsub)*/
21322140
if (e.Ecount && e.Ecomsub)
21332141
{
2134-
CGstate* cg = &cgstate;
2142+
CGstate* cg = &cgstate;
21352143
if (!opsflag && cg.pass != BackendPass.final_ && (I32 || I64))
21362144
return false;
21372145

@@ -2579,7 +2587,7 @@ private void loadcse(ref CodeBuilder cdb,elem* e,reg_t reg,regm_t regm)
25792587
//printf("CSE[%d] = %p, regm = %s\n", i, cse.e, regm_str(cse.regm));
25802588
if (cse.regm & regm)
25812589
{
2582-
CGstate* cg = &cgstate;
2590+
CGstate* cg = &cgstate;
25832591
cg.reflocal = true;
25842592
cse.flags |= CSEload; /* it was loaded */
25852593
cg.regcon.cse.value[reg] = e;

compiler/src/dmd/backend/x86/cgreg.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ void cgreg_spillreg_epilog(block* b,Symbol* s,ref CodeBuilder cdbstore, ref Code
607607
const bi = b.Bdfoidx;
608608
//printf("cgreg_spillreg_epilog(block %d, s = '%s')\n",bi,s.Sident.ptr);
609609
//assert(b.bc == BC.goto_);
610-
if (!cgreg_gotoepilog(b.nthSucc(0), s))
610+
if (!cgreg_gotoepilog(b.Bsucca[0], s))
611611
return;
612612

613613
const live = vec_testbit(bi,s.Slvreg) != 0;
614614

615615
// Look at successors to see if we need to load in/out of register
616-
foreach (bl; ListRange(b.Bsucc))
616+
foreach (bs; b.Bsucca[])
617617
{
618-
const bpi = list_block(bl).Bdfoidx;
618+
const bpi = bs.Bdfoidx;
619619
if (!vec_testbit(bpi,s.Srange))
620620
continue;
621621
if (vec_testbit(bpi,s.Slvreg))

0 commit comments

Comments
 (0)