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:
parent
8668b7de3c
commit
b3a586f07f
@ -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);
|
||||
|
17
test/Transforms/InstCombine/call_nonnull_arg.ll
Normal file
17
test/Transforms/InstCombine/call_nonnull_arg.ll
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user