]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
Actually fix the segfault this time
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index f71e75b5eb78d470f83cc356ce60e42039156bec..2ac7ff1bdc7500a5090785b45206dc8edf13af71 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)
@@ -1122,7 +1123,7 @@ static char *ir_strdup(const char *str)
 {
     if (str && !*str) {
         /* actually dup empty strings */
-        char *out = mem_a(1);
+        char *out = (char*)mem_a(1);
         *out = 0;
         return out;
     }
@@ -1542,7 +1543,7 @@ ir_instr* ir_block_create_phi(ir_block *self, lex_ctx ctx, const char *label, in
     ir_value *out;
     ir_instr *in;
     if (!ir_check_unreachable(self))
-        return false;
+        return NULL;
     in = ir_instr_new(ctx, self, VINSTR_PHI);
     if (!in)
         return NULL;
@@ -1589,7 +1590,7 @@ ir_instr* ir_block_create_call(ir_block *self, lex_ctx ctx, const char *label, i
     ir_value *out;
     ir_instr *in;
     if (!ir_check_unreachable(self))
-        return false;
+        return NULL;
     in = ir_instr_new(ctx, self, (noreturn ? VINSTR_NRCALL : INSTR_CALL0));
     if (!in)
         return NULL;
@@ -2910,7 +2911,7 @@ 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 && OPTS_FLAG(ADJUST_VECTOR_FIELDS))