aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-13 17:03:57 +0100
committerlemon <lsof@mailbox.org>2025-12-13 17:03:57 +0100
commit0266cfecae0832afd0dc6f97ae5a60214afd8f26 (patch)
tree89aa1048c6cc8b435f9a55f6022559b3f4314996
parentf403e250bf4474cead6a6cbe5e917488f39163e9 (diff)
regalloc: fixbug with phi move of stack <- stack
-rw-r--r--ir/builder.c3
-rw-r--r--ir/regalloc.c8
2 files changed, 5 insertions, 6 deletions
diff --git a/ir/builder.c b/ir/builder.c
index ee83961..3ddb5a6 100644
--- a/ir/builder.c
+++ b/ir/builder.c
@@ -218,8 +218,7 @@ useblk(struct function *fn, struct block *blk)
blk->lnext = fn->entry;
blk->lprev = fn->entry->lprev;
blk->lprev->lnext = blk;
- blk->id = blk->lprev->id + 1;
- ++fn->nblk;
+ blk->id = ++fn->nblk;
fn->entry->lprev = blk;
}
fn->curblk = blk;
diff --git a/ir/regalloc.c b/ir/regalloc.c
index 9abd3c6..bb7eff1 100644
--- a/ir/regalloc.c
+++ b/ir/regalloc.c
@@ -116,7 +116,7 @@ fixlive(struct function *fn)
} while ((blk = blk->lnext) != fn->entry);
if (ccopt.dbg.l) {
- DBG("<< After liveness fixup >>\n");
+ efmt("<< After liveness fixup >>\n");
irdump(fn);
}
if (defined != definedbuf) free(defined);
@@ -262,7 +262,7 @@ emitmove(enum irclass k, struct alloc dst, struct alloc src, struct block *blk,
else
reg = kisint(k) ? mctarg->gprscratch : mctarg->fprscratch;
mv.reg = reg+1;
- addstkslotref(insertinstr(blk, curi, mv).i, src.a*8);
+ addstkslotref(insertinstr(blk, curi++, mv).i, src.a*8);
} else reg = src.a;
if (dst.t == ASTACK) {
mv = mkinstr(Ostore8+ilog2(cls2siz[k]), 0, .r = mkref(RREG, reg));
@@ -1255,7 +1255,7 @@ regalloc(struct function *fn)
fillblkids(fn);
if (ccopt.dbg.r) {
- DBG("<< Before linear scan >>\n");
+ bfmt(ccopt.dbgout, "<< Before linear scan >>\n");
irdump(fn);
}
@@ -1292,7 +1292,7 @@ regalloc(struct function *fn)
vfree(&stkslotrefs);
if (ccopt.dbg.r) {
- DBG("<< After regalloc >>\n");
+ bfmt(ccopt.dbgout, "<< After regalloc >>\n");
irdump(fn);
}
}