[InferFuncAttributes][Attributor] add tests for 'dereferenceable'; NFC

Pulling a couple of extra tests out of
D64258
before abandoning in favor of
D70714
This commit is contained in:
Sanjay Patel 2019-11-26 09:07:17 -05:00
parent 16144d2b21
commit 2bd252ea89
1 changed files with 28 additions and 0 deletions

View File

@ -161,6 +161,19 @@ define void @volatile_is_not_dereferenceable(i16* %ptr) {
ret void
}
; TODO: We should allow inference for atomic (but not volatile) ops.
define void @atomic_is_alright(i16* %ptr) {
; CHECK-LABEL: @atomic_is_alright(i16* %ptr)
%arrayidx0 = getelementptr i16, i16* %ptr, i64 0
%arrayidx1 = getelementptr i16, i16* %ptr, i64 1
%arrayidx2 = getelementptr i16, i16* %ptr, i64 2
%t0 = load atomic i16, i16* %arrayidx0 unordered, align 2
%t1 = load i16, i16* %arrayidx1
%t2 = load i16, i16* %arrayidx2
ret void
}
declare void @may_not_return()
define void @not_guaranteed_to_transfer_execution(i16* %ptr) {
@ -244,6 +257,21 @@ define void @more_bytes(i32* dereferenceable(8) %ptr) {
ret void
}
; Improve on existing dereferenceable_or_null attribute.
define void @more_bytes_and_not_null(i32* dereferenceable_or_null(8) %ptr) {
; CHECK-LABEL: @more_bytes_and_not_null(i32* dereferenceable_or_null(8) %ptr)
%arrayidx3 = getelementptr i32, i32* %ptr, i64 3
%arrayidx1 = getelementptr i32, i32* %ptr, i64 1
%arrayidx0 = getelementptr i32, i32* %ptr, i64 0
%arrayidx2 = getelementptr i32, i32* %ptr, i64 2
%t3 = load i32, i32* %arrayidx3
%t1 = load i32, i32* %arrayidx1
%t2 = load i32, i32* %arrayidx2
%t0 = load i32, i32* %arrayidx0
ret void
}
; But don't pessimize existing dereferenceable attribute.
define void @better_bytes(i32* dereferenceable(100) %ptr) {