diff --git a/include/tvm/arithmetic.h b/include/tvm/arithmetic.h index 105cbf7af8e9..1090b46e59f0 100644 --- a/include/tvm/arithmetic.h +++ b/include/tvm/arithmetic.h @@ -471,6 +471,11 @@ class IntSetAnalyzer { */ class Analyzer { public: + /* + * Disable copy constructor. + */ + Analyzer(const Analyzer&) = delete; + Analyzer& operator=(const Analyzer&) = delete; /*! \brief sub-analyzer: const integer bound */ ConstIntBoundAnalyzer const_int_bound; /*! \brief sub-analyzer: modular set */ diff --git a/src/pass/storage_flatten.cc b/src/pass/storage_flatten.cc index 1bf661d51e2a..b5d13eff5235 100644 --- a/src/pass/storage_flatten.cc +++ b/src/pass/storage_flatten.cc @@ -53,7 +53,7 @@ class StorageFlattener : public IRMutator { public: explicit StorageFlattener(Map extern_buffer, int cache_line_size, bool create_bound_attributes, - const std::shared_ptr& bounded_analyzer) + IRVisitorWithAnalyzer* bounded_analyzer) : bounded_analyzer_(bounded_analyzer), create_bound_attributes_(create_bound_attributes) { for (auto kv : extern_buffer) { @@ -518,7 +518,7 @@ class StorageFlattener : public IRMutator { std::vector>> shape_collector_; // bounds populator. We really need the analyzer from it. // However - std::shared_ptr bounded_analyzer_; + IRVisitorWithAnalyzer* bounded_analyzer_; // The size of cacheline int cache_line_size_; // The current stage is an OpenGL shader. @@ -529,20 +529,11 @@ class StorageFlattener : public IRMutator { Stmt StorageFlatten(Stmt stmt, Map extern_buffer, int cache_line_size, bool create_bound_attributes) { - /* - * Unforunately we have to resort to shared_ptr because Analyzer used by - * bounded_analyzer has other analyzers in it. e.g. canonical. - * These ones allocate impl and destroy them on destructor calls. - * However there is no copy/move operator on analyzer that safely copies - * or moves data. Perhaps we should disable copy operator and implement - * move operator. - */ - std::shared_ptr bounded_analyzer = - std::make_shared(); - bounded_analyzer->Visit(stmt); + IRVisitorWithAnalyzer bounded_analyzer; + bounded_analyzer.Visit(stmt); stmt = StorageFlattener(extern_buffer, cache_line_size, - create_bound_attributes, bounded_analyzer).Mutate(stmt); + create_bound_attributes, &bounded_analyzer).Mutate(stmt); return stmt; }