diff options
Diffstat (limited to 'lib/Bytecode/Writer')
-rw-r--r-- | lib/Bytecode/Writer/SlotCalculator.cpp | 6 | ||||
-rw-r--r-- | lib/Bytecode/Writer/Writer.cpp | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 766b000271..2c6dd5e9a6 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -406,6 +406,10 @@ int SlotCalculator::insertValue(const Value *D, bool dontIgnore) { return doInsertValue(D); } +static inline bool hasNullValue(unsigned TyID) { + return TyID != Type::LabelTyID && TyID != Type::TypeTyID && + TyID != Type::VoidTyID; +} // doInsertValue - This is a small helper function to be called only // be insertValue. @@ -435,7 +439,7 @@ int SlotCalculator::doInsertValue(const Value *D) { // If this is the first value to get inserted into the type plane, make sure // to insert the implicit null value... - if (Table[Ty].empty() && Ty >= Type::FirstDerivedTyID && BuildBytecodeInfo) { + if (Table[Ty].empty() && BuildBytecodeInfo && hasNullValue(Ty)) { Value *ZeroInitializer = Constant::getNullValue(Typ); // If we are pushing zeroinit, it will be handled below. diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 6467921d05..ff9e8a989b 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -161,6 +161,11 @@ void BytecodeWriter::outputConstantsInPlane(const std::vector<const Value*> } } +static inline bool hasNullValue(unsigned TyID) { + return TyID != Type::LabelTyID && TyID != Type::TypeTyID && + TyID != Type::VoidTyID; +} + void BytecodeWriter::outputConstants(bool isFunction) { ConstantTotalBytes -= Out.size(); if (isFunction) FunctionConstantTotalBytes -= Out.size(); @@ -190,7 +195,7 @@ void BytecodeWriter::outputConstants(bool isFunction) { if (isFunction) // Don't re-emit module constants ValNo += Table.getModuleLevel(pno); - if (pno >= Type::FirstDerivedTyID) { + if (hasNullValue(pno)) { // Skip zero initializer if (ValNo == 0) ValNo = 1; |