{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift/pulls/comments/205248525","pull_request_review_id":140446574,"id":205248525,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTI0ODUyNQ==","diff_hunk":"@@ -0,0 +1,159 @@\n+# SIL Development\n+\n+This document provides information for developers working on the\n+implementation of SIL. The formal specification of the Swift\n+Intermediate _Language_ is in SIL.rst. This document contains\n+additional information specific to its implementation in the Swift\n+compiler. Source comments normally provide this level of\n+information. However, some features of the implementation are spread\n+out across the source base. This documentation is meant to offer a\n+central point for approaching the source base with links to the source\n+for more detailed comments.\n+\n+## SILType\n+\n+TBD: Define the different levels of types. Explain type lowering with\n+examples.\n+\n+## SILInstructionResults\n+\n+TBD: Explain how the various types fit together with pointers to the\n+source: SILValue, SILInstruction, SingleValueInstruction,\n+MultipleValueInstructionResult. And why it was done this way.\n+\n+## `SILFunction` and `apply` arguments.\n+\n+Throughout the compiler, integer indices are used to identify argument\n+positions in several different contexts:\n+\n+- `SILFunctionType` parameters.\n+\n+- The SIL function definition's callee-side `SILFunctionArguments`,\n+  including indirect results.\n+\n+- Caller-side \"applied arguments\" for `apply` and `try_apply` (vs. operands).\n+\n+- Captured \"applied arguments\" for `partial_apply` (vs. operands).\n+\n+- SIL arguments (any of the three above) at the Lowered SIL stage.\n+\n+An argument may have a different position in each of these\n+contexts. It should be obvious that code should never assume and\n+hard-code argument positions or offsets. Furthermore, common idioms\n+for accessing arguments should be adopted throughout the\n+compiler. Plenty of bugs have resulted from assumptions about the form\n+of SIL made in one area of the compiler that have been copied into\n+other parts of the compiler. Also, without consistent use of common\n+idioms, it becomes overly burdensome to evolve these APIs over time.\n+\n+> Note: Hardcoding offsets based on assumptions of operand layout are still\n+> surprisingly prevalent in the SIL implementation. This was carried over from\n+> LLVM practice but is actually a serious problem in SIL because: (a) the\n+> structure of SIL instructions, particularly applies, is much more nuanced than\n+> LLVM IR, (b) assumptions that may be valid at the initial point of use are\n+> often copied into parts of the code where they are no longer valid; and (c)\n+> unlike LLVM IR, SIL is not stable and will continue evolving.\n+\n+```\n+func example<T>(t: T) -> T {\n+  let foo = { return t }\n+  return foo()\n+}\n+```\n+\n+Ignoring conventions, the closure `foo` would map to the following indices...\n+\n+One direct formal parameter and one direct formal result:\n+\n+```\n+SILFunctionType(foo):  $(0:T) -> @out T\n+```\n+\n+Canonical SIL with opaque values matches `SILFunctionType` with one\n+direct `SILFunctionArgument` and one direct SILResult:\n+\n+```\n+SILFunctionArguments:  (0: $T) -> $T\n+```\n+\n+Lowered SIL has two indirect SILFunctionArguments, the first of which\n+is now a \"result argument\":\n+\n+```\n+SILFunctionArguments:  (0: $*T, 1: $*T)\n+```\n+\n+Creation of the closure has one applied argument:\n+\n+```\n+%closure = partial_apply @foo(0: %t)\n+```\n+\n+Application of the closure with opaque values has zero applied arguments:\n+\n+```\n+%result = apply %closure()\n+```\n+\n+Lowered application of the closure has one applied argument:\n+\n+```\n+apply %closure(%result: $*T)\n+```\n+\n+The mapping between SILFunctionType and SILFunctionArguments depends","path":"docs/SILDevelopment.md","position":104,"original_position":104,"commit_id":"013e5dbad36ecb9f95938237f66d764deb338e46","original_commit_id":"013e5dbad36ecb9f95938237f66d764deb338e46","user":{"login":"gottesmm","id":499423,"node_id":"MDQ6VXNlcjQ5OTQyMw==","avatar_url":"https://avatars1.githubusercontent.com/u/499423?v=4","gravatar_id":"","url":"https://api.github.com/users/gottesmm","html_url":"https://github.com/gottesmm","followers_url":"https://api.github.com/users/gottesmm/followers","following_url":"https://api.github.com/users/gottesmm/following{/other_user}","gists_url":"https://api.github.com/users/gottesmm/gists{/gist_id}","starred_url":"https://api.github.com/users/gottesmm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gottesmm/subscriptions","organizations_url":"https://api.github.com/users/gottesmm/orgs","repos_url":"https://api.github.com/users/gottesmm/repos","events_url":"https://api.github.com/users/gottesmm/events{/privacy}","received_events_url":"https://api.github.com/users/gottesmm/received_events","type":"User","site_admin":false},"body":"Maybe move this before the previous section? Then it would be clearer what you are trying to show.","created_at":"2018-07-25T20:19:02Z","updated_at":"2018-07-25T20:20:57Z","html_url":"https://github.com/apple/swift/pull/18119#discussion_r205248525","pull_request_url":"https://api.github.com/repos/apple/swift/pulls/18119","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/comments/205248525"},"html":{"href":"https://github.com/apple/swift/pull/18119#discussion_r205248525"},"pull_request":{"href":"https://api.github.com/repos/apple/swift/pulls/18119"}}},"pull_request":{"url":"https://api.github.com/repos/apple/swift/pulls/18119","id":202971024,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyOTcxMDI0","html_url":"https://github.com/apple/swift/pull/18119","diff_url":"https://github.com/apple/swift/pull/18119.diff","patch_url":"https://github.com/apple/swift/pull/18119.patch","issue_url":"https://api.github.com/repos/apple/swift/issues/18119","number":18119,"state":"open","locked":false,"title":"[NFC] SILFunctionArgument and ApplySite docs and comments.","user":{"login":"atrick","id":2165663,"node_id":"MDQ6VXNlcjIxNjU2NjM=","avatar_url":"https://avatars1.githubusercontent.com/u/2165663?v=4","gravatar_id":"","url":"https://api.github.com/users/atrick","html_url":"https://github.com/atrick","followers_url":"https://api.github.com/users/atrick/followers","following_url":"https://api.github.com/users/atrick/following{/other_user}","gists_url":"https://api.github.com/users/atrick/gists{/gist_id}","starred_url":"https://api.github.com/users/atrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atrick/subscriptions","organizations_url":"https://api.github.com/users/atrick/orgs","repos_url":"https://api.github.com/users/atrick/repos","events_url":"https://api.github.com/users/atrick/events{/privacy}","received_events_url":"https://api.github.com/users/atrick/received_events","type":"User","site_admin":false},"body":"This is in response to recurring bugs, a recently noticed bug, and feedback that the APIs don't make sense.","created_at":"2018-07-20T22:37:16Z","updated_at":"2018-07-25T20:20:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"84b734b91ce3e852953a8f827b004f65c3080ea8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apple/swift/pulls/18119/commits","review_comments_url":"https://api.github.com/repos/apple/swift/pulls/18119/comments","review_comment_url":"https://api.github.com/repos/apple/swift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift/issues/18119/comments","statuses_url":"https://api.github.com/repos/apple/swift/statuses/013e5dbad36ecb9f95938237f66d764deb338e46","head":{"label":"atrick:nfc-clarify-arg-index","ref":"nfc-clarify-arg-index","sha":"013e5dbad36ecb9f95938237f66d764deb338e46","user":{"login":"atrick","id":2165663,"node_id":"MDQ6VXNlcjIxNjU2NjM=","avatar_url":"https://avatars1.githubusercontent.com/u/2165663?v=4","gravatar_id":"","url":"https://api.github.com/users/atrick","html_url":"https://github.com/atrick","followers_url":"https://api.github.com/users/atrick/followers","following_url":"https://api.github.com/users/atrick/following{/other_user}","gists_url":"https://api.github.com/users/atrick/gists{/gist_id}","starred_url":"https://api.github.com/users/atrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atrick/subscriptions","organizations_url":"https://api.github.com/users/atrick/orgs","repos_url":"https://api.github.com/users/atrick/repos","events_url":"https://api.github.com/users/atrick/events{/privacy}","received_events_url":"https://api.github.com/users/atrick/received_events","type":"User","site_admin":false},"repo":{"id":47422455,"node_id":"MDEwOlJlcG9zaXRvcnk0NzQyMjQ1NQ==","name":"swift","full_name":"atrick/swift","owner":{"login":"atrick","id":2165663,"node_id":"MDQ6VXNlcjIxNjU2NjM=","avatar_url":"https://avatars1.githubusercontent.com/u/2165663?v=4","gravatar_id":"","url":"https://api.github.com/users/atrick","html_url":"https://github.com/atrick","followers_url":"https://api.github.com/users/atrick/followers","following_url":"https://api.github.com/users/atrick/following{/other_user}","gists_url":"https://api.github.com/users/atrick/gists{/gist_id}","starred_url":"https://api.github.com/users/atrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atrick/subscriptions","organizations_url":"https://api.github.com/users/atrick/orgs","repos_url":"https://api.github.com/users/atrick/repos","events_url":"https://api.github.com/users/atrick/events{/privacy}","received_events_url":"https://api.github.com/users/atrick/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/atrick/swift","description":"The Swift Programming Language","fork":true,"url":"https://api.github.com/repos/atrick/swift","forks_url":"https://api.github.com/repos/atrick/swift/forks","keys_url":"https://api.github.com/repos/atrick/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atrick/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atrick/swift/teams","hooks_url":"https://api.github.com/repos/atrick/swift/hooks","issue_events_url":"https://api.github.com/repos/atrick/swift/issues/events{/number}","events_url":"https://api.github.com/repos/atrick/swift/events","assignees_url":"https://api.github.com/repos/atrick/swift/assignees{/user}","branches_url":"https://api.github.com/repos/atrick/swift/branches{/branch}","tags_url":"https://api.github.com/repos/atrick/swift/tags","blobs_url":"https://api.github.com/repos/atrick/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atrick/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atrick/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/atrick/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atrick/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/atrick/swift/languages","stargazers_url":"https://api.github.com/repos/atrick/swift/stargazers","contributors_url":"https://api.github.com/repos/atrick/swift/contributors","subscribers_url":"https://api.github.com/repos/atrick/swift/subscribers","subscription_url":"https://api.github.com/repos/atrick/swift/subscription","commits_url":"https://api.github.com/repos/atrick/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/atrick/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/atrick/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/atrick/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/atrick/swift/contents/{+path}","compare_url":"https://api.github.com/repos/atrick/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atrick/swift/merges","archive_url":"https://api.github.com/repos/atrick/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atrick/swift/downloads","issues_url":"https://api.github.com/repos/atrick/swift/issues{/number}","pulls_url":"https://api.github.com/repos/atrick/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/atrick/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/atrick/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atrick/swift/labels{/name}","releases_url":"https://api.github.com/repos/atrick/swift/releases{/id}","deployments_url":"https://api.github.com/repos/atrick/swift/deployments","created_at":"2015-12-04T18:42:22Z","updated_at":"2017-02-01T18:53:27Z","pushed_at":"2018-07-24T00:13:23Z","git_url":"git://github.com/atrick/swift.git","ssh_url":"git@github.com:atrick/swift.git","clone_url":"https://github.com/atrick/swift.git","svn_url":"https://github.com/atrick/swift","homepage":"","size":287868,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"0ee0c5602f46bfede8843df120ee3533326c8441","user":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":44838949,"node_id":"MDEwOlJlcG9zaXRvcnk0NDgzODk0OQ==","name":"swift","full_name":"apple/swift","owner":{"login":"apple","id":10639145,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjM5MTQ1","avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift","description":"The Swift Programming Language","fork":false,"url":"https://api.github.com/repos/apple/swift","forks_url":"https://api.github.com/repos/apple/swift/forks","keys_url":"https://api.github.com/repos/apple/swift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift/teams","hooks_url":"https://api.github.com/repos/apple/swift/hooks","issue_events_url":"https://api.github.com/repos/apple/swift/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift/events","assignees_url":"https://api.github.com/repos/apple/swift/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift/tags","blobs_url":"https://api.github.com/repos/apple/swift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift/languages","stargazers_url":"https://api.github.com/repos/apple/swift/stargazers","contributors_url":"https://api.github.com/repos/apple/swift/contributors","subscribers_url":"https://api.github.com/repos/apple/swift/subscribers","subscription_url":"https://api.github.com/repos/apple/swift/subscription","commits_url":"https://api.github.com/repos/apple/swift/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift/merges","archive_url":"https://api.github.com/repos/apple/swift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift/downloads","issues_url":"https://api.github.com/repos/apple/swift/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift/deployments","created_at":"2015-10-23T21:15:07Z","updated_at":"2018-07-25T20:17:13Z","pushed_at":"2018-07-25T20:15:59Z","git_url":"git://github.com/apple/swift.git","ssh_url":"git@github.com:apple/swift.git","clone_url":"https://github.com/apple/swift.git","svn_url":"https://github.com/apple/swift","homepage":"https://swift.org/","size":317491,"stargazers_count":44646,"watchers_count":44646,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7039,"mirror_url":null,"archived":false,"open_issues_count":373,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":7039,"open_issues":373,"watchers":44646,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift/pulls/18119"},"html":{"href":"https://github.com/apple/swift/pull/18119"},"issue":{"href":"https://api.github.com/repos/apple/swift/issues/18119"},"comments":{"href":"https://api.github.com/repos/apple/swift/issues/18119/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift/pulls/18119/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift/pulls/18119/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift/statuses/013e5dbad36ecb9f95938237f66d764deb338e46"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"gottesmm"}}