summaryrefslogtreecommitdiffstats
path: root/llvm/test/Analysis/ValueTracking
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2015-06-08 11:58:13 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2015-06-08 11:58:13 +0000
commit7fad7e57e8137a2e6c6d8c21fe92d436a053b2f1 (patch)
tree789235442663959cf2c82b6c3ea22066404f0c85 /llvm/test/Analysis/ValueTracking
parent1c5ad681d7be4192b9d9f88f2821d7f9cd258a63 (diff)
downloadbcm5719-llvm-7fad7e57e8137a2e6c6d8c21fe92d436a053b2f1.tar.gz
bcm5719-llvm-7fad7e57e8137a2e6c6d8c21fe92d436a053b2f1.zip
Minor refactoring of GEP handling in isDereferenceablePointer
For GEP instructions isDereferenceablePointer checks that all indices are constant and within bounds. Replace this index calculation logic to a call to accumulateConstantOffset. Separated from the http://reviews.llvm.org/D9791 Reviewed By: sanjoy Differential Revision: http://reviews.llvm.org/D9874 llvm-svn: 239299
Diffstat (limited to 'llvm/test/Analysis/ValueTracking')
-rw-r--r--llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll b/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
index dae64d7acc2..f49f4f77f40 100644
--- a/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
+++ b/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
@@ -10,6 +10,9 @@ declare zeroext i1 @return_i1()
@globalstr = global [6 x i8] c"hello\00"
@globali32ptr = external global i32*
+%struct.A = type { [8 x i8], [5 x i8] }
+@globalstruct = external global %struct.A
+
define void @test(i32 addrspace(1)* dereferenceable(8) %dparam) gc "statepoint-example" {
; CHECK: The following are dereferenceable:
; CHECK: %globalptr
@@ -22,6 +25,8 @@ define void @test(i32 addrspace(1)* dereferenceable(8) %dparam) gc "statepoint-e
; CHECK-NOT: %d2_load
; CHECK-NOT: %d_or_null_load
; CHECK: %d_or_null_non_null_load
+; CHECK: %within_allocation
+; CHECK-NOT: %outside_allocation
entry:
%globalptr = getelementptr inbounds [6 x i8], [6 x i8]* @globalstr, i32 0, i32 0
%load1 = load i8, i8* %globalptr
@@ -54,6 +59,14 @@ entry:
%d_or_null_non_null_load = load i32*, i32** @globali32ptr, !nonnull !2, !dereferenceable_or_null !0
%load10 = load i32, i32* %d_or_null_non_null_load
+ ; It's OK to overrun static array size as long as we stay within underlying object size
+ %within_allocation = getelementptr inbounds %struct.A, %struct.A* @globalstruct, i64 0, i32 0, i64 10
+ %load11 = load i8, i8* %within_allocation
+
+ ; GEP is outside the underlying object size
+ %outside_allocation = getelementptr inbounds %struct.A, %struct.A* @globalstruct, i64 0, i32 1, i64 10
+ %load12 = load i8, i8* %outside_allocation
+
ret void
}
OpenPOWER on IntegriCloud