Skip to content

Commit 0544fed

Browse files
committed
cgirgen: inline the wrapInHiddenAddr procedure
It only has a single callsite and is now short and simple enough to no longer warrant being a procedure. The assertion is also removed again.
1 parent 410630b commit 0544fed

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

compiler/backend/cgirgen.nim

+4-9
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import std/options as std_options
4646

4747
from compiler/ast/ast import newSym, newType, rawAddSon
4848
from compiler/sem/semdata import makeVarType
49-
from compiler/front/msgs import internalAssert
5049

5150
when defined(nimCompilerStacktraceHints):
5251
import compiler/utils/debugutils
@@ -167,13 +166,6 @@ proc newDefaultCall(info: TLineInfo, typ: PType): CgNode =
167166
## Produces the tree for a ``default`` magic call.
168167
newExpr(cnkCall, info, typ, [newMagicNode(mDefault, info)])
169168

170-
proc wrapInHiddenAddr(cl: TranslateCl, n: CgNode): CgNode =
171-
## Restores the ``cnkHiddenAddr`` around lvalue expressions passed to ``var``
172-
## parameters. The code-generators operating on ``CgNode``-IR depend on the
173-
## hidden addr to be present
174-
cl.graph.config.internalAssert(n.typ.skipTypes(abstractInst).kind != tyVar, n.info)
175-
newOp(cnkHiddenAddr, n.info, makeVarType(cl.owner, n.typ, cl.idgen), n)
176-
177169
proc genObjConv(n: CgNode, to: PType, info: TLineInfo): CgNode =
178170
## Depending on the type relationship between `n` and `to`, wraps `n` in
179171
## either an up- or down-conversion. Returns `nil` if no up- or down-
@@ -415,7 +407,10 @@ proc callToIr(tree: MirBody, cl: var TranslateCl, n: MirNode,
415407
# XXX: prevent this case from happening
416408
arg = newOp(cnkDerefView, arg.info, arg.typ.base, arg)
417409
elif mutable:
418-
arg = wrapInHiddenAddr(cl, arg)
410+
# much like in PNode AST, the CGIR AST also needs a ``cnkHiddenAddr``
411+
# tree wrapped around expressions in var argument positions
412+
arg = newOp(cnkHiddenAddr, arg.info,
413+
makeVarType(cl.owner, arg.typ, cl.idgen), arg)
419414

420415
result.add arg
421416

0 commit comments

Comments
 (0)