]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
liferange calc now sets the 'locked' flag on values when reaching a CALL
authorWolfgang Bumiller <blub@speed.at>
Tue, 25 Dec 2012 20:03:26 +0000 (21:03 +0100)
committerWolfgang Bumiller <blub@speed.at>
Tue, 25 Dec 2012 20:03:26 +0000 (21:03 +0100)
ir.c
ir.h

diff --git a/ir.c b/ir.c
index 17bf16bd9e7eb867a2d4c6f01ee9ea3f85981f8b..7d35e7ff1d979584bad9d42103203449b09f4365 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -987,6 +987,7 @@ ir_value* ir_value_var(const char *name, int storetype, int vtype)
     self->memberof = NULL;
 
     self->unique_life = false;
+    self->locked      = false;
 
     self->life = NULL;
     return self;
@@ -2289,15 +2290,24 @@ static bool ir_block_living_add_instr(ir_block *self, size_t eid)
     for (i = 0; i != vec_size(self->living); ++i)
     {
         tempbool = ir_value_life_merge(self->living[i], eid);
-        /* debug
-        if (tempbool)
-            irerror(self->context, "block_living_add_instr() value instruction added %s: %i", self->living[i]->_name, (int)eid);
-        */
         changed = changed || tempbool;
     }
     return changed;
 }
 
+static bool ir_block_living_lock(ir_block *self)
+{
+    size_t i;
+    bool changed = false;
+    for (i = 0; i != vec_size(self->living); ++i)
+    {
+        if (!self->living[i]->locked)
+            changed = true;
+        self->living[i]->locked = true;
+    }
+    return changed;
+}
+
 static bool ir_block_life_prop_previous(ir_block* self, ir_block *prev, bool *changed)
 {
     size_t i;
@@ -2502,6 +2512,11 @@ static bool ir_block_life_propagate(ir_block *self, ir_block *prev, bool *change
                     vec_push(self->living, value->members[mem]);
             }
         }
+        /* on a call, all these values must be "locked" */
+        if (instr->opcode >= INSTR_CALL0 && instr->opcode <= INSTR_CALL8) {
+            if (ir_block_living_lock(self))
+                *changed = true;
+        }
 
         /* (A) */
         tempbool = ir_block_living_add_instr(self, instr->eid);
diff --git a/ir.h b/ir.h
index a39efca1bcdf973f10c395c6a97471aff93a0027..e85eb45916961440c3015fdb015c018f5d65407f 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -77,6 +77,8 @@ typedef struct ir_value_s {
 
     /* arrays will never overlap with temps */
     bool unique_life;
+    /* temps living during a CALL must be locked */
+    bool      locked;
 
     /* For the temp allocator */
     ir_life_entry_t *life;