Make some methods const. The only interesting change here is that
[oota-llvm.git] / include / llvm / Metadata.h
index 1d18eba32be1bb81e53835b1a1ca4ac97cf404ca..fd8ea0c13b2c0044d1ce5a1b49a2a7753e548fdd 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/Value.h"
 #include "llvm/Type.h"
 #include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/ilist_node.h"
 #include "llvm/Support/ValueHandle.h"
@@ -91,7 +92,7 @@ class MDNode : public MetadataBase, public FoldingSetNode {
   MDNode(const MDNode &);                // DO NOT IMPLEMENT
 
   friend class ElementVH;
-  // Use CallbackVH to hold MDNOde elements.
+  // Use CallbackVH to hold MDNode elements.
   struct ElementVH : public CallbackVH {
     MDNode *Parent;
     ElementVH() {}
@@ -106,6 +107,9 @@ class MDNode : public MetadataBase, public FoldingSetNode {
       Parent->replaceElement(this->operator Value*(), NV);
     }
   };
+  
+  static const unsigned short FunctionLocalBit = 1;
+  
   // Replace each instance of F from the element list of this node with T.
   void replaceElement(Value *F, Value *T);
 
@@ -113,11 +117,12 @@ class MDNode : public MetadataBase, public FoldingSetNode {
   unsigned NodeSize;
 
 protected:
-  explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals);
+  explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
+                  bool isFunctionLocal);
 public:
   // Constructors and destructors.
-  static MDNode *get(LLVMContext &Context, 
-                     Value *const *Vals, unsigned NumVals);
+  static MDNode *get(LLVMContext &Context, Value *const *Vals, unsigned NumVals,
+                     bool isFunctionLocal = false);
 
   /// ~MDNode - Destroy MDNode.
   ~MDNode();
@@ -130,6 +135,19 @@ public:
 
   /// getNumElements - Return number of MDNode elements.
   unsigned getNumElements() const { return NodeSize; }
+  
+  /// isFunctionLocal - Return whether MDNode is local to a function.
+  /// Note: MDNodes are designated as function-local when created, and keep
+  ///       that designation even if their operands are modified to no longer
+  ///       refer to function-local IR.
+  bool isFunctionLocal() const { return SubclassData & FunctionLocalBit; }
+
+  /// getLocalFunction - Return false if MDNode's recursive function-localness
+  /// is invalid (local to more than one function).  Return true otherwise.
+  /// If MDNode has one function to which it is local, set LocalFunction to that
+  /// function.
+  bool getLocalFunction(Function *LocalFunction,
+                        SmallPtrSet<MDNode *, 32> *VisitedMDNodes = NULL);
 
   /// Profile - calculate a unique identifier for this MDNode to collapse
   /// duplicates
@@ -264,7 +282,7 @@ public:
   /// the same metadata to In2.
   void copyMD(Instruction *In1, Instruction *In2);
 
-  /// getHandlerNames - Populate client supplied smallvector using custome
+  /// getHandlerNames - Populate client supplied smallvector using custom
   /// metadata name and ID.
   void getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&) const;