[llvm-commits] [llvm] r92216 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp
Nick Lewycky
nicholas at mxc.ca
Mon Dec 28 01:26:35 PST 2009
Chris Lattner wrote:
> Author: lattner
> Date: Mon Dec 28 02:48:12 2009
> New Revision: 92216
>
> URL: http://llvm.org/viewvc/llvm-project?rev=92216&view=rev
> Log:
> rename MDNode instance variables to something meaningful.
>
Please name them Elements instead of Operands. There's a lot of great
invariants that apply to operands which don't exist on MDNode elements.
Nick
> Modified:
> llvm/trunk/include/llvm/Metadata.h
> llvm/trunk/lib/VMCore/Metadata.cpp
>
> Modified: llvm/trunk/include/llvm/Metadata.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=92216&r1=92215&r2=92216&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Metadata.h (original)
> +++ llvm/trunk/include/llvm/Metadata.h Mon Dec 28 02:48:12 2009
> @@ -99,8 +99,8 @@
> // Replace each instance of F from the element list of this node with T.
> void replaceElement(Value *F, Value *T);
>
> - MDNodeElement *Node;
> - unsigned NodeSize;
> + MDNodeElement *Operands;
> + unsigned NumOperands;
>
> protected:
> explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
> @@ -117,7 +117,7 @@
> Value *getElement(unsigned i) const;
>
> /// getNumElements - Return number of MDNode elements.
> - unsigned getNumElements() const { return NodeSize; }
> + unsigned getNumElements() const { return NumOperands; }
>
> /// isFunctionLocal - Return whether MDNode is local to a function.
> /// Note: MDNodes are designated as function-local when created, and keep
>
> Modified: llvm/trunk/lib/VMCore/Metadata.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=92216&r1=92215&r2=92216&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/VMCore/Metadata.cpp (original)
> +++ llvm/trunk/lib/VMCore/Metadata.cpp Mon Dec 28 02:48:12 2009
> @@ -87,11 +87,12 @@
> MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
> bool isFunctionLocal)
> : MetadataBase(Type::getMetadataTy(C), Value::MDNodeVal) {
> - NodeSize = NumVals;
> - Node = new MDNodeElement[NodeSize];
> - MDNodeElement *Ptr = Node;
> + NumOperands = NumVals;
> + Operands = new MDNodeElement[NumOperands];
> + MDNodeElement *Ptr = Operands;
> for (unsigned i = 0; i != NumVals; ++i)
> - *Ptr++ = MDNodeElement(Vals[i], this);
> + Ptr[i] = MDNodeElement(Vals[i], this);
> +
> if (isFunctionLocal)
> SubclassData |= FunctionLocalBit;
> }
> @@ -122,14 +123,14 @@
> MDNode::~MDNode() {
> LLVMContextImpl *pImpl = getType()->getContext().pImpl;
> pImpl->MDNodeSet.RemoveNode(this);
> - delete [] Node;
> - Node = NULL;
> + delete [] Operands;
> + Operands = NULL;
> }
>
> /// getElement - Return specified element.
> Value *MDNode::getElement(unsigned i) const {
> assert(i < getNumElements() && "Invalid element number!");
> - return Node[i];
> + return Operands[i];
> }
>
>
> @@ -161,8 +162,7 @@
> // Replace From element(s) in place.
> for (SmallVector<unsigned, 4>::iterator I = Indexes.begin(), E = Indexes.end();
> I != E; ++I) {
> - unsigned Index = *I;
> - Node[Index] = MDNodeElement(To, this);
> + Operands[*I] = MDNodeElement(To, this);
> }
>
> // Insert updated "this" into the context's folding node set.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list