imath-32: allow updating isl_int passed as argument
commit7cc91b6bc2f6a49715246df1f180c4fc6e5597e5
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 7 Aug 2015 19:15:28 +0000 (7 21:15 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 10 Aug 2015 08:46:27 +0000 (10 10:46 +0200)
tree4b2bd78e041aca88f62554b6465013cec0171b59
parentcec9cbb46a34e832f9b8581b26cde7c8b1b222bb
imath-32: allow updating isl_int passed as argument

The isl_int type defined by the imath-32 backend behaves differently
from those of the gmp and imath backends.  In particular, when an isl_int
is passed to a function, the function is not allowed to update the value
of that variable.  Doing so may cause memory leaks and/or double frees
depending on the initial and final value.

a1e44f0 (Make pass-by-reference explicit by using pointer,
Tue Jun 30 16:59:45 2015 +0200) and c911d96 (Make pass-by-reference
explicit by using pointers, Thu Aug 6 19:46:46 2015 +0200) fix
this problem by passing a pointer to the isl_int instead.
However, several more functions would need to be changed this way,
including at least isl_seq_preimage, isl_seq_substitute,
solve_ilp_search in isl_ilp.c, lexmin_col_pair in isl_tab_pip.c and
insert_bounds_on_div_from_ineq in isl_map.c, and some exhaustive
static analysis would have to be performed to make sure that
the pattern doesn't also appear in other places.

Change the imath-32 isl_int representation instead to make
it behave in the same way as the other backends by turning
isl_int into a one-element array ensuring that a pointer is
passed to an isl_int argument implicitly.
a1e44f0 and c911d96 could now be safely reverted.
Note that this mechanism does mean that a change that is
made locally in the called function is also visible in
the caller, but this also the case for the gmp backend,
so the code already needs to take this into account.

An alternative would be to change all isl_int arguments
to "const isl_int" arguments, ensuring that the value
of an isl_int argument is never changed inside a function,
but this would require more changes across the entire code base,
while the present change is local to the imath-32 backend.

Tested-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
basis_reduction_tab.c
isl_int_sioimath.h
isl_test_int.c
isl_val_sioimath.c