diff --git a/compiler/src/dmd/backend/cgcod.d b/compiler/src/dmd/backend/cgcod.d index ead512fe521f..d3c249d6f450 100644 --- a/compiler/src/dmd/backend/cgcod.d +++ b/compiler/src/dmd/backend/cgcod.d @@ -113,8 +113,6 @@ regm_t msavereg; // Mask of registers that we would like to save. regm_t mfuncreg; // Mask of registers preserved by a function regm_t allregs; // ALLREGS optionally including mBP - -int dfoidx; /* which block we are in */ } /********************************* @@ -252,11 +250,11 @@ void codgen(Symbol *sfunc) cgreg_reset(); foreach (i, b; dfo[]) { - dfoidx = cast(int)i; + cgstate.dfoidx = cast(int)i; regcon.used = msavereg | regcon.cse.mval; // registers already in use blcodgen(b); // gen code in depth-first order //printf("b.Bregcon.used = %s\n", regm_str(b.Bregcon.used)); - cgreg_used(dfoidx, b.Bregcon.used); // gather register used information + cgreg_used(cgstate.dfoidx, b.Bregcon.used); // gather register used information } } else @@ -1368,14 +1366,14 @@ private void blcodgen(block *bl) sflsave[i] = s.Sfl; if (regParamInPreg(s) && regcon.params & s.Spregm() && - vec_testbit(dfoidx,s.Srange)) + vec_testbit(cgstate.dfoidx,s.Srange)) { // regcon.used |= s.Spregm(); } if (s.Sfl == FLreg) { - if (vec_testbit(dfoidx,s.Srange)) + if (vec_testbit(cgstate.dfoidx,s.Srange)) { regcon.mvar |= s.Sregm; if (s.Sclass == SC.fastpar || s.Sclass == SC.shadowreg) @@ -1384,11 +1382,11 @@ private void blcodgen(block *bl) } else if (s.Sflags & SFLspill) { - if (vec_testbit(dfoidx,s.Srange)) + if (vec_testbit(cgstate.dfoidx,s.Srange)) { anyspill = cast(int)(i + 1); cgreg_spillreg_prolog(bl,s,cdbstore,cdbload); - if (vec_testbit(dfoidx,s.Slvreg)) + if (vec_testbit(cgstate.dfoidx,s.Slvreg)) { s.Sfl = FLreg; regcon.mvar |= s.Sregm; diff --git a/compiler/src/dmd/backend/cod1.d b/compiler/src/dmd/backend/cod1.d index 5f4540beac04..bbaaecdab106 100644 --- a/compiler/src/dmd/backend/cod1.d +++ b/compiler/src/dmd/backend/cod1.d @@ -3990,7 +3990,7 @@ static if (0) if (config.flags4 & CFG4optimized) { // If symbol is live in this basic block and // isn't already in a register - if (s.Srange && vec_testbit(dfoidx, s.Srange) && + if (s.Srange && vec_testbit(cgstate.dfoidx, s.Srange) && s.Sfl != FLreg) { // Then symbol must be allocated on stack needframe = true; diff --git a/compiler/src/dmd/backend/cod3.d b/compiler/src/dmd/backend/cod3.d index e78f79c844d6..ef5cd1183e74 100644 --- a/compiler/src/dmd/backend/cod3.d +++ b/compiler/src/dmd/backend/cod3.d @@ -941,7 +941,7 @@ void outblkexitcode(ref CodeBuilder cdb, block *bl, ref int anyspill, const(char { Symbol *s = globsym[i]; if (s.Sflags & SFLspill && - vec_testbit(dfoidx,s.Srange)) + vec_testbit(cgstate.dfoidx,s.Srange)) { s.Sfl = sflsave[i]; // undo block register assignments cgreg_spillreg_epilog(bl,s,cdbstore,cdbload); diff --git a/compiler/src/dmd/backend/code.d b/compiler/src/dmd/backend/code.d index 2800e897a4ac..a737076ec8c0 100644 --- a/compiler/src/dmd/backend/code.d +++ b/compiler/src/dmd/backend/code.d @@ -188,6 +188,8 @@ struct CGstate targ_size_t funcoffset; // offset of start of function targ_size_t retoffset; // offset from start of func to ret code targ_size_t retsize; // size of function return code + + int dfoidx; // which block we are in } public import dmd.backend.nteh;