Skip to content

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

Merged
merged 1 commit into from
Mar 9, 2017
Merged

Cleanup uses of __asm__ in the runtime #7765

merged 1 commit into from
Mar 9, 2017

Conversation

hughbe
Copy link
Contributor

@hughbe hughbe commented Feb 25, 2017

@gparker42

This also fixes some MSVC errors, as it doesn't define asm

@slavapestov
Copy link
Contributor

As @jckarter pointed out the runtime should only be built with swift-clang, but maybe the SWIFT_SYMBOL_NAME cleanup is worth it anyway?

@hughbe
Copy link
Contributor Author

hughbe commented Feb 25, 2017

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

@@ -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("");
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.)

@jckarter
Copy link
Contributor

@swift-ci Please benchmark

@jckarter
Copy link
Contributor

@swift-ci Please smoke test

@hughbe
Copy link
Contributor Author

hughbe commented Feb 26, 2017

@jckarter do you know what I've done wrong here:

/home/buildnode/jenkins/workspace/swift-PR-Linux-smoke-test/branch-master/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftCore.so: undefined reference to `ClassMirrorMetadata'
/home/buildnode/jenkins/workspace/swift-PR-Linux-smoke-test/branch-master/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftCore.so: undefined reference to `MetatypeMirrorMetadata'
/home/buildnode/jenkins/workspace/swift-PR-Linux-smoke-test/branch-master/buildbot_linux/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftCore.so: undefined reference to `EnumMirrorMetadata'

It seems like it's ignoring the macro and just trying to reference the macro's name... Hmm

@jckarter
Copy link
Contributor

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 SWIFT_PREFIXED_ALL_CAPS names, if we must, but I think MSVC has a similar feature to control symbol names.

@jckarter
Copy link
Contributor

Or you could use a reference declaration to alias the symbol instead of a macro:

extern const Foo SWIFT_MANGLED_NAME(...);
static constexpr auto &ReadableName = SWIFT_MANGLED_NAME(...);

@hughbe
Copy link
Contributor Author

hughbe commented Mar 8, 2017

@swift-ci please smoke test

1 similar comment
@hughbe
Copy link
Contributor Author

hughbe commented Mar 8, 2017

@swift-ci please smoke test

@jckarter
Copy link
Contributor

jckarter commented Mar 9, 2017

This LGTM, thanks @hughbe!

@hughbe hughbe merged commit 78d5155 into swiftlang:master Mar 9, 2017
@hughbe hughbe deleted the runtime-asm branch March 9, 2017 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants