[LLVMdev] DeadStoreElimination: do better without TargetData

Kenneth Uildriks kennethuil at gmail.com
Wed Nov 4 11:36:03 PST 2009


On Wed, Nov 4, 2009 at 12:13 PM, Hans Wennborg <hans at hanshq.net> 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
> }
>
> When run through ./llvm-as test.ll -o - | ./opt -O3 -S
> the dead store is not removed by the DSE pass.
> (The call to @foo is there to prevent InstCombine from folding the store
> instructions into one.)
>
> This is because DSE relies on TargetData to find out about pointer
> sizes. Apparently, there was some default value for this before, but
> when running with top of the tree today, it turned out that TD=NULL in
> the DSE code.

Yes, there was a default value before - a single default value for all
targets.  On most targets, it was wrong, and led to the optimizer
breaking code unless the module had the host's target data string
packaged up inside of it.

>
> We discussed this in the IRC channel, and someone pointed out that the
> more the pass can do without having info about the target, the better --
>  hence the patch.

My feeling exactly.

>
> With the patch, DSE will at least see if the data types are equal, even
> though it doesn't have information about their sizes. This is enough for
> handling the example above, and probably many others as well.

Thanks.




More information about the llvm-dev mailing list