Skip to content

Document the @noescape SIL function type attribute. #15077

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, 2018
Merged

Document the @noescape SIL function type attribute. #15077

merged 1 commit into from
Mar 9, 2018

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Mar 8, 2018

No description provided.

@atrick atrick requested a review from aschwaighofer March 8, 2018 17:00
docs/SIL.rst Outdated
@@ -437,7 +437,13 @@ number of ways:
a guaranteed direct parameter.

- Otherwise, the context value is treated as an unowned direct
parameter.
parameter. FIXME!!! what is this?? It sounds like ``@noescape
Copy link
Contributor

@aschwaighofer aschwaighofer Mar 8, 2018

Choose a reason for hiding this comment

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

This predates @noescape. @convention(block)'s context is passed unowned

From test/IRGen/objc_block.sil:

// CHECK-LABEL: define{{( protected)?}} swiftcc %T10objc_block3FooC* @call_block(%objc_block*, %T10objc_block3FooC*) {{.*}} {
// CHECK:       entry:
// CHECK:         [[T0:%.*]] = getelementptr inbounds %objc_block, %objc_block* %0, i32 0, i32 3
// CHECK:         [[T1:%.*]] = load i8*, i8** [[T0]]
// CHECK:         [[T2:%.*]] = bitcast i8* [[T1]] to i8* (%objc_block*, i8*)*
// CHECK:         [[T3:%.*]] = bitcast %T10objc_block3FooC* %1 to i8*
// CHECK:         [[T4:%.*]] = call i8* [[T2]](%objc_block* %0, i8* [[T3]])
// CHECK:         [[T5:%.*]] = bitcast i8* [[T4]] to %T10objc_block3FooC*
// CHECK:         ret %T10objc_block3FooC* [[T5]]
// CHECK:       }

@atrick
Copy link
Contributor Author

atrick commented Mar 8, 2018

@aschwaighofer is it fair to say that @callee_x attribute implies @convention(thick) attribute?

@aschwaighofer
Copy link
Contributor

It only makes sense to have an ownership qualifier for the context on a function representation that has a context. Yes I think so.

@aschwaighofer
Copy link
Contributor

We can have:

  • @convention(thin) () -> ()
    No context, can be converted to a @convention(thin) @NoEscape type.

  • @convention(block) () -> ()
    Objective-C block convention; context is passed @unowned in spirit.

  • Thick swift function types: @callee_guaranteed () -> ()
    Can be @NoEscape in which case the context value is treated as a trivial type -- which admittedly is a little odd because we still spell out ownership (which we usually only do for reference counted things).
    @callee_owned is dead.

@atrick
Copy link
Contributor Author

atrick commented Mar 8, 2018

@aschwaighofer here's another revision. I'll let you figure out how to kill off @callee_owned. It's still all over the tests and handled in ParseDecl.cpp.

@aschwaighofer
Copy link
Contributor

This looks good to me.

@atrick atrick changed the title [WIP] Document the @noescape SIL function type attribute. Document the @noescape SIL function type attribute. Mar 8, 2018
@atrick
Copy link
Contributor Author

atrick commented Mar 8, 2018

@swift-ci smoke test and merge.

1 similar comment
@atrick
Copy link
Contributor Author

atrick commented Mar 8, 2018

@swift-ci smoke test and merge.

@swift-ci swift-ci merged commit 0b9c973 into swiftlang:master Mar 9, 2018
@atrick atrick deleted the noescape-doc branch May 9, 2018 23:47
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.

3 participants