In https://reviews.llvm.org/D8109, vector construction is optimized for trivial types using an iterator range, i.e. std::vector<int>(int* first, int* last). However, there is a bug so that const iterators are not optimized as expected, i.e. std::vector<int>(const int* first, const int* last). We're not hitting the memcpy overload of __construct_range_forward(). We're taking the slow overload instead, I believe because 'is_same<allocator_type, allocator<_Tp> >::value' check on the fast overload passes when _Tp is 'int', but fails when _Tp is 'const int'. libstdc++ does optimize the const int* version. Workaround is to const_cast<> away the const before calling the vector constructor. In our application, the workaround improves performance by 4-5x.
Fix for this issue is published for review at https://reviews.llvm.org/D48342
Fixed in r349676 and r350583.