[LLVMdev] DeadStoreElimination: do better without TargetData
Chris Lattner
clattner at apple.com
Wed Nov 4 15:21:20 PST 2009
On Nov 4, 2009, at 10:13 AM, 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
> }
>
> 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.
>
> 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.
>
> 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, applied here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091102/090396.html
I'd appreciate it if you could resend your other patches in patch
format like this, attached to the email with the testcase using
filecheck. This commit should be a good example. Thanks for helping
improve this area!
-Chris
More information about the llvm-dev
mailing list