-
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 regions #971
Verify regions #971
Conversation
compiler/modules/bir/verify.bal
Outdated
check verifyNonFinalRegisterKind(vc, insn.operands[0]); | ||
} | ||
else if insn is MultipleOpeandInsn { | ||
foreach var op in <Operand[]>insn.operands { |
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.
@jclark without the type cast it throws the error
ERROR [verify.bal:(125:27,125:40)] incompatible types: '((wso2/nballerina.bir:0.1.0:IntOperand[2] & readonly)|(wso2/nballerina.bir:0.1.0:IntOperand[2] & readonly)|(wso2/nballerina.bir:0.1.0:IntOperand[2] & readonly)|(wso2/nballerina.bir:0.1.0:FloatOperand[2] & readonly)|(wso2/nballerina.bir:0.1.0:DecimalOperand[2] & readonly)|(wso2/nballerina.bir:0.1.0:Operand[2] & readonly)|(wso2/nballerina.bir:0.1.0:Operand[] & readonly)|([wso2/nballerina.bir:0.1.0:Register,wso2/nballerina.bir:0.1.0:IntOperand] & readonly)|(wso2/nballerina.bir:0.1.0:Operand[] & readonly)|([wso2/nballerina.bir:0.1.0:Register,wso2/nballerina.bir:0.1.0:StringOperand] & readonly)|(wso2/nballerina.bir:0.1.0:StringOperand[2] & readonly))' is not an iterable collection
This seems independent of the insn type. Even if we use just 2 instructions with same operands
it still fails.
For type MultipleOpeandInsn ListConstructInsn|MappingConstructInsn;
incompatible types: '((wso2/nballerina.bir:0.1.0:Operand[] & readonly)|(wso2/nballerina.bir:0.1.0:Operand[] & readonly))' is not an iterable collection
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.
Added an issue for JBUG in ballerina-platform/ballerina-lang#35557
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.
Can we work around by assigning to a variable before iterating?
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.
Yes, changed it to assign and iterate.
Hi @jclark |
For tmp, I was envisaging that we would check that it occurs as the result of exactly one instruction. |
compiler/modules/bir/verify.bal
Outdated
|
||
function verifyRegistersKinds(VerifyContext vc, Insn insn) returns Error? { | ||
if insn !is NonResultInsn { | ||
vc.definedTmpRegisters.push(insn.result.number); | ||
if vc.definedTmpRegisters.indexOf(insn.result.number, 0) != () { |
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.
No need for 0
its the defualt
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.
Fixed.
compiler/modules/bir/verify.bal
Outdated
|
||
function verifyNonFinalRegisterKind(VerifyContext vc, Operand r) returns Error? { | ||
if r is FinalRegister { | ||
return vc.invalidErr("invalid register kind final for insn: " + r.kind, <Position>r.pos); |
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.
too many spaces in indention.
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.
First of all, in the issue write a precise description of everything that you are checking.
compiler/modules/bir/verify.bal
Outdated
} | ||
} | ||
|
||
type MultipleOpeandInsn IntBinaryInsn|IntNoPanicArithmeticBinaryInsn|FloatArithmeticBinaryInsn |
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.
Spelling
compiler/modules/bir/verify.bal
Outdated
|DecimalArithmeticBinaryInsn|CompareInsn|ListConstructInsn|ListGetInsn|MappingConstructInsn | ||
|MappingGetInsn|StringConcatInsn|EqualityInsn; | ||
|
||
type NonResultInsn MappingSetInsn|ListSetInsn|BranchInsn|CondBranchInsn|CondNarrowInsn|PanicInsn |
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 it the other way round: ResultInsn
.
compiler/modules/bir/verify.bal
Outdated
|
||
function init(Module mod, FunctionDefn defn) { | ||
final FunctionCode code; | ||
int[] definedTmpRegisters = []; |
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.
boolean[] tmpRegisterUsed
compiler/modules/bir/verify.bal
Outdated
if r !is Register { | ||
return; | ||
} | ||
if r is TmpRegister && vc.definedTmpRegisters.indexOf(r.number) == () { |
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.
Don't want to make assumptions here about ordering of blocks.
I can't review this until the description of the problem in #995 is fixed. |
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.
Please fix the problems with the issue description in #995 first.
Partially fixes #995