[llvm-commits] [llvm] r57342 - in /llvm/trunk: include/llvm/Analysis/EscapeAnalysis.h lib/Analysis/EscapeAnalysis.cpp

Duncan Sands baldrick at free.fr
Sun Oct 12 00:09:33 PDT 2008


Hi Owen,

> if M is a malloced pointer, this would cause M to escape:
> 
> if (M & 1)
>   bits[0]=1;
> if (M & 2)
>   bits[1]=1;
> if (M & 4)
>   bits[2]=1;
> ...
> 
> Export the "bits" array somehow (eg: write to a global,
> a parameter, return it).  Then other parts of the program
> can reconstruct M from bits, so it would be wrong to
> convert it to an alloca.

this also applies to AllocaInst: suppose bits is a global
array, and A is an alloca.

if (A & 1)
  bits[0]=1;
...
call_someone_that_reconstructs_A_from_bits

In fact it seems to me that you might as well treat the
general case as well as allocation instructions, since
there's not going to be much difference.  By the general
case I mean an arbitrary value (maybe restricted to being
of pointer type - though that doesn't seem relevant), or
at least pointer parameters.  Then your escape analysis
could be used for calculating nocapture function attributes
too.

Ciao,

Duncan.



More information about the llvm-commits mailing list