[LLVMdev] Unused malloc/free don't get optimized
Vikram S. Adve
vadve at uiuc.edu
Thu Feb 22 13:23:06 PST 2007
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
More information about the llvm-dev