DependenceInfo: Make clear that no double-free problem exists
authorTobias Grosser <tobias@grosser.es>
Thu, 8 Sep 2016 14:08:01 +0000 (14:08 +0000)
committerTobias Grosser <tobias@grosser.es>
Thu, 8 Sep 2016 14:08:01 +0000 (14:08 +0000)
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_union_map_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: 280938

polly/lib/Analysis/DependenceInfo.cpp

index 8ecfccb..04c2b00 100644 (file)
@@ -537,8 +537,10 @@ void Dependences::calculateDependences(Scop &S) {
       isl_set *AccDomW = isl_map_wrap(MA->getAccessRelation());
       isl_union_map *AccRedDepU = isl_union_map_intersect_domain(
           isl_union_map_copy(TC_RED), isl_union_set_from_set(AccDomW));
-      if (isl_union_map_is_empty(AccRedDepU) && !isl_union_map_free(AccRedDepU))
+      if (isl_union_map_is_empty(AccRedDepU)) {
+        isl_union_map_free(AccRedDepU);
         continue;
+      }
 
       isl_map *AccRedDep = isl_map_from_union_map(AccRedDepU);
       RED_SIN = isl_union_map_add_map(RED_SIN, isl_map_copy(AccRedDep));