]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
More bug fixes and dead code elimination
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index 913e852190d309745822d4a66be50b1b0ade93c2..584bda0714a5f923524ff828c66eaa6919ac9c84 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1563,7 +1563,7 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
     return true;
 
 error: /* clean up */
-    ir_value_delete(v);
+    if(v) ir_value_delete(v);
     return false;
 }
 
@@ -2893,10 +2893,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
     if (bprecond)
     {
         ir_block *ontrue, *onfalse;
-        if      (bbody)      ontrue = bbody;
+        ontrue = bbody; /* can never be null */
+
+        /* all of this is dead code 
         else if (bincrement) ontrue = bincrement;
-        else if (bpostcond)  ontrue = bpostcond;
-        else                 ontrue = bprecond;
+        else                 ontrue = bpostcond;
+        */
+
         onfalse = bout;
         if (self->pre_not) {
             tmpblock = ontrue;
@@ -2934,9 +2937,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
     {
         ir_block *ontrue, *onfalse;
         if      (bprecond)   ontrue = bprecond;
-        else if (bbody)      ontrue = bbody;
+        else                 ontrue = bbody; /* can never be null */
+
+        /* all of this is dead code 
         else if (bincrement) ontrue = bincrement;
         else                 ontrue = bpostcond;
+        */
+
         onfalse = bout;
         if (self->post_not) {
             tmpblock = ontrue;