analyze: use a common namespace for all local and global PointerIds#1164
Merged
Conversation
5854a95 to
01598e1
Compare
1726a71 to
4a634a7
Compare
4a634a7 to
ca0d95e
Compare
01598e1 to
e4e4d46
Compare
ahomescu
approved these changes
Nov 27, 2024
|
|
||
| impl NextLocalPointerId { | ||
| pub fn new() -> NextLocalPointerId { | ||
| pub fn _new() -> NextLocalPointerId { |
Collaborator
Author
There was a problem hiding this comment.
The function is currently unused, but I've left it in place for completeness of the API (NextGlobalPointerId has a fn new(), so the local version should too) and in case it's needed again in the future. To suppress the dead code warning, I prefer a leading underscore rather than #[allow(dead_code)] because it makes it more likely that anyone who starts using the function in the future will also remember to un-suppress the warning.
We still track local vs. global internally, but only for debugging. The `GLOBAL_BIT` flag is ignored in comparisons, and `PointerId` provides no public API for checking it.
ca0d95e to
5830b4f
Compare
b68e568 to
53d1014
Compare
53d1014 to
2149fa6
Compare
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.
Currently, each function has its own namespace for local
PointerIds:PointerId::local(3)in functionfis distinct fromPointerId::local(3)in functiong. This creates some problems for pointee type inference*. This branch puts all functions' localPointerIds into a common namespace, with each function occupying a different range in that space. This means eachPointerIdis now globally unique, and code that is analyzing one function can mentionPointerIds from a different function without ambiguity.Most analyses still only look at a single function; these use a sparse
PointerTablethat has entries only for globalPointerIds (that is,PointerIds in the range allocated for globals) and for the localPointerIds of the current function. Any analyses that need to consider cross-function localPointerIds can use a single largeGlobalPointerTableinstead.* The specific issue is this: the allocation in lighttpd's
buffer_initis not initialized inside that function, so correctly inferring the type requires unifying type variables interprocedurally. The type variables for the pointee analysis are tracked in aVarTable, which containsLTys. We'd like to track variables from all functions in one bigVarTable, so that we can unify variables that originated in different functions. However,LTys may contain localPointerIds, so a sharedVarTablecould mix up localPointerIds from different functions/namespaces, producing nonsensical results. The fix being applied here is to put allPointerIds into a single namespace, so all type variables can be tracked in a commonVarTable, and there is no longer an obstacle to unifying type variables from different functions.