From 981c81199d55ad37c3edb5503206348689fad1ed Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sat, 31 Dec 2016 19:23:26 +0000 Subject: [PATCH] [ValueTracking] add tests for known-nonnull-at; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290790 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../ValueTracking/known-nonnull-at.ll | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/Analysis/ValueTracking/known-nonnull-at.ll diff --git a/test/Analysis/ValueTracking/known-nonnull-at.ll b/test/Analysis/ValueTracking/known-nonnull-at.ll new file mode 100644 index 00000000000..8a0d1f3aff3 --- /dev/null +++ b/test/Analysis/ValueTracking/known-nonnull-at.ll @@ -0,0 +1,57 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -S -instsimplify < %s | FileCheck %s + +declare void @bar(i8* %a, i8* nonnull %b) + +; 'y' must be nonnull. + +define i1 @caller1(i8* %x, i8* %y) { +; CHECK-LABEL: @caller1( +; CHECK-NEXT: call void @bar(i8* %x, i8* %y) +; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp eq i8* %y, null +; CHECK-NEXT: ret i1 [[NULL_CHECK]] +; + call void @bar(i8* %x, i8* %y) + %null_check = icmp eq i8* %y, null + ret i1 %null_check +} + +; Don't know anything about 'y'. + +define i1 @caller2(i8* %x, i8* %y) { +; CHECK-LABEL: @caller2( +; CHECK-NEXT: call void @bar(i8* %y, i8* %x) +; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp eq i8* %y, null +; CHECK-NEXT: ret i1 [[NULL_CHECK]] +; + call void @bar(i8* %y, i8* %x) + %null_check = icmp eq i8* %y, null + ret i1 %null_check +} + +; 'y' must be nonnull. + +define i1 @caller3(i8* %x, i8* %y) { +; CHECK-LABEL: @caller3( +; CHECK-NEXT: call void @bar(i8* %x, i8* %y) +; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp ne i8* %y, null +; CHECK-NEXT: ret i1 [[NULL_CHECK]] +; + call void @bar(i8* %x, i8* %y) + %null_check = icmp ne i8* %y, null + ret i1 %null_check +} + +; Don't know anything about 'y'. + +define i1 @caller4(i8* %x, i8* %y) { +; CHECK-LABEL: @caller4( +; CHECK-NEXT: call void @bar(i8* %y, i8* %x) +; CHECK-NEXT: [[NULL_CHECK:%.*]] = icmp ne i8* %y, null +; CHECK-NEXT: ret i1 [[NULL_CHECK]] +; + call void @bar(i8* %y, i8* %x) + %null_check = icmp ne i8* %y, null + ret i1 %null_check +} + -- 2.49.0