[llvm-commits] metadata type

Frits van Bommel fvbommel at wxs.nl
Sat May 23 12:52:48 PDT 2009


Nick Lewycky wrote:
> This patch switches metadata away from using "{ }" type to its own new 
> "metadata" type. As a side-effect this patch makes PHI nodes on {} legal 
> again, similarly with %x = load {}* resulting in {}, etc.
> 
> Please review!

--- docs/LangRef.html	(revision 72315)
+++ docs/LangRef.html	(working copy)
@@ -2046,8 +2063,8 @@

  <p>Embedded metadata provides a way to attach arbitrary data to the
  instruction stream without affecting the behaviour of the program.  There are
-two metadata primitives, strings and nodes. All metadata has the type of an
-empty struct and is identified in syntax by a preceding exclamation point
+two metadata primitives, strings and nodes. All metadata has the
+<tt>metadata</tt> and is identified in syntax by a preceding exclamation point
  ('<tt>!</tt>').

You probably meant "All metadata has the metadata *type*"



--- include/llvm/Constants.h	(revision 72315)
+++ include/llvm/Constants.h	(working copy)
@@ -863,7 +863,7 @@
    /// getType() specialization - Type is always an empty struct.
    ///
    inline const Type *getType() const {
-    return Type::EmptyStructTy;
+    return Type::MetadataTy;
    }

The comment should also be updated. (The same applies for MDNode::getType() in 
MDNode.h)



--- include/llvm/Bitcode/LLVMBitCodes.h	(revision 72315)
+++ include/llvm/Bitcode/LLVMBitCodes.h	(working copy)
@@ -78,6 +78,7 @@
      TYPE_CODE_DOUBLE   =  4,   // DOUBLE
      TYPE_CODE_LABEL    =  5,   // LABEL
      TYPE_CODE_OPAQUE   =  6,   // OPAQUE
+    TYPE_CODE_METADATA = 16,   // METADATA

This should probably be at the bottom, like the bigger floating-point types. (To 
keep the numbers in-order)



--- lib/VMCore/Verifier.cpp	(revision 72315)
+++ lib/VMCore/Verifier.cpp	(working copy)
@@ -1052,6 +1035,16 @@
                " cannot be used for vararg call arguments!", I);
      }

+  // Verify that there's no metadata unless it's a direct call to an intrinsic.
+  if (!CS.getCalledFunction() || CS.getCalledFunction()->getName().size() < 5 ||
+      CS.getCalledFunction()->getName().substr(0, 5) != "llvm.") {
+    Assert1(FTy->getReturnType(), "Only intrinsics may return metadata", I);

Don't you actually want to *check* whether it's metadata? :)



More information about the llvm-commits mailing list