Skip to content

Commit 977ea4d

Browse files
committed
mirflow, mir2cg: use dedicated statement kind for 'continue'
The statement is a terminator too, so the block folding and continuation inlining needs to know also needs to know about it.
1 parent 21e86a8 commit 977ea4d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/backend/mir2cg.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,8 +2814,6 @@ proc stmtToCgir(c; env; tree; n; stmts; bu) =
28142814
of mnkRaise:
28152815
c.emitLineTrace(env, c.prc.body.source[tree[n].info].info, stmts, bu)
28162816
c.emitRaise(env, tree[tree.last(n)], stmts, bu)
2817-
of mnkContinue:
2818-
c.emitRaise(env, tree[tree.last(n)], stmts, bu)
28192817
of mnkEmit, mnkAsm:
28202818
c.emitLineTrace(env, c.prc.body.source[tree[n].info].info, stmts, bu)
28212819
stmts.add c.emitToCgir(env, tree, n, bu)
@@ -3058,6 +3056,8 @@ proc toTree(c; env; tree; list: seq[Stmt], i: int, stmts, bu) =
30583056
of Raise:
30593057
c.useSourceLoc(tree[list[i].n].info, bu)
30603058
c.emitRaise(env, tree[tree.last(list[i].n)], stmts, bu)
3059+
of Continue:
3060+
c.emitRaise(env, tree[tree.last(list[i].n)], stmts, bu)
30613061
of Dispatch:
30623062
c.useSourceLoc(tree[list[i].n].info, bu)
30633063
if isSimpleCase(tree, list[i].n):

compiler/backend/mirflow.nim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type
1616
Break
1717
Return
1818
Raise
19+
Continue
1920
Stmts
2021
Scope
2122
Block
@@ -41,8 +42,9 @@ using
4142

4243
const
4344
withSub = {Block, Loop, Scope, If, Dispatch, Target, Try}
44-
terminators = {Loop, Dispatch, Break, Return, Raise}
45-
## stmts (block-like and not) that act as control-flow terminators
45+
terminators = {Loop, Dispatch, Break, Return, Raise, Continue}
46+
## statements (both block-like and not) that act as control-
47+
## flow terminators
4648

4749
iterator statements(tree): (int, NodePosition) =
4850
## Iterates over all MIR statement in order of appearance.
@@ -249,7 +251,7 @@ proc toStructured*(tree): seq[Stmt] =
249251
of mnkContinue:
250252
if tree[it, 0].kind != mnkUnwind:
251253
insertTry(tree.child(it, 0), labels[tree[it, 0].label])
252-
append(Stmt(kind: Stmts, n: it))
254+
append(Stmt(kind: Continue, n: it))
253255
of mnkDef, mnkDefCursor, mnkAsgn, mnkInit, mnkSwitch, mnkVoid:
254256
let e = tree.last(it)
255257
if tree[e].kind == mnkCheckedCall:

0 commit comments

Comments
 (0)