r/cpp • ReSharper C++ Dev • May 07 '18

Visual Studio 15.7 is out, with C++17 conformance (with full expression SFINAE and improved two-phase name lookup), ClangFormat support, parallel algorithms, reimplemented coroutine backend, and lots of other fixes

https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes#15.7.0
293 Upvotes

145 comments sorted by

View all comments

Show parent comments

42

u/STL MSVC STL Dev May 07 '18

That's thanks to Billy's perf work! (The issue was my fault, as when I overhauled vector for correctness, I didn't pay attention to inlining consequences.)

1

u/zerexim May 09 '18

Is that PJ?

1

u/STL MSVC STL Dev May 09 '18

Billy O'Neal.

1

u/[deleted] May 09 '18

No, sorry; my name just adds to confusion.

It also breaks a lot of web pages when you add the last name. :P

-11

u/Z01dbrg May 08 '18

The issue was my fault

Not really. Any decent optimizer should understand that push_back should be inlined.

9

u/Sirflankalot Allocate me Daddy May 08 '18

That's not how optimizers work. They don't know about anything in particular, they just do the transforms they are able to do.

3

u/[deleted] May 08 '18

The issue was that previously, push_back was *huge* and thus not a good inline candidate. The optimizer made the correct decision to not inline that.

If the optimizer gets partial inlining support someday it would have been able to do this but to my knowledge none of the major production compilers do that (yet).

1

u/Z01dbrg May 08 '18 edited May 08 '18

The issue was that previously, push_back was huge and thus not a good inline candidate.

I guess that just putting part of push_back in separate function you call from push_back while leaving happy path should help. And I assume you did that.

If the optimizer gets partial inlining support someday it would have been able to do this but to my knowledge none of the major production compilers do that (yet).

Or he learns about the high level world of C+++. Meaning that he understands .reserve(.size()+x) and then x push_backs mean no realloc.

P.S. I just learned that your compiler has a bug there it considers sizeof... result int instead of size_t, do you know about it or do you need a repo? https://imgur.com/a/18H5kop

Also surprise surprise this does not compile in VS 15.7 https://godbolt.org/g/fKAEPL

2

u/[deleted] May 08 '18

I guess that just putting part of push_back in separate function you call from push_back while leaving happy path should help. And I assume you did that.

Factoring out the big "what happens if we reallocate" function was indeed the change here :)

1

u/Z01dbrg May 08 '18

Can you answer about the bugs?

I would really feel like an idiot wasting time to report bugs that are known to you for years.

2

u/[deleted] May 08 '18 edited May 08 '18

If they are bugs in the frontend I'm not really qualified to speak about them, sorry.

EDIT: I filed the second one as a bug against the FE team

1

u/Z01dbrg May 08 '18

Thank you. Here is a repo for the other one also: https://godbolt.org/g/ZfuJiL

note that code is not minimal, but when I tried to minimize it bug went away :) and I do not know how MSVC works internally so I can't make educated guesses about how to minimize it so that bug remains.

Wrong error is: C2397: conversion from 'int' to 'size_t' requires a narrowing conversion

2

u/[deleted] May 09 '18 edited May 09 '18

Reduced to:

C:\Users\bion\Desktop>type test.cpp
using size_t = decltype(sizeof(int));

template<class A, class B>
inline constexpr bool is_same_v = false;
template<class A>
inline constexpr bool is_same_v<A, A> = true;

template<size_t>
struct integral_constant;

template<auto... H>
struct if_set_bsearch {
#ifdef WORKAROUND
    static constexpr size_t sz = sizeof...(H);
#else
        static constexpr auto sz = sizeof...(H);
#endif

        static_assert(is_same_v<decltype(sz/2), size_t>);
        using left = integral_constant<size_t{ sz / 2 }>;
};

template struct if_set_bsearch<2, 3, 5, 7, 11>;

C:\Users\bion\Desktop>cl /EHsc /W4 /WX /std:c++latest .\test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26412 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
.\test.cpp(20): error C2397: conversion from 'int' to 'size_t' requires a narrowing conversion
.\test.cpp(21): note: see reference to class template instantiation 'if_set_bsearch<H...>' being compiled

C:\Users\bion\Desktop>cl /nologo /DWORKAROUND /EHsc /W4 /WX /std:c++latest .\test.cpp
test.cpp
LINK : fatal error LNK1561: entry point must be defined

C:\Users\bion\Desktop>

and filed.

2

u/Z01dbrg May 09 '18

Awesome... Thank you.

I guess this is some internal tracking tool that has no access for nonMSFT people?

→ More replies (0)

1

u/[deleted] May 31 '18

Looks like JonCaves fixed the "pack expansion into initializer_list fails" bug in 15.8.