1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 13:11:39 +01:00
llvm-mirror/test/Transforms/InstSimplify/null-ptr-is-valid-attribute.ll
Matt Arsenault bd9b22ee76 ValueTracking: Fix isKnownNonZero for non-0 null pointers for byval
The IR doesn't have a proper concept of invalid pointers, and "null"
constants are just all zeros (though it really needs one).

I think it's not possible to break this for AMDGPU due to the copy
semantics of byval. If you have an original stack object at 0, the
byval copy will be placed above it so I don't think it's really
possible to hit a 0 address.
2020-07-16 13:50:49 -04:00

21 lines
611 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instsimplify < %s | FileCheck %s
; A 0 valued byval pointer may be valid
define i1 @byval_may_be_zero(i32* byval(i32) %ptr) null_pointer_is_valid {
; CHECK-LABEL: @byval_may_be_zero(
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[PTR:%.*]], null
; CHECK-NEXT: ret i1 [[CMP]]
;
%cmp = icmp eq i32* %ptr, null
ret i1 %cmp
}
define i1 @nonnull_may_be_zero(i32* nonnull %ptr) null_pointer_is_valid {
; CHECK-LABEL: @nonnull_may_be_zero(
; CHECK-NEXT: ret i1 false
;
%cmp = icmp eq i32* %ptr, null
ret i1 %cmp
}