Skip to content

Stop using the _branchHint function #23375

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 18, 2019

Conversation

bob-wilson
Copy link
Contributor

LLVM r355981 changed various intrinsic functions, including expect,
to require immediate arguments. Swift's _branchHint function has an
expected value that is passed in as an argument, so that it cannot
use LLVM's expect intrinsic. The good news is that _branchHint is only
ever used with immediate arguments, so we can just move the intrinsic
into _fastPath and _slowPath and use those instead of _branchHint.

As was noted in the documentation, the _fastPath and _slowPath names are
confusing but we have passed the point where we can simply rename them.
We could add new names but would still need to keep the old ones around
for binary compatibility, and it is not clear that it is worth the
trouble. I have removed that note from the documentation.

LLVM r355981 changed various intrinsic functions, including expect,
to require immediate arguments. Swift's _branchHint function has an
expected value that is passed in as an argument, so that it cannot
use LLVM's expect intrinsic. The good news is that _branchHint is only
ever used with immediate arguments, so we can just move the intrinsic
into _fastPath and _slowPath and use those instead of _branchHint.

As was noted in the documentation, the _fastPath and _slowPath names are
confusing but we have passed the point where we can simply rename them.
We could add new names but would still need to keep the old ones around
for binary compatibility, and it is not clear that it is worth the
trouble. I have removed that note from the documentation.
@bob-wilson
Copy link
Contributor Author

@swift-ci please test

// never be called in cases where performance matters, so just return the
// value without any branch hint.
return actual
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to introduce a Swift50ABICompatibility.swift and move this there so that we know what version we are maintaining compatibility with. But, that is beyond the scope of this change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. My other PRs pending SE introduce a LegacyABI.swift file. It doesn't matter to me what's it's called, but splitting them out improves maintainability.

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Would be nice to split ABI compatibility hooks into separate file.

// never be called in cases where performance matters, so just return the
// value without any branch hint.
return actual
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. My other PRs pending SE introduce a LegacyABI.swift file. It doesn't matter to me what's it's called, but splitting them out improves maintainability.

@compnerd
Copy link
Member

@milseman - the reason that I was suggesting the versioning is because it can allow us to track the set that was changed between [base]-5.1, [base]-5.2, [base]-6.0, etc. It prevents a single file from growing unbounded. But, yes, that can be handled later as well.

@bob-wilson
Copy link
Contributor Author

OK. I'll wait until you add that LegacyABI.swift file (or a versioned file) and then move the _branchHint function over there.

@bob-wilson bob-wilson merged commit ba75030 into swiftlang:master Mar 18, 2019
@bob-wilson bob-wilson deleted the llvm-r355981 branch March 18, 2019 23:55
@milseman
Copy link
Member

@compnerd which version, the version it was added to the ABI or it was moved into "legacy"? The version it was introduced to the ABI is part of its @availability (default 5.0).

@bob-wilson
Copy link
Contributor Author

Follow-up PR to move _branchHint to LegacyABI.swift is in #23896

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