summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2014-10-20 22:40:55 +0000
committerPhilip Reames <listmail@philipreames.com>2014-10-20 22:40:55 +0000
commitcdb72f369f94be40a4f2651ac36f65caa4034bb5 (patch)
treec0d199e2c7a0f1191df3d5d8d264f860296a6851 /llvm/test
parent2f9548a3efe4cd7268f2572710608bff1218393c (diff)
downloadbcm5719-llvm-cdb72f369f94be40a4f2651ac36f65caa4034bb5.tar.gz
bcm5719-llvm-cdb72f369f94be40a4f2651ac36f65caa4034bb5.zip
Introduce a 'nonnull' metadata on Load instructions.
The newly introduced 'nonnull' metadata is analogous to existing 'nonnull' attributes, but applies to load instructions rather than call arguments or returns. Long term, it would be nice to combine these into a single construct. The value of the load is allowed to vary between successive loads, but null is not a valid value to be loaded by any load marked nonnull. Reviewed by: Hal Finkel Differential Revision: http://reviews.llvm.org/D5220 llvm-svn: 220240
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/InstSimplify/compare.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll
index b30648301ae..38fd747172f 100644
--- a/llvm/test/Transforms/InstSimplify/compare.ll
+++ b/llvm/test/Transforms/InstSimplify/compare.ll
@@ -949,6 +949,29 @@ define i1 @returns_nonnull_as_deref() {
; CHECK: ret
}
+define i1 @nonnull_load(i32** %addr) {
+ %ptr = load i32** %addr, !nonnull !{}
+ %cmp = icmp eq i32* %ptr, null
+ ret i1 %cmp
+; CHECK-LABEL: @nonnull_load
+; CHECK: ret i1 false
+}
+
+define i1 @nonnull_load_as_outer(i32* addrspace(1)* %addr) {
+ %ptr = load i32* addrspace(1)* %addr, !nonnull !{}
+ %cmp = icmp eq i32* %ptr, null
+ ret i1 %cmp
+; CHECK-LABEL: @nonnull_load_as_outer
+; CHECK: ret i1 false
+}
+define i1 @nonnull_load_as_inner(i32 addrspace(1)** %addr) {
+ %ptr = load i32 addrspace(1)** %addr, !nonnull !{}
+ %cmp = icmp eq i32 addrspace(1)* %ptr, null
+ ret i1 %cmp
+; CHECK-LABEL: @nonnull_load_as_inner
+; CHECK: ret i1 false
+}
+
; If a bit is known to be zero for A and known to be one for B,
; then A and B cannot be equal.
define i1 @icmp_eq_const(i32 %a) nounwind {
OpenPOWER on IntegriCloud