aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-05-10 20:57:05 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-05-10 20:57:05 +0000
commitb8f9b7a965756c532cbcd1ffdac05675fe65af39 (patch)
treedf8d0d1a8f45d9acfd6ce7ff3ab7851540fe0985 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent9257b234a581024444b71382504f23671a453dbf (diff)
downloadllvm-b8f9b7a965756c532cbcd1ffdac05675fe65af39.zip
llvm-b8f9b7a965756c532cbcd1ffdac05675fe65af39.tar.gz
llvm-b8f9b7a965756c532cbcd1ffdac05675fe65af39.tar.bz2
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. llvm-svn: 71407
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 1937c7e..1ad70df 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/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<MDNode>(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!");