Robert L. Bocchino Jr.
2007-Feb-22 16:21 UTC
[LLVMdev] Unused malloc/free don't get optimized
> Sounds good! I'd like to see the code, even though I can't promise > that > I'll do anything with it in the near term.OK. I've sent you the code in a separate email.> I'd rather not depend on DSA in particular. If it could depend on > AliasAnalysis then it would grow stronger or weaker depending on what > aliasing analysis was loaded at the time. Are there any special > features > of DSA that you're using?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. Rob Robert L. Bocchino Jr. Ph.D. Student University of Illinois, Urbana-Champaign -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070222/9cf515e8/attachment.html>
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. --Vikram
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