diff options
author | Philip Reames <listmail@philipreames.com> | 2014-10-21 20:56:29 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2014-10-21 20:56:29 +0000 |
commit | 0ca58b33cf2888443688f3fcdaada2ddd2a9b944 (patch) | |
tree | 4668db529090b4bd2259d1dc2d5d8c490f765a1c /llvm/lib/IR/Verifier.cpp | |
parent | 622be238eb847fbb15b320028263668d17d7e21f (diff) | |
download | bcm5719-llvm-0ca58b33cf2888443688f3fcdaada2ddd2a9b944.tar.gz bcm5719-llvm-0ca58b33cf2888443688f3fcdaada2ddd2a9b944.zip |
Extend the verifier to check usage of 'nonnull' metadata.
The recently added !nonnull metadata is only valid on loads of pointer type.
llvm-svn: 220323
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 154d54870ef..3060baa52e2 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2287,6 +2287,14 @@ void Verifier::visitInstruction(Instruction &I) { visitRangeMetadata(I, Range, I.getType()); } + if (I.getMetadata(LLVMContext::MD_nonnull)) { + Assert1(I.getType()->isPointerTy(), + "nonnull applies only to pointer types", &I); + Assert1(isa<LoadInst>(I), + "nonnull applies only to load instructions, use attributes" + " for calls or invokes", &I); + } + InstsInThisBlock.insert(&I); } |