isDereferenceablePointer: look through gc.relocate calls
[oota-llvm.git] / test / Analysis / ValueTracking / memory-dereferenceable.ll
1 ; RUN: opt -print-memderefs -analyze -S <%s | FileCheck %s
2
3 ; Uses the print-deref (+ analyze to print) pass to run
4 ; isDereferenceablePointer() on many load instruction operands
5
6 declare zeroext i1 @return_i1()
7
8 @globalstr = global [6 x i8] c"hello\00"
9
10 define void @test(i32 addrspace(1)* byval %dparam) {
11 ; CHECK: The following are dereferenceable:
12 ; CHECK: %globalptr
13 ; CHECK: %alloca
14 ; CHECK: %dparam
15 ; CHECK: %relocate
16 ; CHECK-NOT: %nparam
17 entry:
18     %globalptr = getelementptr inbounds [6 x i8]* @globalstr, i32 0, i32 0
19     %load1 = load i8* %globalptr
20     %alloca = alloca i1
21     %load2 = load i1* %alloca
22     %load3 = load i32 addrspace(1)* %dparam
23     %tok = tail call i32 (i1 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 addrspace(1)* %dparam)
24     %relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %tok, i32 4, i32 4)
25     %load4 = load i32 addrspace(1)* %relocate
26     %nparam = getelementptr i32 addrspace(1)* %dparam, i32 5
27     %load5 = load i32 addrspace(1)* %nparam
28     ret void
29 }
30
31 declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...)
32 declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32)