[llvm] r220323 - Extend the verifier to check usage of 'nonnull' metadata.

Philip Reames listmail at philipreames.com
Tue Oct 21 13:56:29 PDT 2014


Author: reames
Date: Tue Oct 21 15:56:29 2014
New Revision: 220323

URL: http://llvm.org/viewvc/llvm-project?rev=220323&view=rev
Log:
Extend the verifier to check usage of 'nonnull' metadata.

The recently added !nonnull metadata is only valid on loads of pointer type.  


Modified:
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=220323&r1=220322&r2=220323&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Tue Oct 21 15:56:29 2014
@@ -2287,6 +2287,14 @@ void Verifier::visitInstruction(Instruct
     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);
 }
 





More information about the llvm-commits mailing list