mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
Teach isKnownNonNull that a nonnull return is not null. Add a test for this case as well as the case of a nonnull attribute (already handled but not tested).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209193 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Analysis/InstructionSimplify.h"
|
||||
#include "llvm/Analysis/MemoryBuiltins.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/ConstantRange.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
@@ -2073,6 +2074,10 @@ bool llvm::isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI) {
|
||||
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V))
|
||||
return !GV->hasExternalWeakLinkage();
|
||||
|
||||
if (ImmutableCallSite CS = V)
|
||||
if (CS.paramHasAttr(0, Attribute::NonNull))
|
||||
return true;
|
||||
|
||||
// operator new never returns null.
|
||||
if (isOperatorNewLikeFn(V, TLI, /*LookThroughBitCast=*/true))
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user