MCPcopy Create free account
hub / github.com/python/mypy / analyze_must_defined_regs

Function analyze_must_defined_regs

mypyc/analysis/dataflow.py:365–389  ·  view source on GitHub ↗

Calculate always defined registers at each CFG location. This analysis can work before exception insertion, since it is a sound assumption that registers defined in a block might not be initialized in its error handler. A register is defined if it has a value along all paths from t

(
    blocks: list[BasicBlock],
    cfg: CFG,
    initial_defined: set[Value],
    regs: Iterable[Value],
    strict_errors: bool = False,
)

Source from the content-addressed store, hash-verified

363
364
365def analyze_must_defined_regs(
366 blocks: list[BasicBlock],
367 cfg: CFG,
368 initial_defined: set[Value],
369 regs: Iterable[Value],
370 strict_errors: bool = False,
371) -> AnalysisResult[Value]:
372 """Calculate always defined registers at each CFG location.
373
374 This analysis can work before exception insertion, since it is a
375 sound assumption that registers defined in a block might not be
376 initialized in its error handler.
377
378 A register is defined if it has a value along all paths from the
379 initial location.
380 """
381 return run_analysis(
382 blocks=blocks,
383 cfg=cfg,
384 gen_and_kill=DefinedVisitor(strict_errors=strict_errors),
385 initial=initial_defined,
386 backward=False,
387 kind=MUST_ANALYSIS,
388 universe=set(regs),
389 )
390
391
392class BorrowedArgumentsVisitor(BaseAnalysisVisitor[Value]):

Callers 2

insert_ref_count_opcodesFunction · 0.90
insert_uninit_checksFunction · 0.90

Calls 3

run_analysisFunction · 0.85
DefinedVisitorClass · 0.85
setClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…