[PATCH] D12772: [InstCombineCalls] Use isKnownNonNullAt() to check nullness of gc.relocate return value
Chen Li via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 15:36:58 PDT 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247353: [InstCombineCalls] Use isKnownNonNullAt() to check nullness of gc.relocate… (authored by chenli).
Changed prior to commit:
http://reviews.llvm.org/D12772?vs=34485&id=34501#toc
Repository:
rL LLVM
http://reviews.llvm.org/D12772
Files:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/trunk/test/Transforms/InstCombine/gc.relocate.ll
Index: llvm/trunk/test/Transforms/InstCombine/gc.relocate.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/gc.relocate.ll
+++ llvm/trunk/test/Transforms/InstCombine/gc.relocate.ll
@@ -19,3 +19,34 @@
%relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %tok, i32 7, i32 7)
ret i32 addrspace(1)* %relocate
}
+
+define i32 @explicit_nonnull(i32 addrspace(1)* nonnull %dparam) gc "statepoint-example" {
+; Checks that a nonnull pointer
+; CHECK-LABEL: @explicit_nonnull
+; CHECK: ret i32 1
+entry:
+ %load = load i32, i32 addrspace(1)* %dparam
+ %tok = tail call i32 (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, i32 addrspace(1)* %dparam)
+ %relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %tok, i32 7, i32 7)
+ %cmp = icmp eq i32 addrspace(1)* %relocate, null
+ %ret_val = select i1 %cmp, i32 0, i32 1
+ ret i32 %ret_val
+}
+
+define i32 @implicit_nonnull(i32 addrspace(1)* %dparam) gc "statepoint-example" {
+; Checks that a nonnull pointer
+; CHECK-LABEL: @implicit_nonnull
+; CHECK: ret i32 1
+entry:
+ %cond = icmp eq i32 addrspace(1)* %dparam, null
+ br i1 %cond, label %no_gc, label %gc
+gc:
+ %load = load i32, i32 addrspace(1)* %dparam
+ %tok = tail call i32 (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, i32 addrspace(1)* %dparam)
+ %relocate = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %tok, i32 7, i32 7)
+ %cmp = icmp eq i32 addrspace(1)* %relocate, null
+ %ret_val = select i1 %cmp, i32 0, i32 1
+ ret i32 %ret_val
+no_gc:
+ unreachable
+}
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1367,7 +1367,7 @@
}
// isKnownNonNull -> nonnull attribute
- if (isKnownNonNull(DerivedPtr))
+ if (isKnownNonNullAt(DerivedPtr, II, DT, TLI))
II->addAttribute(AttributeSet::ReturnIndex, Attribute::NonNull);
// isDereferenceablePointer -> deref attribute
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12772.34501.patch
Type: text/x-patch
Size: 2377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150910/0e2e1dcb/attachment.bin>
More information about the llvm-commits
mailing list