]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
Cleanups
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index 84832fedf5a5aa7dc3bc4aec35a7dffa2b6a9a8f..12f9a5115c4e14dfad82917cb8ae0dd92fe47868 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -527,7 +527,8 @@ static bool instr_is_operation(uint16_t op)
              (op >= INSTR_LOAD_F && op <= INSTR_LOAD_FNC) ||
              (op == INSTR_ADDRESS) ||
              (op >= INSTR_NOT_F  && op <= INSTR_NOT_FNC) ||
-             (op >= INSTR_AND    && op <= INSTR_BITOR) );
+             (op >= INSTR_AND    && op <= INSTR_BITOR) ||
+             (op >= INSTR_CALL0  && op <= INSTR_CALL8) );
 }
 
 bool ir_function_pass_peephole(ir_function *self)
@@ -638,7 +639,7 @@ bool ir_function_pass_peephole(ir_function *self)
     return true;
 }
 
-bool ir_function_pass_tailcall(ir_function *self)
+bool ir_function_pass_tailrecursion(ir_function *self)
 {
     size_t b, p;
 
@@ -738,8 +739,8 @@ bool ir_function_finalize(ir_function *self)
     }
 
     if (OPTS_OPTIMIZATION(OPTIM_TAIL_RECURSION)) {
-        if (!ir_function_pass_tailcall(self)) {
-            irerror(self->context, "tailcall optimization pass broke something in `%s`", self->name);
+        if (!ir_function_pass_tailrecursion(self)) {
+            irerror(self->context, "tail-recursion optimization pass broke something in `%s`", self->name);
             return false;
         }
     }
@@ -2910,11 +2911,11 @@ tailcall:
             code_push_statement(&stmt, instr->context.line);
 
             retvalue = instr->_ops[0];
-            if (retvalue && retvalue->store != store_return && vec_size(retvalue->life))
+            if (retvalue && retvalue->store != store_return && (vec_size(retvalue->life) || retvalue->store == store_global))
             {
                 /* not to be kept in OFS_RETURN */
-                if (retvalue->vtype == TYPE_FIELD)
-                    stmt.opcode = field_store_instr[retvalue->vtype];
+                if (retvalue->vtype == TYPE_FIELD && OPTS_FLAG(ADJUST_VECTOR_FIELDS))
+                    stmt.opcode = field_store_instr[retvalue->fieldtype];
                 else
                     stmt.opcode = type_store_instr[retvalue->vtype];
                 stmt.o1.u1 = OFS_RETURN;