llvm.org GIT mirror llvm / ab9cf12
make memdep use the getModRefInfo method for stores instead of the low-level alias() method, allowing it to reason more aggressively about pointers into constant memory. PR4189 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72403 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
2 changed file(s) with 22 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
201201 }
202202
203203 if (StoreInst *SI = dyn_cast(Inst)) {
204 // If alias analysis can tell that this store is guaranteed to not modify
205 // the query pointer, ignore it. Use getModRefInfo to handle cases where
206 // the query pointer points to constant memory etc.
207 if (AA->getModRefInfo(SI, MemPtr, MemSize) == AliasAnalysis::NoModRef)
208 continue;
209
210 // Ok, this store might clobber the query pointer. Check to see if it is
211 // a must alias: in this case, we want to return this as a def.
204212 Value *Pointer = SI->getPointerOperand();
205213 uint64_t PointerSize = TD->getTypeStoreSize(SI->getOperand(0)->getType());
206
214
207215 // If we found a pointer, check if it could be the same as our pointer.
208216 AliasAnalysis::AliasResult R =
209217 AA->alias(Pointer, PointerSize, MemPtr, MemSize);
0 ; RUN: llvm-as < %s | opt -gvn -instcombine | llvm-dis | grep {ret i32 0}
1 ; PR4189
2 @G = external constant [4 x i32]
3
4 define i32 @test(i8* %p, i32 %i) nounwind {
5 entry:
6 %P = getelementptr [4 x i32]* @G, i32 0, i32 %i
7 %A = load i32* %P
8 store i8 4, i8* %p
9 %B = load i32* %P
10 %C = sub i32 %A, %B
11 ret i32 %C
12 }