scf_dn_index_t* di;
scf_dn_index_t* di2;
+ scf_variable_t* v;
+ scf_variable_t* v2;
+
int i;
for (i = 0; i < bb2->ds_malloced->size; i++) {
ds2 = bb2->ds_malloced->data[i];
}
}
- int size = ds->dn_indexes->size;
int j;
for (j = 0; j < ds2->dn_indexes->size; j++) {
di2 = ds2->dn_indexes->data[j];
if (!di->dn) {
scf_dn_status_free(ds);
scf_dn_index_free (di);
+ return -ENOMEM;
}
}
- if (scf_vector_add(ds->dn_indexes, di) < 0) {
+ if (scf_vector_add_front(ds->dn_indexes, di) < 0) {
scf_dn_status_free(ds);
scf_dn_index_free (di);
return -ENOMEM;
}
}
- int k;
- for (k = 0; k < ds2->dn_indexes->size; k++) {
+ v = ds ->dag_node->var;
+ v2 = ds2->dag_node->var;
- di = ds->dn_indexes->data[size + k];
+ int m = v ->nb_pointers + v ->nb_dimentions + (v ->type >= SCF_STRUCT);
+ int n = v2->nb_pointers + v2->nb_dimentions + (v2->type >= SCF_STRUCT);
- for (j = size + k - 1; j > k; j--)
- ds->dn_indexes->data[j + 1] = ds->dn_indexes->data[j];
+ for (j = 0; j + m < n; j++) {
- ds->dn_indexes->data[k] = di;
+ di = ds->dn_indexes->data[ds->dn_indexes->size - 1];
+
+ if (di->member || 0 == di->index) {
+ assert(!di->dn);
+
+ --ds->dn_indexes->size;
+ scf_dn_index_free(di);
+ di = NULL;
+ } else{
+ scf_dn_status_free(ds);
+ return -ENOMEM;
+ }
+ }
+
+ if (ds->dn_indexes->size <= 0) {
+ scf_vector_free(ds->dn_indexes);
+ ds->dn_indexes = NULL;
}
_bb_add_ds(bb, ds);
if (!v1->auto_gc_flag)
continue;
- scf_logd("f2: %s, v0: %s, v1: %s\n", f2->node.w->text->data, v0->w->text->data, v1->w->text->data);
+ scf_logd("i: %d, f2: %s, v0: %s, v1: %s\n", i, f2->node.w->text->data, v0->w->text->data, v1->w->text->data);
ds_obj = NULL;
if (SCF_OP_ADDRESS_OF == dn->type)
if (bb_prev->nexts->size != 1)
return 0;
+ if (bb_prev->call_flag)
+ return 0;
+
if (!scf_vector_find(bbg->body, bb_prev))
return 0;
return 0;
}
+ assert(0 == scf_vector_del(bb->dn_reloads, dn));
+
+ if (bb->call_flag)
+ continue;
+
for (j = 0; j < bb->prevs->size; j++) {
bb_prev = bb->prevs->data[j];
assert(0 == scf_vector_del(bb_prev->dn_resaves, dn));
}
- assert(0 == scf_vector_del(bb->dn_reloads, dn));
-
int ret = scf_vector_add_unique(bb->dn_resaves, dn);
if (ret < 0)
return ret;
--- /dev/null
+include "../lib/scf_capi.c";
+
+int f(int** t0, int **t1);
+
+int g(int** s0, int** s1)
+{
+ if (!*s1)
+ *s1 = scf__auto_malloc(sizeof(int));
+
+ if (!*s0)
+ f(s0, s1);
+ return 0;
+}
+
+int f(int** t0, int **t1)
+{
+ if (!*t0)
+ *t0 = scf__auto_malloc(sizeof(int));
+
+ if (!*t1)
+ g(t0, t1);
+ return 0;
+}
+
+int main()
+{
+ int* p0 = NULL;
+ int* p1 = NULL;
+
+ f(&p0, &p1);
+
+ *p0 = 1;
+ *p1 = 2;
+
+ printf("%d, %d\n", *p0, *p1);
+ return 0;
+}
return 0;
}
+static inline int scf_vector_add_front(scf_vector_t* v, void* node)
+{
+ int ret = scf_vector_add(v, node);
+ if (ret < 0)
+ return ret;
+
+ int i;
+ for (i = v->size - 2; i >= 0; i--)
+ v->data[i + 1] = v->data[i];
+
+ v->data[0] = node;
+ return 0;
+}
+
static inline int scf_vector_del(scf_vector_t* v, void* node)
{
if (!v || !v->data)