r/cpp • • May 20 '26

Introducing Sample Profile Guided Optimization in MSVC

https://devblogs.microsoft.com/cppblog/introducing-sample-profile-guided-optimization-in-msvc
60 Upvotes

12 comments sorted by

View all comments

Show parent comment

3

u/FewCandy943 May 22 '26 edited May 22 '26

Several folks have asked, so I'll give the special linker option to compile functions with little or no profile data as if it was a non-SPGO compile. That is, if you specified -O2 on a function, it will remain so if "cold". This is a linker option:

-d2:-SpgoCompileColdFunctionsWithoutProfileData

2

u/barfyus May 23 '26

Thank you very much! That works!