Skip to content

Don't pass dead values into proactively added phis in SILMem2Reg #36339

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

Closed
wants to merge 3 commits into from

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Mar 6, 2021

Mem2Reg proactively inserts phis. Some of the phis maybe operands to other phis but are not stored in any specific order in PhiBlocks structure. Instead of erasing phi's that are unnecessary, and walking up the phi operand chain to check if more phis need erasing, insert a end_lifetime at leaking blocks. Such phis will be cleaned up later by DCE.

Also until now, dead values (over consumed) maybe passed to such phis. This wasn't an issue in non-OSSA because there is no verification. In OSSA, this triggers a verifier assert. This PR fixes the OSSA SIL such that no over-consumed values are generated by Mem2Reg in such cases. It does this by identifying load [take] and destroy_addr to the alloc_stack within a block not followed by any store. Such blocks are marked in the deadValueBlock map which will be used while querying the live-out value to return undef.

Note this does not translate to a real bug.

Fixes rdar://79349413

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Mar 6, 2021

Build failed
Swift Test Linux Platform
Git Sha - 46ac85e6b0408b52c26334ff5640ab4bffdd593f

@swift-ci
Copy link
Contributor

swift-ci commented Mar 6, 2021

Build failed
Swift Test OS X Platform
Git Sha - 46ac85e6b0408b52c26334ff5640ab4bffdd593f

@meg-gupta meg-gupta marked this pull request as ready for review March 24, 2021 21:36
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0075ef8cc1ed4dcf4fabee86c43824eea3547dfb

@meg-gupta meg-gupta changed the title Fixes for OSSA SILMem2Reg Cleanup dead phis in SILMem2Reg for OSSA May 18, 2021
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta force-pushed the mem2regnewfixes branch 2 times, most recently from c95fceb to fddba11 Compare May 18, 2021 21:36
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta changed the title Cleanup dead phis in SILMem2Reg for OSSA [WI]Cleanup dead phis in SILMem2Reg for OSSA May 18, 2021
@meg-gupta meg-gupta changed the title [WI]Cleanup dead phis in SILMem2Reg for OSSA [WIP] Cleanup dead phis in SILMem2Reg for OSSA May 18, 2021
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a85a171b507ff941bcd1ba022b27def9bd4573d4

@meg-gupta meg-gupta force-pushed the mem2regnewfixes branch 2 times, most recently from 5b40be7 to d258c16 Compare May 20, 2021 17:58
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta changed the title [WIP] Cleanup dead phis in SILMem2Reg for OSSA Don't pass dead values into proactively added unnecessary phis in SILMem2Reg Jun 23, 2021
@meg-gupta
Copy link
Contributor Author

@swift-ci test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 40cdb81b2172da9c44f9f7209735af701076b3b2

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 40cdb81b2172da9c44f9f7209735af701076b3b2

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta
Copy link
Contributor Author

@swift-ci test source compatibility

@meg-gupta meg-gupta changed the title Don't pass dead values into proactively added unnecessary phis in SILMem2Reg Don't pass dead values into proactively added phis in SILMem2Reg Jun 25, 2021
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b88e6b76ec57d9cb8971c85825bfec56f0d28f4c

@meg-gupta
Copy link
Contributor Author

@swift-ci test OSX platform

@meg-gupta
Copy link
Contributor Author

@swift-ci test macOS platform

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e9d1ca0104ecd3f6fd08734040bd2357521a1aa9

@meg-gupta
Copy link
Contributor Author

Opened #38265 as an alternate PR.

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.

2 participants