-
Notifications
You must be signed in to change notification settings - Fork 254
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
analyze: use a common namespace for all local and global PointerIds #1164
Conversation
5854a95
to
01598e1
Compare
1726a71
to
4a634a7
Compare
4a634a7
to
ca0d95e
Compare
01598e1
to
e4e4d46
Compare
#[derive(Clone, Debug)] | ||
pub struct NextLocalPointerId(u32); | ||
|
||
impl NextLocalPointerId { | ||
pub fn new() -> NextLocalPointerId { | ||
pub fn _new() -> NextLocalPointerId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the rename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Currently, each function has its own namespace for local
PointerId
s:PointerId::local(3)
in functionf
is distinct fromPointerId::local(3)
in functiong
. This creates some problems for pointee type inference*. This branch puts all functions' localPointerId
s into a common namespace, with each function occupying a different range in that space. This means eachPointerId
is now globally unique, and code that is analyzing one function can mentionPointerId
s from a different function without ambiguity.Most analyses still only look at a single function; these use a sparse
PointerTable
that has entries only for globalPointerId
s (that is,PointerId
s in the range allocated for globals) and for the localPointerId
s of the current function. Any analyses that need to consider cross-function localPointerId
s can use a single largeGlobalPointerTable
instead.* The specific issue is this: the allocation in lighttpd's
buffer_init
is 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 containsLTy
s. We'd like to track variables from all functions in one bigVarTable
, so that we can unify variables that originated in different functions. However,LTy
s may contain localPointerId
s, so a sharedVarTable
could mix up localPointerId
s from different functions/namespaces, producing nonsensical results. The fix being applied here is to put allPointerId
s 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.