Skip to content

Commit

Permalink
cgirgen: instrument with frameMsg
Browse files Browse the repository at this point in the history
To keep the overhead at a reasonable level, only the top-level
procedures `stmtToIr` and `exprToIr` are instrumented.
  • Loading branch information
zerbina committed Aug 6, 2024
1 parent 398af41 commit f88d1f2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler/backend/cgirgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ import std/options as std_options
from compiler/ast/ast import newSym, newType, rawAddSon
from compiler/sem/semdata import makeVarType

when defined(nimCompilerStacktraceHints):
import compiler/utils/debugutils

type
TranslateCl = object
graph: ModuleGraph
Expand Down Expand Up @@ -557,6 +560,9 @@ proc stmtToIr(tree: MirBody, env: MirEnv, cl: var TranslateCl,
let n {.cursor.} = tree.get(cr)
let info = cr.info ## the source information of `n`

when defined(nimCompilerStacktraceHints):
frameMsg(cl.graph.config, info)

template to(kind: CgNodeKind, args: varargs[untyped]) =
stmts.add newStmt(kind, info, args)

Expand Down Expand Up @@ -683,6 +689,9 @@ proc exprToIr(tree: MirBody, cl: var TranslateCl,
let n {.cursor.} = get(tree, cr)
let info = cr.info

when defined(nimCompilerStacktraceHints):
frameMsg(cl.graph.config, info)

template op(kind: CgNodeKind, e: CgNode): CgNode =
newOp(kind, info, cl.map(n.typ), e)

Expand Down

0 comments on commit f88d1f2

Please sign in to comment.