[polly] r280940 - ScopInfo: Make clear that no double-free problem exists

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 07:08:07 PDT 2016


Author: grosser
Date: Thu Sep  8 09:08:07 2016
New Revision: 280940

URL: http://llvm.org/viewvc/llvm-project?rev=280940&view=rev
Log:
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.

Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=280940&r1=280939&r2=280940&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Sep  8 09:08:07 2016
@@ -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);
       }
     }
 




More information about the llvm-commits mailing list