Skip to content

Commit 8e3a21e

Browse files
committed
[CGObjC] Use llvm::isKnownNonZero to determine if receiver can be null.
Signed-off-by: Peter Rong <[email protected]>
1 parent ea85900 commit 8e3a21e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clang/lib/CodeGen/CGObjCRuntime.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "clang/AST/StmtObjC.h"
2323
#include "clang/CodeGen/CGFunctionInfo.h"
2424
#include "clang/CodeGen/CodeGenABITypes.h"
25+
#include "llvm/Analysis/ValueTracking.h"
2526
#include "llvm/IR/Instruction.h"
2627
#include "llvm/Support/SaveAndRestore.h"
2728

@@ -413,8 +414,8 @@ bool CGObjCRuntime::canMessageReceiverBeNull(CodeGenFunction &CGF,
413414
}
414415
}
415416

416-
// Otherwise, assume it can be null.
417-
return true;
417+
// Otherwise, try to prove if it can be null.
418+
return !llvm::isKnownNonZero(receiver, CGM.getDataLayout());
418419
}
419420

420421
bool CGObjCRuntime::isWeakLinkedClass(const ObjCInterfaceDecl *ID) {

0 commit comments

Comments
 (0)