[InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing arguments...
[oota-llvm.git] / test / Transforms / InstCombine / call_nonnull_arg.ll
diff --git a/test/Transforms/InstCombine/call_nonnull_arg.ll b/test/Transforms/InstCombine/call_nonnull_arg.ll
new file mode 100644 (file)
index 0000000..cac53d3
--- /dev/null
@@ -0,0 +1,17 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; InstCombine should mark null-checked argument as nonnull at callsite
+declare void @dummy(i32*)
+
+define void @test(i32* %a) {
+; CHECK-LABEL: @test
+; CHECK: call void @dummy(i32* nonnull %a)
+entry:
+  %cond = icmp eq i32* %a, null
+  br i1 %cond, label %is_null, label %not_null
+not_null:
+  call void @dummy(i32* %a)
+  ret void
+is_null:
+  unreachable
+}