-
Notifications
You must be signed in to change notification settings - Fork 237
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
[SSA] Fix bug in to_ssa.py #111
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@main() { | ||
cond: bool = const true; | ||
br cond .true .false; | ||
.true: | ||
a: int = const 0; | ||
jmp .zexit; | ||
.false: | ||
b: int = const 1; | ||
jmp .zexit; | ||
# zexit to trigger a bug in to_ssa.py that depends on | ||
# the order that basic blocks get renamed. | ||
.zexit: | ||
print a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@main { | ||
.b1: | ||
cond.0: bool = const true; | ||
br cond.0 .true .false; | ||
.true: | ||
a.0: int = const 0; | ||
jmp .zexit; | ||
.false: | ||
b.0: int = const 1; | ||
jmp .zexit; | ||
.zexit: | ||
b.1: int = phi b.0 b.0 .false .true; | ||
a.1: int = phi __undefined a.0 .false .true; | ||
print a.1; | ||
ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@main(cond: bool) { | ||
.entry: | ||
a.1: int = const 47; | ||
br cond .left .right; | ||
.left: | ||
a.2: int = add a.1 a.1; | ||
jmp .zexit; | ||
.right: | ||
a.3: int = mul a.1 a.1; | ||
jmp .zexit; | ||
# zexit to trigger a bug in to_ssa.py that depends on | ||
# the order that basic blocks get renamed. | ||
.zexit: | ||
a.4: int = phi .left a.2 .right a.3; | ||
print a.4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@main(cond: bool) { | ||
.entry: | ||
a.1.0: int = const 47; | ||
br cond .left .right; | ||
.left: | ||
a.2.0: int = add a.1.0 a.1.0; | ||
jmp .zexit; | ||
.right: | ||
a.3.0: int = mul a.1.0 a.1.0; | ||
jmp .zexit; | ||
.zexit: | ||
a.3.1: int = phi __undefined a.3.0 .left .right; | ||
a.2.1: int = phi a.2.0 a.2.0 .left .right; | ||
a.4.0: int = phi a.2.1 a.3.1 .left .right; | ||
print a.4.0; | ||
ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't 100% necessary, as
brili
supportsphi
nodes with incomplete sets of labels. If the label isn't present it treats the variable as undefined. However, the bril spec says that "It is an error to use a phi instruction when [..] the instruction does not contain an entry for the second-most-recently-executed label".Let me know what you would prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfect! I can definitely see it going either way, but I like that this version of the pass, at least, maintains the invariant that phi-nodes reflect the in-degree of the CFG node they are attached to (as they do in LLVM, for example).