From cb33799b9f4e152e3460faa83e59b53ff604c87d Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 10 May 2009 20:57:05 +0000 Subject: Make MDNode use CallbackVH. Also change MDNode to store Value* instead of Constant* in preperation of a future change to support holding non-Constants in an MDNode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71407 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Writer/BitcodeWriter.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 1937c7e26f..1ad70df054 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -19,6 +19,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/InlineAsm.h" #include "llvm/Instructions.h" +#include "llvm/MDNode.h" #include "llvm/Module.h" #include "llvm/TypeSymbolTable.h" #include "llvm/ValueSymbolTable.h" @@ -706,9 +707,14 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, } } else if (const MDNode *N = dyn_cast(C)) { Code = bitc::CST_CODE_MDNODE; - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { - Record.push_back(VE.getTypeID(N->getOperand(i)->getType())); - Record.push_back(VE.getValueID(N->getOperand(i))); + for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { + if (N->getElement(i)) { + Record.push_back(VE.getTypeID(N->getElement(i)->getType())); + Record.push_back(VE.getValueID(N->getElement(i))); + } else { + Record.push_back(VE.getTypeID(Type::VoidTy)); + Record.push_back(0); + } } } else { assert(0 && "Unknown constant!"); -- cgit v1.2.3-18-g5258