[LLVMdev] Functions: sret and readnone

Duncan Sands baldrick at free.fr
Fri Nov 6 05:02:39 PST 2009


Hi Stephan,

>> In order to perform this transform the optimizers would have to work out
>> that sample does not modify any global state.  This cannot be done without
>> knowing the definition of sample, but you only provide a declaration.
> 
> Which is why I am trying to supply this additional information in a
> custom alias analysis pass, but it doesn't seem to work. (The
> AAEvalPass stats are precisely for this custom pass.)
> 
> Could you take a look at the code, please? Am I missing something
> here?

I think this cannot possibly work.  Imagine that I am a pass trying to
determine if the function call modifies global state.  What would I have
to do?  I would have to consider all global variables, and query alias
analysis to find out if any of them are modified.  But how can I know all
global variables?  There is no way to know about global variables that are
not declared in the module, so I can't query about those.  And even if I
could know about all global variables, checking all of them every time I
want to consider deleting a function call would be very expensive and not
worthwhile in general.  GlobalsModRef only considers global variables with
internal linkage IIRC (I may be wrong about this).  That said, maybe there
is some special AA query method that I don't know about that asks "do you
write any global state".

Ciao,

Duncan.



More information about the llvm-dev mailing list