add support for undef values of opaque type, addressing PR541
llvm-svn: 21701
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp
index cdda1c7..d4f231b 100644
--- a/llvm/lib/Bytecode/Writer/Writer.cpp
+++ b/llvm/lib/Bytecode/Writer/Writer.cpp
@@ -843,8 +843,8 @@
}
}
-static inline bool hasNullValue(unsigned TyID) {
- return TyID != Type::LabelTyID && TyID != Type::VoidTyID;
+static inline bool hasNullValue(const Type *Ty) {
+ return Ty != Type::LabelTy && Ty != Type::VoidTy && !isa<OpaqueType>(Ty);
}
void BytecodeWriter::outputConstants(bool isFunction) {
@@ -867,7 +867,7 @@
if (isFunction) // Don't re-emit module constants
ValNo += Table.getModuleLevel(pno);
- if (hasNullValue(pno)) {
+ if (hasNullValue(Plane[0]->getType())) {
// Skip zero initializer
if (ValNo == 0)
ValNo = 1;