summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.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/Reader/BitcodeReader.cpp
parent9257b234a581024444b71382504f23671a453dbf (diff)
downloadbcm5719-llvm-b8f9b7a965756c532cbcd1ffdac05675fe65af39.tar.gz
bcm5719-llvm-b8f9b7a965756c532cbcd1ffdac05675fe65af39.zip
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/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index fe20f725878..d2b4544cb00 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -17,6 +17,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
+#include "llvm/MDNode.h"
#include "llvm/Module.h"
#include "llvm/AutoUpgrade.h"
#include "llvm/ADT/SmallString.h"
@@ -287,12 +288,10 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() {
UserCS->getType()->isPacked());
} else if (isa<ConstantVector>(UserC)) {
NewC = ConstantVector::get(&NewOps[0], NewOps.size());
- } else if (isa<ConstantExpr>(UserC)) {
+ } else {
+ assert(isa<ConstantExpr>(UserC) && "Must be a ConstantExpr.");
NewC = cast<ConstantExpr>(UserC)->getWithOperands(&NewOps[0],
NewOps.size());
- } else {
- assert(isa<MDNode>(UserC) && "Must be a metadata node.");
- NewC = MDNode::get(&NewOps[0], NewOps.size());
}
UserC->replaceAllUsesWith(NewC);
@@ -300,6 +299,8 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() {
NewOps.clear();
}
+ // Update all ValueHandles, they should be the only users at this point.
+ Placeholder->replaceAllUsesWith(RealVal);
delete Placeholder;
}
}
@@ -1017,10 +1018,13 @@ bool BitcodeReader::ParseConstants() {
return Error("Invalid CST_MDNODE record");
unsigned Size = Record.size();
- SmallVector<Constant*, 8> Elts;
+ SmallVector<Value*, 8> Elts;
for (unsigned i = 0; i != Size; i += 2) {
const Type *Ty = getTypeByID(Record[i], false);
- Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], Ty));
+ if (Ty != Type::VoidTy)
+ Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], Ty));
+ else
+ Elts.push_back(NULL);
}
V = MDNode::get(&Elts[0], Elts.size());
break;
OpenPOWER on IntegriCloud