]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
fix: check if parsing a variable initializer failed
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index 0dc785a0d4b565d6008df65e2ac13b9f75ddcc3f..47b9adc7798125536cf83969e61468da5068c2c8 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2109,6 +2109,19 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change
         /* See which operands are read and write operands */
         ir_op_read_write(instr->opcode, &read, &write);
 
+        if (instr->opcode == INSTR_MUL_VF)
+        {
+            /* the float source will get an additional lifetime */
+            tempbool = ir_value_life_merge(instr->_ops[2], instr->eid+1);
+            *changed = *changed || tempbool;
+        }
+        else if (instr->opcode == INSTR_MUL_FV)
+        {
+            /* the float source will get an additional lifetime */
+            tempbool = ir_value_life_merge(instr->_ops[1], instr->eid+1);
+            *changed = *changed || tempbool;
+        }
+
         /* Go through the 3 main operands */
         for (o = 0; o < 3; ++o)
         {
@@ -2558,7 +2571,6 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
     }
 
     fun.firstlocal = code_globals_elements;
-    fun.locals     = irfun->allocated_locals + irfun->locals_count;
 
     local_var_end = fun.firstlocal;
     for (i = 0; i < irfun->locals_count; ++i) {
@@ -2583,6 +2595,8 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
         code_globals_add(0);
     }
 
+    fun.locals = code_globals_elements - fun.firstlocal;
+
     if (irfun->builtin)
         fun.entry = irfun->builtin;
     else {
@@ -2926,7 +2940,7 @@ void ir_function_dump(ir_function *f, char *ind,
     for (i = 0; i < f->locals_count; ++i) {
         size_t l;
         ir_value *v = f->locals[i];
-        oprintf("%s\t%s: ", ind, v->name);
+        oprintf("%s\t%s: unique ", ind, v->name);
         for (l = 0; l < v->life_count; ++l) {
             oprintf("[%i,%i] ", v->life[l].start, v->life[l].end);
         }
@@ -2935,7 +2949,7 @@ void ir_function_dump(ir_function *f, char *ind,
     for (i = 0; i < f->values_count; ++i) {
         size_t l;
         ir_value *v = f->values[i];
-        oprintf("%s\t%s: (%i)", ind, v->name, (int)v->life_count);
+        oprintf("%s\t%s: @%i ", ind, v->name, (int)v->code.local);
         for (l = 0; l < v->life_count; ++l) {
             oprintf("[%i,%i] ", v->life[l].start, v->life[l].end);
         }