Check in some patches for better assertions
authorChris Lattner <sabre@nondot.org>
Sat, 4 Dec 2004 21:28:47 +0000 (21:28 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 4 Dec 2004 21:28:47 +0000 (21:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18500 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Writer/SlotCalculator.cpp
lib/Bytecode/Writer/Writer.cpp

index 575dd34dbdfc65b73b8497a028f968deb0312379..4a95c7b80f9f2017ce1ec1c7345fc710814a4b9b 100644 (file)
@@ -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<GlobalValue>(V))
+    assert(GV->getParent() != 0 && "Global not embedded into a module!");
+
   if (!isa<GlobalValue>(V))  // Initializers for globals are handled explicitly
     if (const Constant *C = dyn_cast<Constant>(V)) {
       assert(CompactionNodeMap.empty() &&
index b54a513b72db112bf5ba4fe5426e095a759bb7f8..98a4234a4105a677283616665847cbe7ae0a52a0 100644 (file)
@@ -295,6 +295,7 @@ void BytecodeWriter::outputConstant(const Constant *CPV) {
   if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(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