]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.cpp
Merge branch 'cleanup' of git://github.com/graphitemaster/gmqcc into cleanup
[xonotic/gmqcc.git] / ir.cpp
diff --git a/ir.cpp b/ir.cpp
index ba4ed649b7eea9eebe41f5d3b36260696c798409..d11bbb795e0335e491ad4b2279abdffd21484a9a 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -792,6 +792,9 @@ static void ir_instr_delete_quick(ir_instr *self)
 {
     self->m_phi.clear();
     self->m_params.clear();
+    self->_m_ops[0] = nullptr;
+    self->_m_ops[1] = nullptr;
+    self->_m_ops[2] = nullptr;
     delete self;
 }
 
@@ -3433,6 +3436,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
     {
         ir_value_code_setaddr(global, self->m_code->globals.size());
         if (global->m_hasvalue) {
+            if (global->m_cvq == CV_CONST && global->m_reads.empty())
+                return true;
             iptr = (int32_t*)&global->m_constval.ivec[0];
             self->m_code->globals.push_back(*iptr);
         } else {
@@ -3448,6 +3453,8 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
     {
         ir_value_code_setaddr(global, self->m_code->globals.size());
         if (global->m_hasvalue) {
+            if (global->m_cvq == CV_CONST && global->m_reads.empty())
+                return true;
             uint32_t load = code_genstring(self->m_code.get(), global->m_constval.vstring);
             self->m_code->globals.push_back(load);
         } else {