Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the optimizer to allocate UseDefInfo through a central location
This change implements the recommended refactoring suggested by @andrewcraik in the review comments for #2823. The background is that we need to allow setting of the _hasCallAsUses flag depending on the language front-end. However this is currently hard coded to false. Following is a copy of Andrew's recommendation. Setting _hasCallAsUses should be handled as part of the constructor if it needs to be configured by different languages. This is the first time we are going to have a language specific override of a flag like this for UseDefInfo. Looking at how it is currently used instances of TR_UseDef_info are allocated in the OMROptimizer.cpp, ValueNumberInfo.cpp and LoadExtensions.cpp. There is some variation between them in how they configure UseDefInfo for globals. I think the best way to handle this is to create a new API on the Optimizer object (eg OMROptimizer.hpp and OMROptimizer.cpp) which all current allocation sites switch to calling - the method will accept as parameters the bools which vary between the different request sites within the compiler. The value for _hasCallAsUses could be either stored as a flag in the optimizer or by overriding the build method to change how UseDefInfo is built. I would prefer the later since it means languages have a common place to configure UseDefInfo according to their needs. This small refactor would ideally be done as a separate commit and pull request ahead of changes introducing the new flag to the constructor. I hope that makes sense - if it doesn't do keep asking questions and I'll try to clarify more on how this would work. An added bonus of this is that we could improve the UseDefInfo memory management in a follow-on item which would be a another good reason to Refactor the optimizer to allocate UseDefInfo through a central location. End quote. Note that this change does not address the construction of TR_OSRDefInfo, which extends the TR_UseDefInfo class. To allow language front-ends to control this flag when use defs are analysed we need a callsAsUses flag to be held by the Optimizer and we need methods to get and set the flag. This flag will be used when constructing TR_UseDefInfo objects. The callsAsUses parameter is controlled by a virtual method in the Optimizer that front-end language implementations may override to change the default behaviour. Also the TR_UseDefInfo constructor has been made protected to avoid users making a mistake trying to construct it directly. Signed-off-by: Dibyendu Majumdar <mobile@majumdar.org.uk>
- Loading branch information
1 parent
bfe4c50
commit 775d7cf
Showing
6 changed files
with
85 additions
and
8 deletions.
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
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
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