[PATCH] D17241: [Refactor] Move isl_ctx into Scop.

Hongbin Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 15 07:02:53 PST 2016


etherzhhb added a comment.

Currently, we build isl object in ScopInfo, DependencyInfo and IslAst.

We must free all isl objects before we free the ctx. And I try to use the reference counter from shared_ptr to figure out the time to free the isl ctx.

Suppose we free ScopInfo, DependencyInfo, IslAst in order:

If we only run ScopInfo, we should free ctx when we free the corresponding Scop.

If we only run ScopInfo and DependencyInfo, we should free ctx when we free the corresponding Dependences.

If we only run ScopInfo, DependencyInfo and IslAst, we should free ctx when we free the corresponding IslAst.

And if  ScopInfo, DependencyInfo, IslAst are not free in order, it become a total mess ....

Using the reference counter from the shared_ptr can solve this problem: Everytime we destruct a shared_ptr, the shared_ptr will decrease the reference counter. If the reference counter is decreased to 0, the current analysis result we are destructing are the last one that hold isl objects -- and there are no isl object left, which mean it is safe to free the isl context.

A better solution may be provide a "isl_free_ctx_if_ref_is_zero" function which do not actually free the context until all isl objs are released?

Or we can try to make an SCoP to remember all the created ISL objects, and only free isl objs in the SCoP info?


Repository:
  rL LLVM

http://reviews.llvm.org/D17241





More information about the llvm-commits mailing list