From 4643e958429347a59769c2fcc14df3b6411f2faf Mon Sep 17 00:00:00 2001 From: BoyBaykiller Date: Sat, 30 May 2026 00:00:15 +0200 Subject: [PATCH 1/2] * use stl iterator tags instead of custom ones --- src/coreclr/jit/fgopt.cpp | 6 ++++++ src/coreclr/jit/jitstd/iterator.h | 20 ++------------------ src/coreclr/jit/jitstd/list.h | 27 +++++++++++++++------------ src/coreclr/jit/jitstd/vector.h | 23 +++++++++++++---------- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index fa79f661f4e2f9..28a3c47ef2195e 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -5066,6 +5066,12 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) Statement* m_stmt; }; + // Test + jitstd::vector v(getAllocator(CMK_ArrayStack)); + std::partition(v.begin(), v.end(), [](PredInfo a) { + return true; + }); + ArrayStack predInfo(getAllocator(CMK_ArrayStack)); ArrayStack matchedPredInfo(getAllocator(CMK_ArrayStack)); ArrayStack retryBlocks(getAllocator(CMK_ArrayStack)); diff --git a/src/coreclr/jit/jitstd/iterator.h b/src/coreclr/jit/jitstd/iterator.h index f96d358a7dcc01..1dbf27e002da9d 100644 --- a/src/coreclr/jit/jitstd/iterator.h +++ b/src/coreclr/jit/jitstd/iterator.h @@ -18,22 +18,6 @@ struct iterator typedef Category iterator_category; }; -struct input_iterator_tag -{ -}; - -struct forward_iterator_tag : public input_iterator_tag -{ -}; - -struct bidirectional_iterator_tag : public forward_iterator_tag -{ -}; - -struct random_access_iterator_tag : public bidirectional_iterator_tag -{ -}; - struct int_not_an_iterator_tag { }; @@ -55,7 +39,7 @@ struct iterator_traits typedef T value_type; typedef T* pointer; typedef T& reference; - typedef random_access_iterator_tag iterator_category; + typedef std::random_access_iterator_tag iterator_category; }; template @@ -65,7 +49,7 @@ struct iterator_traits typedef T value_type; typedef const T* pointer; typedef const T& reference; - typedef random_access_iterator_tag iterator_category; + typedef std::random_access_iterator_tag iterator_category; }; template<> diff --git a/src/coreclr/jit/jitstd/list.h b/src/coreclr/jit/jitstd/list.h index 77b5f893bea101..505f93316faec3 100644 --- a/src/coreclr/jit/jitstd/list.h +++ b/src/coreclr/jit/jitstd/list.h @@ -40,7 +40,7 @@ class list public: // nested classes class iterator; - class const_iterator : public jitstd::iterator + class const_iterator : public jitstd::iterator { private: const_iterator(Node* ptr); @@ -67,7 +67,7 @@ class list Node* m_pNode; }; - class iterator : public jitstd::iterator + class iterator : public jitstd::iterator { iterator(Node* ptr); public: @@ -94,7 +94,7 @@ class list }; class reverse_iterator; - class const_reverse_iterator : public jitstd::iterator + class const_reverse_iterator : public jitstd::iterator { private: const_reverse_iterator(Node* ptr); @@ -121,7 +121,7 @@ class list Node* m_pNode; }; - class reverse_iterator : public jitstd::iterator + class reverse_iterator : public jitstd::iterator { private: reverse_iterator(Node* ptr); @@ -268,15 +268,15 @@ class list void construct_helper(size_type n, const T& value, int_not_an_iterator_tag); template - void construct_helper(InputIterator first, InputIterator last, forward_iterator_tag); + void construct_helper(InputIterator first, InputIterator last, std::forward_iterator_tag); void assign_helper(size_type n, const T& value, int_not_an_iterator_tag); template - void assign_helper(InputIterator first, InputIterator last, forward_iterator_tag); + void assign_helper(InputIterator first, InputIterator last, std::forward_iterator_tag); void insert_helper(iterator position, size_type n, const T& value, int_not_an_iterator_tag); template - void insert_helper(iterator position, InputIterator first, InputIterator last, forward_iterator_tag); + void insert_helper(iterator position, InputIterator first, InputIterator last, std::forward_iterator_tag); void insert_new_node_helper(Node* pInsert, Node* pNewNode); @@ -332,7 +332,7 @@ list::list(const list& other) , m_allocator(other.m_allocator) , m_nodeAllocator(other.m_nodeAllocator) { - construct_helper(other.begin(), other.end(), forward_iterator_tag()); + construct_helper(other.begin(), other.end(), std::forward_iterator_tag()); } template @@ -551,7 +551,7 @@ template list& list::operator=(const list& lst) { destroy_helper(); - construct_helper(lst.begin(), lst.end(), forward_iterator_tag()); + construct_helper(lst.begin(), lst.end(), std::forward_iterator_tag()); return *this; } @@ -803,7 +803,7 @@ void list::construct_helper(size_type n, const T& value, int_not_a template template -void list::construct_helper(InputIterator first, InputIterator last, forward_iterator_tag) +void list::construct_helper(InputIterator first, InputIterator last, std::forward_iterator_tag) { while (first != last) { @@ -824,7 +824,7 @@ void list::assign_helper(size_type n, const T& value, int_not_an_i template template -void list::assign_helper(InputIterator first, InputIterator last, forward_iterator_tag) +void list::assign_helper(InputIterator first, InputIterator last, std::forward_iterator_tag) { destroy_helper(); while (first != last) @@ -845,7 +845,10 @@ void list::insert_helper(iterator position, size_type n, const T& template template -void list::insert_helper(iterator position, InputIterator first, InputIterator last, forward_iterator_tag) +void list::insert_helper(iterator position, + InputIterator first, + InputIterator last, + std::forward_iterator_tag) { while (first != last) { diff --git a/src/coreclr/jit/jitstd/vector.h b/src/coreclr/jit/jitstd/vector.h index 2d0a91210ecc95..c05a630f9d896b 100644 --- a/src/coreclr/jit/jitstd/vector.h +++ b/src/coreclr/jit/jitstd/vector.h @@ -33,7 +33,7 @@ class vector typedef T value_type; // nested classes - class iterator : public jitstd::iterator + class iterator : public jitstd::iterator { iterator(T* ptr); public: @@ -58,7 +58,7 @@ class vector pointer m_pElem; }; - class const_iterator : public jitstd::iterator + class const_iterator : public jitstd::iterator { private: const_iterator(T* ptr); @@ -84,7 +84,7 @@ class vector pointer m_pElem; }; - class reverse_iterator : public jitstd::iterator + class reverse_iterator : public jitstd::iterator { private: reverse_iterator(T* ptr); @@ -110,7 +110,7 @@ class vector pointer m_pElem; }; - class const_reverse_iterator : public jitstd::iterator + class const_reverse_iterator : public jitstd::iterator { private: const_reverse_iterator(T* ptr); @@ -233,19 +233,19 @@ class vector bool ensure_capacity(size_type capacity); template - void construct_helper(InputIterator first, InputIterator last, forward_iterator_tag); + void construct_helper(InputIterator first, InputIterator last, std::forward_iterator_tag); template void construct_helper(InputIterator first, InputIterator last, int_not_an_iterator_tag); void construct_helper(size_type size, const T& value); template - void insert_helper(iterator iter, InputIterator first, InputIterator last, forward_iterator_tag); + void insert_helper(iterator iter, InputIterator first, InputIterator last, std::forward_iterator_tag); template void insert_helper(iterator iter, InputIterator first, InputIterator last, int_not_an_iterator_tag); void insert_elements_helper(iterator iter, size_type size, const T& value); template - void assign_helper(InputIterator first, InputIterator last, forward_iterator_tag); + void assign_helper(InputIterator first, InputIterator last, std::forward_iterator_tag); template void assign_helper(InputIterator first, InputIterator last, int_not_an_iterator_tag); @@ -728,7 +728,7 @@ void vector::construct_helper(InputIterator first, InputIterator l template template -void vector::construct_helper(InputIterator first, InputIterator last, forward_iterator_tag) +void vector::construct_helper(InputIterator first, InputIterator last, std::forward_iterator_tag) { size_type size = iterator_difference(first, last); @@ -779,7 +779,10 @@ void vector::insert_helper(iterator iter, InputIterator first, Inp template template -void vector::insert_helper(iterator iter, InputIterator first, InputIterator last, forward_iterator_tag) +void vector::insert_helper(iterator iter, + InputIterator first, + InputIterator last, + std::forward_iterator_tag) { // m_pElem could be NULL then m_pArray would be NULL too. size_type pos = iter.m_pElem - m_pArray; @@ -809,7 +812,7 @@ void vector::insert_helper(iterator iter, InputIterator first, Inp template template -void vector::assign_helper(InputIterator first, InputIterator last, forward_iterator_tag) +void vector::assign_helper(InputIterator first, InputIterator last, std::forward_iterator_tag) { size_type size = iterator_difference(first, last); From ba4ad54dc452c95ae49913d851d02545d91fcbf4 Mon Sep 17 00:00:00 2001 From: BoyBaykiller Date: Sat, 30 May 2026 03:55:48 +0200 Subject: [PATCH 2/2] * remove compilation test --- src/coreclr/jit/fgopt.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index 28a3c47ef2195e..fa79f661f4e2f9 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -5066,12 +5066,6 @@ PhaseStatus Compiler::fgHeadTailMerge(bool early) Statement* m_stmt; }; - // Test - jitstd::vector v(getAllocator(CMK_ArrayStack)); - std::partition(v.begin(), v.end(), [](PredInfo a) { - return true; - }); - ArrayStack predInfo(getAllocator(CMK_ArrayStack)); ArrayStack matchedPredInfo(getAllocator(CMK_ArrayStack)); ArrayStack retryBlocks(getAllocator(CMK_ArrayStack));