Skip to content

Devirtualizer: disable the “effectively final” optimization if a function is inlinable #14740

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
Feb 20, 2018

Conversation

shajrawi
Copy link

radar rdar://problem/36703886

The devirtualizer performs two optimizations:

  • If a value is known to have an exact class type, ie it is the result of an alloc_ref, we can devirtualize calls of non-final methods, because we know we’re calling that specific method and not an override.

  • If a method is known to be “effectively final” (it is not open, and there are no overrides inside the module) we can devirtualize it.

However the second optimization needs to be disabled if a function is inlinable (F->getResilienceExpansion() == ResilienceExpansion::Minimal).

…tion is inlinable.

The devirtualizer performs two optimizations:

- If a value is known to have an exact class type, ie it is the result of an alloc_ref, we can devirtualize calls of *non-final* methods, because we know we’re calling that specific method and not an override.

- If a method is known to be “effectively final” (it is not open, and there are no overrides inside the module) we can devirtualize it.

However the second optimization needs to be disabled if a function is inlinable (F->getResilienceExpansion() == ResilienceExpansion::Minimal).
@shajrawi
Copy link
Author

@swift-ci Please test and merge

@swift-ci swift-ci merged commit 4d9e1b0 into swiftlang:master Feb 20, 2018
@shajrawi shajrawi deleted the devirt_inline branch February 20, 2018 16:36
shajrawi pushed a commit to shajrawi/swift that referenced this pull request Jun 19, 2018
…ller is serialized

Improve the check done in swiftlang#14740

The class_method being devirtualized might be OK for most call sites, i.e. we are allowed to devirtualize it, however, the caller itself might have been marked with inlinable
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.

2 participants