diff --git a/compiler/backend/ccgcalls.nim b/compiler/backend/ccgcalls.nim index 6f3fb9f4f837..ee46fb84894b 100644 --- a/compiler/backend/ccgcalls.nim +++ b/compiler/backend/ccgcalls.nim @@ -364,33 +364,7 @@ proc genClosureCall(p: BProc, le, ri: CgNode, d: var TLoc) = genCallPattern() exitCall(p, ri[0], canRaise) -proc notYetAlive(p: BProc, n: CgNode): bool {.inline.} = - let r = getRoot(n) - result = r != nil and r.kind == cnkLocal and p.locals[r.local].k == locNone - -proc isInactiveDestructorCall(p: BProc, e: CgNode): bool = - #[ Consider this example. - - var :tmpD_3281815 - try: - if true: - return - let args_3280013 = - wasMoved_3281816(:tmpD_3281815) - `=_3280036`(:tmpD_3281815, [1]) - :tmpD_3281815 - finally: - `=destroy_3280027`(args_3280013) - - We want to return early but the 'finally' section is traversed before - the 'let args = ...' statement. We exploit this to generate better - code for 'return'. ]# - result = e.len == 2 and e[0].kind == cnkSym and - e[0].sym.name.s == "=destroy" and notYetAlive(p, e[1].operand) - proc genAsgnCall(p: BProc, le, ri: CgNode, d: var TLoc) = - if p.withinBlockLeaveActions > 0 and isInactiveDestructorCall(p, ri): - return if ri[0].typ.skipTypes({tyGenericInst, tyAlias, tySink}).callConv == ccClosure: genClosureCall(p, le, ri, d) else: diff --git a/compiler/backend/ccgexprs.nim b/compiler/backend/ccgexprs.nim index 57ae0dec144a..1ea9106fe951 100644 --- a/compiler/backend/ccgexprs.nim +++ b/compiler/backend/ccgexprs.nim @@ -1679,9 +1679,7 @@ proc skipAddr(n: CgNode): CgNode = proc genWasMoved(p: BProc; n: CgNode) = var a: TLoc let n1 = n[1].skipAddr - if p.withinBlockLeaveActions > 0 and notYetAlive(p, n1): - discard - else: + if true: initLocExpr(p, n1, a, {lfWantLvalue}) resetLoc(p, a) #linefmt(p, cpsStmts, "#nimZeroMem((void*)$1, sizeof($2));$n", diff --git a/compiler/backend/compat.nim b/compiler/backend/compat.nim index dae9c48f0bf1..678e19e24bec 100644 --- a/compiler/backend/compat.nim +++ b/compiler/backend/compat.nim @@ -98,26 +98,6 @@ proc isDeepConstExpr*(n: CgNode): bool = else: result = false -proc getRoot*(n: CgNode): CgNode = - ## ``getRoot`` takes a *path* ``n``. A path is an lvalue expression - ## like ``obj.x[i].y``. The *root* of a path is the symbol that can be - ## determined as the owner; ``obj`` in the example. - case n.kind - of cnkSym: - if n.sym.kind in {skVar, skLet, skForVar}: - result = n - of cnkLocal: - result = n - of cnkFieldAccess, cnkArrayAccess, cnkTupleAccess, cnkCheckedFieldAccess: - result = getRoot(n[0]) - of cnkDerefView, cnkDeref, cnkObjUpConv, cnkObjDownConv, cnkHiddenAddr, - cnkAddr, cnkHiddenConv, cnkConv: - result = getRoot(n.operand) - of cnkCall: - if getMagic(n) == mSlice: - result = getRoot(n[1]) - else: discard - proc canRaiseConservative*(fn: CgNode): bool = ## Duplicate of `canRaiseConservative `_. # ``mNone`` is also included in the set, therefore this check works even for