mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
Introduce a 'nonnull' metadata on Load instructions.
The newly introduced 'nonnull' metadata is analogous to existing 'nonnull' attributes, but applies to load instructions rather than call arguments or returns. Long term, it would be nice to combine these into a single construct. The value of the load is allowed to vary between successive loads, but null is not a valid value to be loaded by any load marked nonnull. Reviewed by: Hal Finkel Differential Revision: http://reviews.llvm.org/D5220 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220240 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -2622,6 +2622,10 @@ bool llvm::isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI) {
|
||||
if (const GlobalValue *GV = dyn_cast<GlobalValue>(V))
|
||||
return !GV->hasExternalWeakLinkage();
|
||||
|
||||
// A Load tagged w/nonnull metadata is never null.
|
||||
if (const LoadInst *LI = dyn_cast<LoadInst>(V))
|
||||
return LI->getMetadata("nonnull");
|
||||
|
||||
if (ImmutableCallSite CS = V)
|
||||
if (CS.isReturnNonNull())
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user