diff options
| author | 2025-10-16 17:53:42 +0200 | |
|---|---|---|
| committer | 2025-10-16 17:53:42 +0200 | |
| commit | d051c17c70c86b3c9bbc0a0761203d97e8c662d0 (patch) | |
| tree | 0a4b1e27b5a7ef3092a476952727def0900d496a | |
| parent | 77b13b42643991fc8c2b8942ca167eb7bf156908 (diff) | |
various little bugs
| -rw-r--r-- | c.c | 7 | ||||
| -rw-r--r-- | lex.c | 4 | ||||
| -rw-r--r-- | regalloc.c | 4 |
3 files changed, 10 insertions, 5 deletions
@@ -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); @@ -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); @@ -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 */ |