-
Notifications
You must be signed in to change notification settings - Fork 2k
C#: Replace SSA classes with shared code. #21762
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
Changes from 5 commits
7ef9e1b
72d21a9
e5d219a
fb438bf
83c7a33
2545f06
c88a22c
9345c44
ed6cdfc
a6c7f27
dc34b10
31e06bc
6ecdf3f
9a7eb8d
65f647a
80d5e27
de96b5a
55b83ca
bedadc9
e0421db
77807c8
ff8ab19
d3df5ce
5fbba0e
439a67a
351e9cc
e012981
21a0d14
1f3a831
02f5fe9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,14 @@ | |
| */ | ||
|
|
||
| import csharp | ||
| private import internal.SsaImpl as SsaImpl | ||
| import SsaImpl::Ssa_ | ||
|
|
||
| /** | ||
| * Provides classes for working with static single assignment (SSA) form. | ||
| */ | ||
| module Ssa { | ||
| private import internal.SsaImpl as SsaImpl | ||
| import SsaImpl::Ssa_ | ||
|
|
||
| pragma[nomagic] | ||
| private predicate assignableDefinitionLocalScopeVariable( | ||
|
|
@@ -147,6 +149,47 @@ module Ssa { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets a read of the source variable underlying the SSA definition `def` | ||
| * that can be reached from `def` without passing through any | ||
| * other SSA definition or read. Example: | ||
| * | ||
| * ```csharp | ||
| * int Field; | ||
| * | ||
| * void SetField(int i) { | ||
| * this.Field = i; | ||
| * Use(this.Field); | ||
| * if (i > 0) | ||
| * this.Field = i - 1; | ||
| * else if (i < 0) | ||
| * SetField(1); | ||
| * Use(this.Field); | ||
| * Use(this.Field); | ||
| * } | ||
| * ``` | ||
| * | ||
| * - The read of `i` on line 4 can be reached from the explicit SSA | ||
| * definition (wrapping an implicit entry definition) on line 3. | ||
| * - The reads of `i` on lines 6 and 7 are not the first reads of any SSA | ||
| * definition. | ||
| * - The read of `this.Field` on line 5 can be reached from the explicit SSA | ||
| * definition on line 4. | ||
| * - The read of `this.Field` on line 10 can be reached from the phi node | ||
| * between lines 9 and 10. | ||
| * - The read of `this.Field` on line 11 is not the first read of any SSA | ||
| * definition. | ||
| * | ||
| * Subsequent reads can be found by following the steps defined by | ||
| * `AssignableRead.getANextRead()`. | ||
| */ | ||
| AssignableRead ssaGetAFirstUse(SsaDefinition def) { | ||
| exists(ControlFlowNode cfn | | ||
| SsaImpl::firstReadSameVar(def, cfn) and | ||
| result.getControlFlowNode() = cfn | ||
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest folding this into the cached predicate
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll fold it in, but I'm a bit hesitant to rename the predicate as it doesn't match the semantics of the Java version. In Java the firstUse predicate allows flow through phi nodes (it has |
||
| } | ||
|
|
||
| /** | ||
| * A static single assignment (SSA) definition. Either an explicit variable | ||
| * definition (`ExplicitDefinition`), an implicit variable definition | ||
|
|
@@ -227,6 +270,8 @@ module Ssa { | |
| } | ||
|
|
||
| /** | ||
| * DEPRECATED: Use `ssaGetAFirstUse` instead. | ||
| * | ||
| * Gets a read of the source variable underlying this SSA definition that | ||
| * can be reached from this SSA definition without passing through any | ||
| * other SSA definition or read. Example: | ||
|
|
@@ -260,9 +305,11 @@ module Ssa { | |
| * Subsequent reads can be found by following the steps defined by | ||
| * `AssignableRead.getANextRead()`. | ||
| */ | ||
| final AssignableRead getAFirstRead() { result = this.getAFirstReadAtNode(_) } | ||
| deprecated final AssignableRead getAFirstRead() { result = this.getAFirstReadAtNode(_) } | ||
|
|
||
| /** | ||
| * DEPRECATED: Use `ssaGetAFirstUse` instead. | ||
| * | ||
| * Gets a read of the source variable underlying this SSA definition at | ||
| * control flow node `cfn` that can be reached from this SSA definition | ||
| * without passing through any other SSA definition or read. Example: | ||
|
|
@@ -296,7 +343,7 @@ module Ssa { | |
| * Subsequent reads can be found by following the steps defined by | ||
| * `AssignableRead.getANextRead()`. | ||
| */ | ||
| final AssignableRead getAFirstReadAtNode(ControlFlowNode cfn) { | ||
| deprecated final AssignableRead getAFirstReadAtNode(ControlFlowNode cfn) { | ||
| SsaImpl::firstReadSameVar(this, cfn) and | ||
| result.getControlFlowNode() = cfn | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.