aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--c.c7
-rw-r--r--lex.c4
-rw-r--r--regalloc.c4
3 files changed, 10 insertions, 5 deletions
diff --git a/c.c b/c.c
index c214ced..62e8bbe 100644
--- a/c.c
+++ b/c.c
@@ -3423,12 +3423,12 @@ genswitch(struct comp *cm, struct function *fn, const struct expr *ex)
EMITS {
struct block *next = i < st.cases.n - 1 ? newblk(fn) : st.bdefault;
putcondbranch(fn, addinstr(fn, mkinstr(Oequ, k, .l = sel, .r = mkintcon(k, c.val))), c.blk, next);
- useblk(fn, next);
+ if (next != st.bdefault) useblk(fn, next);
}
}
vfree(&st.cases);
if (fn->curblk != end) {
- EMITS putbranch(fn, end);
+ if (fn->curblk) EMITS putbranch(fn, end);
useblk(fn, end);
}
}
@@ -3517,7 +3517,8 @@ stmt(struct comp *cm, struct function *fn)
terminates = 0;
} else {
EMITS {
- if (!terminates) putbranch(fn, end = newblk(fn));
+ end = newblk(fn);
+ if (!terminates) putbranch(fn, end);
useblk(fn, fl);
}
terminates &= stmt(cm, fn);
diff --git a/lex.c b/lex.c
index 6dbc324..e668500 100644
--- a/lex.c
+++ b/lex.c
@@ -1168,6 +1168,7 @@ expandfnmacro(struct lexer *lx, struct span *span, struct macro *mac)
goto Redo;
}
tk.t = TKSTRLIT;
+ tk.wide = 0;
tk.s = buf.buf != tmp ? buf.buf : alloccopy(lx->tmparena, buf.buf, buf.len, 1);
tk.len = buf.len-1;
vpush(&rlist2, tk);
@@ -1771,6 +1772,7 @@ mac__file__handler(struct lexer *lx, struct token *tk)
{
tk->t = TKSTRLIT;
tk->s = getfilename(lx->fileid);
+ tk->wide = 0;
tk->len = strlen(tk->s);
}
@@ -1797,6 +1799,7 @@ mac__date__handler(struct lexer *lx, struct token *tk)
time_t tm = time(NULL);
struct tm *ts = localtime(&tm);
tk->t = TKSTRLIT;
+ tk->wide = 0;
tk->len = 11;
if (ts) {
bfmt(&wbuf, "%S %2d %4d%c",
@@ -1818,6 +1821,7 @@ mac__time__handler(struct lexer *lx, struct token *tk)
time_t tm = time(NULL);
struct tm *ts = localtime(&tm);
tk->t = TKSTRLIT;
+ tk->wide = 0;
tk->len = 8;
if (ts) {
bfmt(&wbuf, "%.2d:%.2d:%.2d%c", ts->tm_hour, ts->tm_min, ts->tm_sec, 0);
diff --git a/regalloc.c b/regalloc.c
index 165b1cb..64dcfac 100644
--- a/regalloc.c
+++ b/regalloc.c
@@ -82,7 +82,7 @@ fixlive(struct function *fn)
struct bitset definedbuf[4] = {0};
struct bitset *defined = definedbuf;
- if (BSSIZE(ninstr) >= sizeof(definedbuf))
+ if (BSSIZE(ninstr) >= arraylength(definedbuf))
defined = xcalloc(sizeof *defined * BSSIZE(ninstr));
npendingphi = 0;
@@ -1010,7 +1010,7 @@ devirt(struct rega *ra, struct block *blk)
if (nspill > 0) assert(ins->op != Ocall);
/* devirtualize destination */
- alloc = (it = &ra->intervals.temps[temp]) && it->nrange ? &it->alloc : NULL;
+ alloc = temp < ra->intervals.count && (it = &ra->intervals.temps[temp]) && it->nrange ? &it->alloc : NULL;
if (alloc && alloc->t == ASTACK) {
int store = Ostore1 + ilog2(cls2siz[insrescls(*ins)]);
/* t was spilled, gen store */