[LLVMdev] BasicAliasAnalysis: constant does not alias with noalias parameter
Hans Wennborg
hans at hanshq.net
Wed Nov 4 06:43:18 PST 2009
Here is another change I'd like to suggest to the BasicAliasAnalysis.
LLVM fails to remove the dead store in the following code:
%t = type { i32 }
define void @f(%t* noalias nocapture %stuff ) {
%p = getelementptr inbounds %t* %stuff, i32 0, i32 0
store i32 1, i32* %p; <-- This store is dead
%x = load i32* inttoptr (i32 12345 to i32*)
store i32 %x, i32* %p
ret void
}
when run through
./llvm-as -o - test2.ll | ./opt -O3 -o - | ./llvm-dis -o -
The problem is that the alias analysis is unsure about whether %p and
12345 may alias. But since %p is derived from %stuff, which has the
noalias attribute, and 12345 is a constant and therefore cannot be
derived from %stuff, they cannot alias.
I'm attaching a patch which implements this. Please comment on whether
this is sane, and if my code is the right way of doing it.
/ Hans
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BasicAliasAnalysis.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091104/33e67b8a/attachment.bin>
More information about the llvm-dev
mailing list