The getEnclosingRepetitiveRegion functions walk the ancestor regions everytime which can be expensive especially when there are multiple regions inbetween. This commit adds a cache to the bufferization analysis to remember the result of the walk.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h | ||
---|---|---|
575–577 | This cache should be cleared when OneShotAnalysisState::resetCache() is called. We need a virtual resetCache function in this class. (And override + call base impl. in OneShotAnalysisState.) | |
mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp | ||
57–61 | An enclosing repetitive region can be nullptr. In that case, the stored region in the cache will be nullptr and this check will return "false". I would change this to if (enclosingRepetitiveRegionCache.contains(op)). |
Cache nullptr results as well and consider them in the lookups. I used find_as to avoid looking up the value twice. Also, add the resetCache virtual method.
This cache should be cleared when OneShotAnalysisState::resetCache() is called. We need a virtual resetCache function in this class. (And override + call base impl. in OneShotAnalysisState.)