Skip to content
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

[SR-261] Plumb ResilienceExpansion through SIL type lowering #42883

Closed
slavapestov opened this issue Dec 17, 2015 · 4 comments
Closed

[SR-261] Plumb ResilienceExpansion through SIL type lowering #42883

slavapestov opened this issue Dec 17, 2015 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@slavapestov
Copy link
Member

Previous ID SR-261
Radar None
Original Reporter @slavapestov
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 80620a631b3b2c5b96ab46096498b37c

blocks:

  • SR-257 Resilient value type support -- umbrella bug

Issue Description:

Right now, SILGen conservatively uses address-only semantics for types that are resilient anywhere. Resilient types defined in the current module however are allowed to be accessed directly, with the following caveats:

  • Transparent function bodies are serialized with the module and inlined into other SIL modules, so they must continue using address-only semantics
  • Entry points of public functions should use address-only semantics for parameters that are resilient anywhere

This means the prolog of a SIL function should load any indirect parameters that in fact have a loadable type lowering.

Private functions that pass around resilient types from the current module can use an efficient calling convention on the other hand.

  • Function values should use an abstraction pattern with address-only semantics for parameters that are resilient anywhere, to avoid re-abstraction thunks.

This means that in the following, 's' and 'ss' will use different calling conventions, but the parameter 'g' of 'f' and 'ff' will use the same one:

struct S {}
func s(s: S) {ss(s) }
public func ss(s: S) {}

func f(g: S -> S) { ff(g) } // no thunking of 'g' here
public func ff(g: S -> S) {}

This requires adding a ResilienceExpansion to SILFunction and changing SILGenFunction's type lowering to pass this down to the TypeConverter. The TypeConverter will then need to cache different type lowerings for each ResilienceExpansion. This might increase memory usage too much – if so, some trick can be used where a type that has the same lowering in all expansions doesn't need to store the expansion as part of the key.

@slavapestov
Copy link
Member Author

rdar://24057844

@Dante-Broggi
Copy link
Contributor

Is this resolved? If so, this should be closed.

@slavapestov
Copy link
Member Author

No, it's not.

@slavapestov
Copy link
Member Author

#23170

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants