]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
add AINSTR_END to the end of functions so the debug-printing knows when to end...
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index 557a821886cd3df4488142c1ef6642e2b2427fa7..4ac089d7956995404559f47c5f073f1bb84700ad 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2310,6 +2310,7 @@ tailcall:
 static bool gen_function_code(ir_function *self)
 {
     ir_block *block;
+    prog_section_statement stmt;
 
     /* Starting from entry point, we generate blocks "as they come"
      * for now. Dead blocks will not be translated obviously.
@@ -2327,6 +2328,14 @@ static bool gen_function_code(ir_function *self)
         printf("failed to generate blocks for '%s'\n", self->name);
         return false;
     }
+
+    /* otherwise code_write crashes since it debug-prints functions until AINSTR_END */
+    stmt.opcode = AINSTR_END;
+    stmt.o1.u1 = 0;
+    stmt.o2.u1 = 0;
+    stmt.o3.u1 = 0;
+    if (code_statements_add(stmt) < 0)
+        return false;
     return true;
 }