-
Notifications
You must be signed in to change notification settings - Fork 46
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
Verify tmp registers #1010
Open
ushirask
wants to merge
24
commits into
ballerina-platform:main
Choose a base branch
from
ushirask:995_register
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Verify tmp registers #1010
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4d7932a
Verify register kinds
ushirask 11f3509
Rename function
ushirask 9318029
make variables private
ushirask 753c457
Merge branch 'ballerina-platform:main' into 995_register
ushirask abdbf53
fix conflicts
ushirask 3a4c0df
Refactor code
ushirask 8eba31b
Merge branch 'ballerina-platform:main' into 995_register
ushirask f2a1382
Refactor code
ushirask e2ec714
Use match statment
ushirask d6879e7
Remove unused param
ushirask 4d12ef0
Refactor code
ushirask 54ce38f
Refactor code
ushirask 87e1184
Refactor code
ushirask 0b1638e
Rename to tmpRegisterInit
ushirask 06d93f7
Rename function
ushirask d16e0b2
Rename param
ushirask a5b3a3f
Remove incorrect verification
ushirask 9546bee
Remove incorrect verification
ushirask 82cfbb3
Move TypeMerge/Branch checks
ushirask 59b6c9f
Fix match stmt assign tmp
ushirask 88838a1
Fix foreach stmt assign tmp
ushirask 2895ca3
Remove tmp register read check
ushirask f264fd5
Remove unused function
ushirask 029c548
Rename function
ushirask 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 |
---|---|---|
|
@@ -67,18 +67,34 @@ class VerifyContext { | |
|
||
public function verifyFunctionCode(Module mod, FunctionDefn defn, FunctionCode code) returns Error? { | ||
VerifyContext cx = new(mod, defn); | ||
boolean[] tmpRegisterInitialized = []; | ||
if code.registers.length() > 0 { | ||
tmpRegisterInitialized[code.registers.length() - 1] = false; | ||
} | ||
foreach BasicBlock b in code.blocks { | ||
check verifyBasicBlock(cx, b); | ||
check verifyBasicBlock(cx, b, tmpRegisterInitialized); | ||
} | ||
} | ||
|
||
type IntBinaryInsn IntArithmeticBinaryInsn|IntBitwiseBinaryInsn; | ||
|
||
type Error err:Semantic|err:Internal; | ||
|
||
function verifyBasicBlock(VerifyContext vc, BasicBlock bb) returns Error? { | ||
function verifyBasicBlock(VerifyContext vc, BasicBlock bb, boolean[] tmpRegisterInitialized) returns Error? { | ||
foreach Insn insn in bb.insns { | ||
check verifyInsn(vc, insn); | ||
check verifyTmpRegisters(vc, insn, tmpRegisterInitialized); | ||
} | ||
} | ||
|
||
function verifyTmpRegisters(VerifyContext vc, Insn insn, boolean[] tmpRegisterInitialized) returns Error? { | ||
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. let's call this |
||
if insn is ResultInsnBase { | ||
if tmpRegisterInitialized[insn.result.number] { | ||
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. Add |
||
return vc.invalidErr("multiple assignments to a tmp register", insn.pos); | ||
} | ||
else { | ||
tmpRegisterInitialized[insn.result.number] = true; | ||
} | ||
} | ||
} | ||
|
||
|
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.
Cleaner to do
tmpRegisterIntialized.setLength(code.registers.length());