{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift/issues/16615","repository_url":"https://api.github.com/repos/apple/swift","labels_url":"https://api.github.com/repos/apple/swift/issues/16615/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift/issues/16615/comments","events_url":"https://api.github.com/repos/apple/swift/issues/16615/events","html_url":"https://github.com/apple/swift/pull/16615","id":323018565,"number":16615,"title":"Perform value operations opaquely on ABI-inaccessible types","user":{"login":"rjmccall","id":793869,"avatar_url":"https://avatars1.githubusercontent.com/u/793869?v=4","gravatar_id":"","url":"https://api.github.com/users/rjmccall","html_url":"https://github.com/rjmccall","followers_url":"https://api.github.com/users/rjmccall/followers","following_url":"https://api.github.com/users/rjmccall/following{/other_user}","gists_url":"https://api.github.com/users/rjmccall/gists{/gist_id}","starred_url":"https://api.github.com/users/rjmccall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjmccall/subscriptions","organizations_url":"https://api.github.com/users/rjmccall/orgs","repos_url":"https://api.github.com/users/rjmccall/repos","events_url":"https://api.github.com/users/rjmccall/events{/privacy}","received_events_url":"https://api.github.com/users/rjmccall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-05-14T23:42:42Z","updated_at":"2018-05-15T19:08:13Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/16615","html_url":"https://github.com/apple/swift/pull/16615","diff_url":"https://github.com/apple/swift/pull/16615.diff","patch_url":"https://github.com/apple/swift/pull/16615.patch"},"body":"Track whether types are fixed-ABI and ABI-accessible at the SIL level.\r\n    \r\n*Fixed ABI* means that we can do value operations on the type without any metadata: value-allocations, copies, and destroys.  It's currently equivalent to being fixed-size, but (1) being fixed-size isn't useful by itself at the SIL level and (2) you can imagine resilience or generics micro-optimizations where there's like an attribute that tells us the size of a type without actually telling us how to copy it.  All types are fixed-ABI except:\r\n\r\n- layout-unconstrained generic types,\r\n- resilient value types, and\r\n- value types which contain a subobject of such a type (except within indirect enum cases).\r\n    \r\n*ABI-accessible* means that it's legal to perform value operations on the type.  We cannot perform value operations on a type `T` if it's not fixed-ABI and we can't construct metadata for it in the current file.  The latter will be true if `T` is private to a different file (in non-WMO builds) or internal to a different module because the metadata-accessor symbol will be private or hidden, respectively.  Importantly, in these cases, it always illegal to use `T` directly in the current file, which means that SIL generated from that source code won't contain any direct value operations on `T`.  However, we may be able use some type `C` that's itself permitted to use `T` and which *is* accessible to the current file.  If `C` contains subobjects of type `T`, value operations on `C` must perform value operations on `T` recursively.  This is okay as long as we don't either:\r\n\r\n- inline code that contains value operations on `T` or\r\n- naively attempt to recursively expand a value operation on `C` into value operations on its subobjects.\r\n\r\n(Note that we cannot simply treat `C` as an opaque type because we may need to perform operations on it that would not be legal on a totally opaque type, such as directly accessing a known-stored property.  It is tempting to try to define that away by saying that we never use direct property access on such types and instead go through property accessors.  However, this would require us to *guarantee* the emission of property accessors for properties, which we'd like to avoid.  Also, it's not actually possible to define this problem completely, because the current file might define a type `C2` which contains `C` as a subobject.  The same recursive trouble applies to `C2` as would apply to `C`, but we must be able to directly access the properties of `C2` in order to define its constructors and accessors.  Any model which can support directly accessing the properties of `C2` can equally support it for `C` as well.)\r\n\r\nThe SIL optimizer currently never tries to expand value operations on objects in memory.  (It does sometimes expand value operations on scalars, and this may be a problem for the opaque-values effort.)  However, IRGen currently recursively expands value operations on non-resilient types.  That is fixed as the final commit in this PR.\r\n    \r\nThe SIL verification that I've added here is definitely incomplete.\r\n\r\nFixes rdar://39763787 / [SR-7549](https://bugs.swift.org/browse/SR-7549)."},"comment":{"url":"https://api.github.com/repos/apple/swift/issues/comments/389279464","html_url":"https://github.com/apple/swift/pull/16615#issuecomment-389279464","issue_url":"https://api.github.com/repos/apple/swift/issues/16615","id":389279464,"user":{"login":"rjmccall","id":793869,"avatar_url":"https://avatars1.githubusercontent.com/u/793869?v=4","gravatar_id":"","url":"https://api.github.com/users/rjmccall","html_url":"https://github.com/rjmccall","followers_url":"https://api.github.com/users/rjmccall/followers","following_url":"https://api.github.com/users/rjmccall/following{/other_user}","gists_url":"https://api.github.com/users/rjmccall/gists{/gist_id}","starred_url":"https://api.github.com/users/rjmccall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjmccall/subscriptions","organizations_url":"https://api.github.com/users/rjmccall/orgs","repos_url":"https://api.github.com/users/rjmccall/repos","events_url":"https://api.github.com/users/rjmccall/events{/privacy}","received_events_url":"https://api.github.com/users/rjmccall/received_events","type":"User","site_admin":false},"created_at":"2018-05-15T19:08:13Z","updated_at":"2018-05-15T19:08:13Z","author_association":"MEMBER","body":"@swift-ci Please smoke test."}}
{"actor":{"display_login":"rjmccall"}}