1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
David Bolvansky 4d7d2beaf1 [SimplifyLibCalls] Mark known arguments with nonnull
Reviewers: efriedma, jdoerfert

Reviewed By: jdoerfert

Subscribers: ychen, rsmith, joerg, aaron.ballman, lebedev.ri, uenoku, jdoerfert, hfinkel, javed.absar, spatel, dmgreen, llvm-commits

Differential Revision: https://reviews.llvm.org/D53342

llvm-svn: 372091
2019-09-17 09:32:52 +00:00

56 lines
1.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
declare i8* @memrchr(i8*, i32, i32)
define i8* @test1(i8* %str, i32 %c, i32 %n) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 %n)
ret i8* %ret
}
define i8* @test2(i8* %str, i32 %c, i32 %n) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* nonnull [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* nonnull %str, i32 %c, i32 %n)
ret i8* %ret
}
define i8* @test3(i8* %str, i32 %c) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 5)
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 5)
ret i8* %ret
}
define i8* @test4(i8* %str, i32 %c) "null-pointer-is-valid"="true" {
; CHECK-LABEL: @test4(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 5)
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 5)
ret i8* %ret
}
define i8* @test5(i8* %str, i32 %c) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 0)
; CHECK-NEXT: ret i8* [[RET]]
;
%ret = call i8* @memrchr(i8* %str, i32 %c, i32 0)
ret i8* %ret
}