summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-09-28 19:12:08 +0800
committerGitHub <noreply@github.com>2022-09-28 13:12:08 +0200
commitfe8feb46c6b69d2a2b63c83af88d0f9f03a31435 (patch)
tree134e9e803a0e083b6d1418d8c7ff4896b8b518f7 /compiler
parent95614089ac9ddd61de834a2fb1454b5d159acb35 (diff)
downloadNim-fe8feb46c6b69d2a2b63c83af88d0f9f03a31435.tar.gz
fixes #19457 seqs are not properly updated in loop with ARC/ORC (#19922)
* test CI

* fixes #19457

* add comments

Co-authored-by: sandytypical <43030857+xflywind@users.noreply.github.com>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/varpartitions.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim
index 403aca38c..4841a0c47 100644
--- a/compiler/varpartitions.nim
+++ b/compiler/varpartitions.nim
@@ -767,6 +767,11 @@ proc traverse(c: var Partitions; n: PNode) =
     #     mutate(graph)
     #     connect(graph, cursorVar)
     for child in n: traverse(c, child)
+
+    if n.kind == nkWhileStmt:
+      traverse(c, n[0])
+      # variables in while condition has longer alive time than local variables 
+      # in the while loop body
   else:
     for child in n: traverse(c, child)
 
@@ -854,6 +859,11 @@ proc computeLiveRanges(c: var Partitions; n: PNode) =
     inc c.inLoop
     for child in n: computeLiveRanges(c, child)
     dec c.inLoop
+
+    if n.kind == nkWhileStmt:
+      computeLiveRanges(c, n[0])
+      # variables in while condition has longer alive time than local variables 
+      # in the while loop body
   of nkElifBranch, nkElifExpr, nkElse, nkOfBranch:
     inc c.inConditional
     for child in n: computeLiveRanges(c, child)