Vikram S. Adve wrote:> On Feb 22, 2007, at 10:21 AM, Robert L. Bocchino Jr. wrote: > > >>I glanced at the code again, and it looks like I use DSA to (1) >>construct the call graph and (2) identify things that would be >>unsafe to put on the stack, such as arrays, cyclic data structures, >>and allocations with escaping references. Right now these parts >>are pretty heavily dependent on DSA -- e.g., they make explicit use >>of the various DSA graphs. I'm sure you could modify the code to >>use AliasAnalysis instead of DSA, but I'm not sure what would be >>involved in that. > > Unfortunately, I don't think the AliasAnalysis interface gives a way > to check whether allocations escape a function. In DSA, you can do > this because there is an explicit points-to graph: you can find all > objects escaping "upwards" from a function by traversing the graph, > starting at globals, formal arguments, and return values.I think you could use "getModRefInfo(CallSite, Value *, unsigned)". "getModRefInfo (for call sites) - Return whether information about whether a particular call site modifies or reads the memory specified by the pointer." If I read that right, it can only return no modify when the called function and its callees never modify the pointer; BasicAA will check whether the target is a pure function. Whether the implementation is efficient or accurate is another matter. Nick Lewycky
On Feb 22, 2007, at 1:54 PM, Nick Lewycky wrote:> Vikram S. Adve wrote: >> On Feb 22, 2007, at 10:21 AM, Robert L. Bocchino Jr. wrote: >> >> >>> I glanced at the code again, and it looks like I use DSA to (1) >>> construct the call graph and (2) identify things that would be >>> unsafe to put on the stack, such as arrays, cyclic data structures, >>> and allocations with escaping references. Right now these parts >>> are pretty heavily dependent on DSA -- e.g., they make explicit use >>> of the various DSA graphs. I'm sure you could modify the code to >>> use AliasAnalysis instead of DSA, but I'm not sure what would be >>> involved in that. >> >> Unfortunately, I don't think the AliasAnalysis interface gives a way >> to check whether allocations escape a function. In DSA, you can do >> this because there is an explicit points-to graph: you can find all >> objects escaping "upwards" from a function by traversing the graph, >> starting at globals, formal arguments, and return values. > > I think you could use "getModRefInfo(CallSite, Value *, unsigned)".I may be missing your point, but that doesn't tell you if an object allocated *within* a function escapes the function.> > "getModRefInfo (for call sites) - Return whether information about > whether a particular call site modifies or reads the memory > specified by > the pointer." > > If I read that right, it can only return no modify when the called > function and its callees never modify the pointer; BasicAA will check > whether the target is a pure function. > > Whether the implementation is efficient or accurate is another matter. > > Nick Lewycky >--Vikram
Vikram S. Adve wrote:> On Feb 22, 2007, at 1:54 PM, Nick Lewycky wrote: > >>I think you could use "getModRefInfo(CallSite, Value *, unsigned)". > > I may be missing your point, but that doesn't tell you if an object > allocated *within* a function escapes the function.No, I missed your point. I thought you could look at the allocations within a function then use that method on all calls involving that alloca as an argument, but that doesn't do what I wanted. I have some hope for getModRefBehavior which returns a container of PointerAccessInfo, but I haven't yet decided if that actually does what I mean either. Worst case, the optz'n just falls back to degraded behaviour without DSA. Nick Lewycky