[InstCombine] Propagate non-null facts to call parameters
[oota-llvm.git] / test / Transforms / InstCombine / nonnull-param.ll
1 ; RUN: opt -S -instcombine < %s | FileCheck %s
2
3 declare void @callee(i8* %arg)
4
5 ; Positive test - arg is known non null
6 define void @test(i8* nonnull %arg) {
7 ; CHECK-LABEL: @test
8 ; CHECK: call void @callee(i8* nonnull %arg)
9   call void @callee(i8* %arg)
10   ret void
11 }
12
13
14 ; Negative test - arg is not known to be non null
15 define void @test2(i8* %arg) {
16 ; CHECK-LABEL: @test2
17 ; CHECK: call void @callee(i8* %arg)
18   call void @callee(i8* %arg)
19   ret void
20 }
21
22 declare void @callee2(i8*, i8*, i8*)
23
24 ; Sanity check arg indexing
25 define void @test3(i8* %arg1, i8* nonnull %arg2, i8* %arg3) {
26 ; CHECK-LABEL: @test3
27 ; CHECK: call void @callee2(i8* %arg1, i8* nonnull %arg2, i8* %arg3)
28   call void @callee2(i8* %arg1, i8* %arg2, i8* %arg3)
29   ret void
30 }
31
32 ; Because of the way CallSite::paramHasAttribute looks at the callee 
33 ; directly, we will not set the attribute on the CallSite.  That's 
34 ; fine as long as all consumers use the same check. 
35 define void @test4(i8* nonnull %arg) {
36 ; CHECK-LABEL: @test4
37 ; CHECK: call void @test4(i8* %arg)
38   call void @test4(i8* %arg)
39   ret void
40 }
41
42