From 9556b678408bdbd53083938346dbb7b0467176ac Mon Sep 17 00:00:00 2001 From: Vladislav Khmelevsky Date: Thu, 8 Dec 2022 14:06:39 +0400 Subject: [BOLT] Fix blocks layout reverse iterators Use container's reverse iterators, fix iterators types. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D139335 --- bolt/include/bolt/Core/FunctionLayout.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'bolt') diff --git a/bolt/include/bolt/Core/FunctionLayout.h b/bolt/include/bolt/Core/FunctionLayout.h index 8eeabd97..904da3a 100644 --- a/bolt/include/bolt/Core/FunctionLayout.h +++ b/bolt/include/bolt/Core/FunctionLayout.h @@ -71,11 +71,8 @@ class FunctionFragment { using FragmentListType = SmallVector; public: - using iterator = raw_pointer_iterator; - using const_iterator = - raw_pointer_iterator; + using iterator = BasicBlockListType::iterator; + using const_iterator = BasicBlockListType::const_iterator; private: FunctionLayout *Layout; @@ -150,9 +147,7 @@ public: pointee_iterator; using block_iterator = BasicBlockListType::iterator; - using block_const_iterator = - raw_pointer_iterator; + using block_const_iterator = BasicBlockListType::const_iterator; using block_reverse_iterator = std::reverse_iterator; using block_const_reverse_iterator = std::reverse_iterator; @@ -303,16 +298,18 @@ public: return {block_begin(), block_end()}; } block_reverse_iterator block_rbegin() { - return block_reverse_iterator(block_end()); + return block_reverse_iterator(Blocks.rbegin()); } block_const_reverse_iterator block_rbegin() const { - return block_const_reverse_iterator(block_end()); + return block_const_reverse_iterator( + std::make_reverse_iterator(block_end())); } block_reverse_iterator block_rend() { - return block_reverse_iterator(block_begin()); + return block_reverse_iterator(Blocks.rend()); } block_const_reverse_iterator block_rend() const { - return block_const_reverse_iterator(block_begin()); + return block_const_reverse_iterator( + std::make_reverse_iterator(block_begin())); } iterator_range rblocks() const { return {block_rbegin(), block_rend()}; -- cgit v1.1