summaryrefslogtreecommitdiff
path: root/include/llvm/Metadata.h
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-12-18 20:09:14 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-12-18 20:09:14 +0000
commit5d3016215075c52766711e741ce5401ee891d4ac (patch)
treebde7ea2658c9ec0f555730d5fe4a65b9f2f04a81 /include/llvm/Metadata.h
parent1edcafe10f05ba17dd1fbf36713fb40f98eca03a (diff)
downloadllvm-5d3016215075c52766711e741ce5401ee891d4ac.tar.gz
llvm-5d3016215075c52766711e741ce5401ee891d4ac.tar.bz2
llvm-5d3016215075c52766711e741ce5401ee891d4ac.tar.xz
Formalize MDNode's function-localness:
- an MDNode is designated as function-local when created, and continues to be even if its operands are modified not to refer to function-local IR - function-localness is designated via lowest bit in SubclassData - getLocalFunction() descends MDNode tree to see if it is consistently function-local Add verification of MDNodes to checks that MDNodes are consistently function-local. Update AsmWriter to use isFunctionLocal(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91708 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Metadata.h')
-rw-r--r--include/llvm/Metadata.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h
index 32c7fad203..fd8ea0c13b 100644
--- a/include/llvm/Metadata.h
+++ b/include/llvm/Metadata.h
@@ -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"
@@ -106,21 +107,22 @@ 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);
ElementVH *Node;
unsigned NodeSize;
- Function *LocalFunction;
protected:
explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
- Function *LocalFunc = NULL);
+ bool isFunctionLocal);
public:
// Constructors and destructors.
- static MDNode *get(LLVMContext &Context,
- Value *const *Vals, unsigned NumVals,
- Function *LocalFunction = NULL);
+ static MDNode *get(LLVMContext &Context, Value *const *Vals, unsigned NumVals,
+ bool isFunctionLocal = false);
/// ~MDNode - Destroy MDNode.
~MDNode();
@@ -135,7 +137,17 @@ public:
unsigned getNumElements() const { return NodeSize; }
/// isFunctionLocal - Return whether MDNode is local to a function.
- bool isFunctionLocal() const { return LocalFunction; }
+ /// 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