[LLVMdev] DeadStoreElimination: do better without TargetData

Nick Lewycky nicholas at mxc.ca
Thu Nov 5 00:44:36 PST 2009


Hans Wennborg wrote:
> Sorry, I admit my e-mail was a bit unclear.
> Here is an example:
> 
> declare void @foo()
> 
> define void @f(i32* noalias %p) {
>          store i32 1, i32* %p; <-- This is dead
>          call void @foo()
>          store i32 2, i32 *%p
>          ret void
> }

Hold up. Is this correct?

"noalias: This indicates that the pointer does not alias any global or 
any other parameter. The caller is responsible for ensuring that this is 
the case." - LangRef

I've been interpreting this to mean that an arbitrary function may 
modify %p in this example, so long as it isn't *directly* held by a 
global or another argument. However, the global could contain a pointer 
to an object, indirectly pointing to %p.

This would allow us to get more 'noalias' results from within @foo 
itself, but we not this optimization around it. I believe it's 
compatible with the definition of 'restrict' in C which noalias is 
modelled on.

According to my interpretation, if the TD was the only issue blocking 
this transform then DSE was already buggy.

Chris, could you please confirm your intention here?

Nick



More information about the llvm-dev mailing list