-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Cleanup uses of __asm__ in the runtime #7765
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
As @jckarter pointed out the runtime should only be built with swift-clang, but maybe the SWIFT_SYMBOL_NAME cleanup is worth it anyway? |
Yeah this ones about cleaning up some uses - I think the rest of the runtime doesn't use asm but does what I've changed this to |
stdlib/public/runtime/Casting.cpp
Outdated
@@ -169,7 +169,9 @@ void | |||
swift::swift_dynamicCastFailure(const void *sourceType, const char *sourceName, | |||
const void *targetType, const char *targetName, | |||
const char *message) { | |||
#if !defined(_WIN32) | |||
asm(""); |
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.
@rjmccall or @gparker42, do either of you recall why this is here? If it were intended as an optimization barrier, wouldn't it have to be volatile
? As is, this would be a no-op even on Clang, AIUI.
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.
The intent is to preserve that frame in stack traces. I know the asm("") is necessary when the function is empty. This function is not empty so noinline alone may be sufficient.
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.
(If the function is empty and you use noinline without asm("") then the optimizer may simply delete the call at the call site. Technically that doesn't count as inlining. asm("") inhibits that optimization.)
@swift-ci Please benchmark |
@swift-ci Please smoke test |
@jckarter do you know what I've done wrong here:
It seems like it's ignoring the macro and just trying to reference the macro's name... Hmm |
I think we want the asm names. Macros aren't namespaced and lead to problems when you try to refer to something else with the same name. We should make them obviously macros with |
Or you could use a reference declaration to alias the symbol instead of a macro:
|
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
This LGTM, thanks @hughbe! |
@gparker42
This also fixes some MSVC errors, as it doesn't define asm