From c200bfc189c037997b5e4e20f33a5880db7e69b3 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 25 Aug 2026 09:55:48 +0100 Subject: [PATCH] Check for infinite cycles in the CFG and report if the procedure is not marketed as diverging --- src/check_asm_cfg.cpp | 60 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/src/check_asm_cfg.cpp b/src/check_asm_cfg.cpp index b846264a1..2f1ce03c7 100644 --- a/src/check_asm_cfg.cpp +++ b/src/check_asm_cfg.cpp @@ -1,6 +1,8 @@ struct AsmBlock { - i32 first, last; - Array succs; + i32 first; // instruction index + i32 last; + + Array succs; u16 in_defs; u16 out_defs; @@ -33,7 +35,7 @@ struct AsmInstructionFacts { bool is_terminal; Entity *branch_target; - i32 block_id; + i32 block_id; }; struct AsmCfg { @@ -325,7 +327,7 @@ gb_internal void check_asm_cfg_analyse(AsmCtx *asm_ctx, AsmCfg *cfg, CheckerCont if (cfg->blocks.count == 0) { // With an empty body, the CFG cannot really do nothing if (diverging && !cfg->saw_any_instructions) { - error(entity->token, "This asm template is declared as diverging (-> !) but its body is empty and cannot diverge"); + error(entity->token, "This 'asm' template is declared as diverging (-> !) but its body is empty and cannot diverge"); } return; } @@ -584,9 +586,6 @@ gb_internal void check_asm_cfg_analyse(AsmCtx *asm_ctx, AsmCfg *cfg, CheckerCont break; } } - gb_printf_err("RBW-ERROR site=