]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Don't allocate globals for constants that aren't read xonotic-v0.8.1
authorDale Weiler <weilercdale@gmail.com>
Fri, 30 Jan 2015 05:40:59 +0000 (00:40 -0500)
committerDale Weiler <weilercdale@gmail.com>
Fri, 30 Jan 2015 05:40:59 +0000 (00:40 -0500)
ir.c

diff --git a/ir.c b/ir.c
index 5a6229fc9f87d0259054a3fd839e3a9d4ed914ac..8d52898bd5a957dece321cd5fc33b8d3e44f9257 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -3772,6 +3772,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
     {
         ir_value_code_setaddr(global, vec_size(self->code->globals));
         if (global->hasvalue) {
+            if (global->cvq == CV_CONST && !vec_size(global->reads))
+                return true;
             iptr = (int32_t*)&global->constval.ivec[0];
             vec_push(self->code->globals, *iptr);
         } else {
@@ -3787,7 +3789,10 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
     {
         ir_value_code_setaddr(global, vec_size(self->code->globals));
         if (global->hasvalue) {
-            uint32_t load = code_genstring(self->code, global->constval.vstring);
+            uint32_t load;
+            if (global->cvq == CV_CONST && !vec_size(global->reads))
+                return true;
+            load = code_genstring(self->code, global->constval.vstring);
             vec_push(self->code->globals, load);
         } else {
             vec_push(self->code->globals, 0);