From 90a195a120b4be286d40362a64792835e9842126 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 24 Jul 2009 17:47:35 +0200 Subject: [PATCH] isl_tab: store index of variable in undo record instead of pointer to variable The row of variables might get reallocated between pushing the undo record and performing the undo, invalidating the pointer. --- isl_tab.c | 30 ++++++++++++++++++------------ isl_tab.h | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/isl_tab.c b/isl_tab.c index 6aaedc04..a8e4e02c 100644 --- a/isl_tab.c +++ b/isl_tab.c @@ -387,7 +387,12 @@ static void push(struct isl_tab *tab, return; } undo->type = type; - undo->var = var; + if (!var) + undo->var_index = 0; + else if (var->is_row) + undo->var_index = tab->row_var[var->index]; + else + undo->var_index = tab->col_var[var->index]; undo->next = tab->top; tab->top = undo; } @@ -1717,34 +1722,35 @@ static void unrelax(struct isl_tab *tab, struct isl_tab_var *var) static void perform_undo(struct isl_tab *tab, struct isl_tab_undo *undo) { + struct isl_tab_var *var = var_from_index(tab, undo->var_index); switch(undo->type) { case isl_tab_undo_empty: tab->empty = 0; break; case isl_tab_undo_nonneg: - undo->var->is_nonneg = 0; + var->is_nonneg = 0; break; case isl_tab_undo_redundant: - undo->var->is_redundant = 0; + var->is_redundant = 0; tab->n_redundant--; break; case isl_tab_undo_zero: - undo->var->is_zero = 0; + var->is_zero = 0; tab->n_dead--; break; case isl_tab_undo_allocate: - if (!undo->var->is_row) { - if (!max_is_manifestly_unbounded(tab, undo->var)) - to_row(tab, undo->var, 1); - else if (!min_is_manifestly_unbounded(tab, undo->var)) - to_row(tab, undo->var, -1); + if (!var->is_row) { + if (!max_is_manifestly_unbounded(tab, var)) + to_row(tab, var, 1); + else if (!min_is_manifestly_unbounded(tab, var)) + to_row(tab, var, -1); else - to_row(tab, undo->var, 0); + to_row(tab, var, 0); } - drop_row(tab, undo->var->index); + drop_row(tab, var->index); break; case isl_tab_undo_relax: - unrelax(tab, undo->var); + unrelax(tab, var); break; } } diff --git a/isl_tab.h b/isl_tab.h index 4db65a70..5a7c96dc 100644 --- a/isl_tab.h +++ b/isl_tab.h @@ -27,7 +27,7 @@ enum isl_tab_undo_type { struct isl_tab_undo { enum isl_tab_undo_type type; - struct isl_tab_var *var; + int var_index; struct isl_tab_undo *next; }; -- 2.11.4.GIT