1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing arguments at callsite

Summary: This patch replaces isKnownNonNull() with isKnownNonNullAt() when checking nullness of passing arguments at callsite. In this way it can handle cases where the argument does not have nonnull attribute but has a dominating null check from the CFG.

Reviewers: reames

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D12779

llvm-svn: 247356
This commit is contained in:
Chen Li 2015-09-10 23:04:49 +00:00
parent 8668b7de3c
commit b3a586f07f
2 changed files with 18 additions and 1 deletions

View File

@ -1537,7 +1537,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
unsigned ArgNo = 0;
for (Value *V : CS.args()) {
if (!CS.paramHasAttr(ArgNo+1, Attribute::NonNull) &&
isKnownNonNull(V)) {
isKnownNonNullAt(V, CS.getInstruction(), DT, TLI)) {
AttributeSet AS = CS.getAttributes();
AS = AS.addAttribute(CS.getInstruction()->getContext(), ArgNo+1,
Attribute::NonNull);

View File

@ -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
}