From 55a7af7da5b6cac6da012741dca48c8ab857801c Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Thu, 8 Sep 2016 14:08:07 +0000 Subject: [PATCH] ScopInfo: Make clear that no double-free problem exists When running the clang static analyser to check for memory issues, this code originally showed a double free, as the analyser was unable to understand that isl_set_free always returns NULL and consequently later uses of the isl object we just freed will never be reached. Without this knowledge, the analyser has to issue a warning. We refactor the code to make it clear that for empty maps the current loop iteration is aborted. llvm-svn: 280940 --- polly/lib/Analysis/ScopInfo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 5fb1616..2c0cd42 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1536,10 +1536,12 @@ void ScopStmt::checkForReductions() { isl_map_intersect_domain(MA->getAccessRelation(), getDomain()); isl_set *Accs = isl_map_range(AccRel); - if (isl_set_has_equal_space(AllAccs, Accs) || isl_set_free(Accs)) { + if (isl_set_has_equal_space(AllAccs, Accs)) { isl_set *OverlapAccs = isl_set_intersect(Accs, isl_set_copy(AllAccs)); Valid = Valid && isl_set_is_empty(OverlapAccs); isl_set_free(OverlapAccs); + } else { + isl_set_free(Accs); } } -- 2.7.4