From 619b7670af260d9d211afdd65b333784cdf1e479 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 23 Sep 2015 15:42:14 +0200 Subject: [PATCH] tree2scop.c: scop_from_tree_macro: drop redundant argument and plug leak The redundant argument has been there from the start in 892c4f3 (add encapsulate_dynamic_control option, Tue Jan 28 11:16:24 2014 +0100). Usually, the argument is NULL, so it does not have any effect, but if the "macro-statement" has a label, then a copy would be passed that is never freed, resulting in a memory leak. Signed-off-by: Sven Verdoolaege --- tests/encapsulate/while2.c | 9 +++++++++ tests/encapsulate/while2.scop | 37 +++++++++++++++++++++++++++++++++++++ tree2scop.c | 6 ++---- 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 tests/encapsulate/while2.c create mode 100644 tests/encapsulate/while2.scop diff --git a/tests/encapsulate/while2.c b/tests/encapsulate/while2.c new file mode 100644 index 0000000..9c4442f --- /dev/null +++ b/tests/encapsulate/while2.c @@ -0,0 +1,9 @@ +void f() +{ + int done = 0; + +#pragma scop +While: while (!done) + done = 1; +#pragma endscop +} diff --git a/tests/encapsulate/while2.scop b/tests/encapsulate/while2.scop new file mode 100644 index 0000000..5bea07a --- /dev/null +++ b/tests/encapsulate/while2.scop @@ -0,0 +1,37 @@ +start: 27 +end: 89 +indent: +context: '{ : }' +schedule: '{ domain: "{ While[] }" }' +arrays: +- context: '{ : }' + extent: '{ done[] }' + element_type: int + element_size: 4 +statements: +- line: 6 + domain: '{ While[] }' + body: + type: while + condition: + type: op + operation: '!' + arguments: + - type: access + index: '{ While[] -> done[] }' + reference: __pet_ref_0 + read: 1 + write: 0 + body: + type: expression + expr: + type: op + operation: = + arguments: + - type: access + index: '{ While[] -> done[] }' + reference: __pet_ref_1 + read: 0 + write: 1 + - type: int + value: 1 diff --git a/tree2scop.c b/tree2scop.c index 288870b..38de5f6 100644 --- a/tree2scop.c +++ b/tree2scop.c @@ -2485,8 +2485,7 @@ static int extract_declared_arrays(__isl_keep pet_tree *node, void *user) * cannot occur at the outer level. */ static struct pet_scop *scop_from_tree_macro(__isl_take pet_tree *tree, - __isl_take isl_id *label, __isl_keep pet_context *pc, - struct pet_state *state) + __isl_keep pet_context *pc, struct pet_state *state) { struct pet_tree_extract_declared_arrays_data data = { pc, state }; @@ -2571,8 +2570,7 @@ static struct pet_scop *scop_from_tree(__isl_keep pet_tree *tree, return scop; pet_scop_free(scop); - return scop_from_tree_macro(pet_tree_copy(tree), - isl_id_copy(tree->label), pc, state); + return scop_from_tree_macro(pet_tree_copy(tree), pc, state); } /* If "tree" has a label that is of the form S_, then make -- 2.11.4.GIT