rockeet wrote: We used this extension to improve virtual function calling performance, there are simple and small virtual functions which are frequently called and can not be eliminated and it is in a delegation thus compiler can not optimize, so we use pmf to bound the virtual function, like this: ```c++ #if defined(_MSC_VER) || defined(__clang__) #define IF_BOUND_PMF(Then, Else) Else #else #define IF_BOUND_PMF(Then, Else) Then #endif void SetSubReader(const ToplingZipSubReader* sub) { subReader_ = sub; iter_ = sub->index_->NewIterator(); store_ = sub->store_.get(); get_record_append_ = store_->m_get_record_append_CacheOffsets; #if defined(_MSC_VER) || defined(__clang__) #else iter_next_ = (IterScanFN)(iter_->*(&COIndex::Iterator::Next)); iter_prev_ = (IterScanFN)(iter_->*(&COIndex::Iterator::Prev)); #endif tag_rs_kind_ = sub->tag_rs_kind_; }
inline bool IndexIterInvokeNext() { return IF_BOUND_PMF(iter_next_(iter_), iter_->Next()); } inline bool IndexIterInvokePrev() { return IF_BOUND_PMF(iter_prev_(iter_), iter_->Prev()); } ``` In which `iter_->Next()` is a small virtual function for different index type, we save the pmf as a member, thus reduced the virtual function calling overhead. https://github.com/llvm/llvm-project/pull/135649 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits