mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-15 16:09:57 +00:00
ecc1d153b7
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. It also adds assertions in isKnownNonNull() and isKnownNonNullFromDominatingCondition() to make sure the value checked is pointer type (as defined in LLVM document). These assertions might trip failures in things which are not covered under llvm/test, but fixes should be pretty obvious. Reviewers: reames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12779 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247587 91177308-0d34-0410-b5e6-96231b3b80d8
21 lines
508 B
LLVM
21 lines
508 B
LLVM
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
; InstCombine should mark null-checked argument as nonnull at callsite
|
|
declare void @dummy(i32*, i32)
|
|
|
|
define void @test(i32* %a, i32 %b) {
|
|
; CHECK-LABEL: @test
|
|
; CHECK: call void @dummy(i32* nonnull %a, i32 %b)
|
|
entry:
|
|
%cond1 = icmp eq i32* %a, null
|
|
br i1 %cond1, label %dead, label %not_null
|
|
not_null:
|
|
%cond2 = icmp eq i32 %b, 0
|
|
br i1 %cond2, label %dead, label %not_zero
|
|
not_zero:
|
|
call void @dummy(i32* %a, i32 %b)
|
|
ret void
|
|
dead:
|
|
unreachable
|
|
}
|