diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-11-26 10:24:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-26 10:24:52 +0100 |
commit | da753c6a2eded5a382faf22dbf2a2ec1b1fc328f (patch) | |
tree | 6bfa2a4fb8f37cd320cbec8a7aae0c311bc84986 /compiler | |
parent | 3e7077ac7d2f4867ecabff09b730b6bc9356979d (diff) | |
download | Nim-da753c6a2eded5a382faf22dbf2a2ec1b1fc328f.tar.gz |
fixes #15076 (#16143)
* fixes #15076 * heapqueue: optimized for ARC * added another test case [backport:1.4] * code cleanup
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/injectdestructors.nim | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 869e8ecc8..34c11e06c 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -37,7 +37,7 @@ type g: ControlFlowGraph graph: ModuleGraph otherRead: PNode - inLoop, inSpawn: int + inLoop, inSpawn, inLoopCond: int uninit: IntSet # set of uninit'ed vars uninitComputed: bool idgen: IdGenerator @@ -296,8 +296,8 @@ proc isNoInit(dest: PNode): bool {.inline.} = result = dest.kind == nkSym and sfNoInit in dest.sym.flags proc genSink(c: var Con; dest, ri: PNode, isDecl = false): PNode = - if isUnpackedTuple(dest) or isDecl or - (isAnalysableFieldAccess(dest, c.owner) and isFirstWrite(dest, c)) or + if (c.inLoopCond == 0 and (isUnpackedTuple(dest) or isDecl or + (isAnalysableFieldAccess(dest, c.owner) and isFirstWrite(dest, c)))) or isNoInit(dest): # optimize sink call into a bitwise memcopy result = newTree(nkFastAsgn, dest, ri) @@ -629,8 +629,10 @@ template handleNestedTempl(n, processCall: untyped, willProduceStmt = false) = of nkWhileStmt: inc c.inLoop + inc c.inLoopCond result = copyNode(n) result.add p(n[0], c, s, normal) + dec c.inLoopCond var bodyScope = nestedScope(s) let bodyResult = p(n[1], c, bodyScope, normal) result.add processScope(c, bodyScope, bodyResult) |