-
Notifications
You must be signed in to change notification settings - Fork 5k
[mono] Workaround MSVC miscompiling sgen_clz #114786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
After the recent VS upgrade from 17.12.5 to 17.13.2 we started seeing access violations in the mono-aot-cross.exe when targetting wasm. We tracked it down to sgen_clz being miscompiled, we can workaround the compiler bug by switching from ternary condition to if/else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
@@ -60,7 +60,10 @@ static inline guint32 | |||
sgen_clz (guint32 x) | |||
{ | |||
gulong leading_zero_bits; | |||
return _BitScanReverse (&leading_zero_bits, (gulong)x) ? 31 - leading_zero_bits : 32; | |||
if (_BitScanReverse (&leading_zero_bits, (gulong)x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding an inline comment above this if/else block to explain that the change is a workaround for the MSVC miscompilation issue encountered in VS 17.13.2.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
/ba-g CI is blocked due to other issues but this is a no-op change so merging to unblock the runtime -> sdk flow |
/backport to release/9.0-staging |
/backport to release/8.0-staging |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/14593713790 |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/14593716274 |
After the recent VS upgrade from 17.12.5 to 17.13.2 we started seeing access violations in the mono-aot-cross.exe when targetting wasm.
We tracked it down to sgen_clz being miscompiled, we can workaround the compiler bug by switching from ternary condition to if/else.
Thanks to @lateralusX for the great help :)