@@ -2170,20 +2170,6 @@ proc addHcrInitGuards(p: BProc, n: PNode, inInitGuard: var bool) =
2170
2170
2171
2171
genStmts(p, n)
2172
2172
2173
- proc handleProcGlobals(m: BModule) =
2174
- var procGlobals: seq[PNode] = move m.g.graph.procGlobals
2175
-
2176
- for i in 0..<procGlobals.len:
2177
- var stmts = newBuilder("")
2178
-
2179
- # fixes recursive calls #24997
2180
- swap stmts, m.preInitProc.s(cpsStmts)
2181
- genStmts(m.preInitProc, procGlobals[i])
2182
- swap stmts, m.preInitProc.s(cpsStmts)
2183
-
2184
- handleProcGlobals(m)
2185
- m.preInitProc.s(cpsStmts).add stmts.extract()
2186
-
2187
2173
proc genTopLevelStmt*(m: BModule; n: PNode) =
2188
2174
## Also called from `ic/cbackend.nim`.
2189
2175
if pipelineutils.skipCodegen(m.config, n): return
@@ -2199,7 +2185,13 @@ proc genTopLevelStmt*(m: BModule; n: PNode) =
2199
2185
else:
2200
2186
genProcBody(m.initProc, transformedN)
2201
2187
2202
- handleProcGlobals(m)
2188
+ var procGloals = move m.g.graph.procGlobals
2189
+ while true:
2190
+ if procGloals.len == 0:
2191
+ procGloals = move m.g.graph.procGlobals
2192
+ if procGloals.len == 0:
2193
+ break
2194
+ genStmts(m.preInitProc, procGloals.pop())
2203
2195
2204
2196
proc shouldRecompile(m: BModule; code: Rope, cfile: Cfile): bool =
2205
2197
if optForceFullMake notin m.config.globalOptions:
0 commit comments