Skip to content
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

Compiler Bug : overwriting definitions in defuse (#2900) #2971

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

Jovana-Syrmia
Copy link
Contributor

@Jovana-Syrmia Jovana-Syrmia commented Dec 1, 2021

Fixes #2900

Bug in file def_use in method setDefinitionsAt class AllDefinitions
In that method definition in map atPoint is overridden

This happens beacuse there is more than one AsssignStatement with the same id
Pass KeySideEffect is creating those AssignStatements (in method KeySideEffect::doStatement)
This method creates a BlockStatement and inserts AssignStatements from TableInsertions variable and then inserts that block before tbl.apply()

Bug is removed by cloning an AssignStatement before inserting it in a BlockStatement

Backend pass CopyMatchKeysToSingleStruct inherits KeySideEffect
Backend uses this pass to transform tables such that all the Match keys are part of the same header/metadata struct
With cloning two test fail (psa-dpdk-table-key-consolidation-if*) in spec file
This happens because for every assignment DpdkMovStatement is created and inserted in instractions (pass ConvertStatementToDpdk)
There is no need for this new DpdkMovStatements because src is already in dest (it is done the first time we call tbl.apply)

This is fixed by setting SideEffect::doStatement to be virtual and overriding it in class CopyMatchKeysToSingleStruct
In this override there is no cloning

* Bug in file def_use in method setDefinitionsAt class AllDefinitions
* In that method definition in map atPoint is overridden

* This happens beacuse there is more than one AsssignStatement with the same id
* Pass KeySideEffect is creating those AssignStatements (in method KeySideEffect::doStatement)
* This method creates a BlockStatement and inserts AssignStatements from TableInsertions variable and then inserts that block before tbl.apply()

* Bug is removed by cloning an AssignStatement before inserting it in a BlockStatement

* Backend pass CopyMatchKeysToSingleStruct inherits KeySideEffect
* Backend uses this pass to transform tables such that all the Match keys are part of the same header/metadata struct
* With cloning two test fail (psa-dpdk-table-key-consolidation-if*) in spec file
* This happens because for every assignment DpdkMovStatement is created and inserted in instractions (pass ConvertStatementToDpdk)
* There is no need for this new DpdkMovStatements because src is already in dest (it is done the first time we call tbl.apply)

* This is fixed by setting SideEffect::doStatement to be virtual and  overriding it in class CopyMatchKeysToSingleStruct
* In this override there is no cloning

* Added test for issue 2900 (bug.p4 that was given in issue discussion)
* Added expected outputs for that test
@Jovana-Syrmia
Copy link
Contributor Author

Jovana-Syrmia commented Dec 1, 2021

I just saw PR from mvido, we were dealing with the same issue.

@mihaibudiu
Copy link
Contributor

The problem is not that two nodes have the same id, the problem is that the to IR nodes are in fact the same exact node. We keep pointers to nodes in hash-tables, so a node cannot be mapped to two different values in the hash-table. See also the discussion from #2969

@mihaibudiu mihaibudiu merged commit f520931 into p4lang:main Dec 1, 2021
@Jovana-Syrmia Jovana-Syrmia deleted the issue2900 branch December 2, 2021 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler Bug: overwriting definitions in defuse analysis
2 participants