Skip to content

add __forceinline to std::unreachable instead of inline - #3055

Merged
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
fsb4000:force_inline_unreachable
Aug 27, 2022
Merged

Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
fsb4000:force_inline_unreachable

Conversation

@fsb4000

Copy link
Copy Markdown
Contributor

Co-authored-by: Alexander Bessonov alexbav@hhdsoftware.com

From #3051

And we already use __forceinline there:

_NODISCARD __forceinline uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) {

@fsb4000
Igor Zhukov (fsb4000) requested a review from a team as a code owner August 25, 2022 16:09
@strega-nil-ms

Copy link
Copy Markdown
Contributor

This looks extremely reasonable to me, personally - we know that MSVC does not consider [[noreturn]] functions for inlining unless they're marked with __forceinline. I would like to see what the opinions of the other maintainers are, though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the rest of the team thinks this is reasonable, this is obviously the correct way to implement this.

@StephanTLavavej

Copy link
Copy Markdown
Member

I agree with nicole mazzuca (@strega-nil-ms), and Alex Bessonov (@AlexBAV)'s codegen example https://godbolt.org/z/a9d33hc5b shows that this makes a difference for /O2. In __ryu_umul128, the use of __forceinline was a compiler workaround (marked TRANSITION), but here the compiler's behavior regarding [[noreturn]] is reasonable and so __forceinline is also a reasonable perma-workaround. (The Ryu/charconv usage proves that __forceinline shouldn't cause other issues due to its non-Standardness.)

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit c23bbd8 into microsoft:main Aug 27, 2022
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for improving the STL's performance to previously unreachable levels! 📈 🚀 😹

@fsb4000
Igor Zhukov (fsb4000) deleted the force_inline_unreachable branch August 27, 2022 01:42
@AlexBAV

Copy link
Copy Markdown
Contributor

Thanks for improving the STL's performance to previously unreachable levels! 📈 🚀 😹

You're always welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants