Add privatization of effectively thread-local globals#1966
Draft
Add privatization of effectively thread-local globals#1966
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is currently on top of #1965.
Inspired by the analysis of signal handlers as threads, it occurred to me that it is very imprecise to make the analysis go into multi-threaded mode if even one signal handler is installed, because the analysis of all globals becomes flow-insensitive.
At least with signal handlers, they are (supposed to be) small and usually read/write very few global variables. So if the rest of the program is single-threaded, it's quite crude to analyze all globals flow-insensitively.
It would be much more precise to only analyze those globals flow-insensitively which are read/written by a signal handler. All other global variables could be analyzed flow-sensitively still.
In fact, this could also be done in actual multi-threaded programs for globals which are effectively thread-local, i.e. only used by one thread.
It's kind of difficult to achieve this right now (to apply privatizations selectively) but this is a dirty attempt. The threadAccess analysis computes for each global the set of threads accessing it. If it's a singleton, then it answers the
MayBePublicquery negatively, which should improve precision of some protection-based privatizations.Some privatizations with TIDs might be able to do this out of the box anyway (?), but this kind of thing should be possible also for others, thus some extra analysis.
It isn't currently as generic as it could be though: with
noneprivatization (as used by large-program conf), the query isn't used and this cannot help, although the same selective flow-(in)sensitivity should still be possible.TODO