diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 575dd34dbdf..4a95c7b80f9 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -691,6 +691,9 @@ int SlotCalculator::getOrCreateSlot(const Value *V) { int SlotNo = getSlot(V); // Check to see if it's already in! if (SlotNo != -1) return SlotNo; + if (const GlobalValue *GV = dyn_cast(V)) + assert(GV->getParent() != 0 && "Global not embedded into a module!"); + if (!isa(V)) // Initializers for globals are handled explicitly if (const Constant *C = dyn_cast(V)) { assert(CompactionNodeMap.empty() && diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index b54a513b72d..98a4234a410 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -295,6 +295,7 @@ void BytecodeWriter::outputConstant(const Constant *CPV) { if (const ConstantExpr *CE = dyn_cast(CPV)) { // FIXME: Encoding of constant exprs could be much more compact! assert(CE->getNumOperands() > 0 && "ConstantExpr with 0 operands"); + assert(CE->getNumOperands() != 1 || CE->getOpcode() == Instruction::Cast); output_vbr(1+CE->getNumOperands()); // flags as an expr output_vbr(CE->getOpcode()); // flags as an expr