* Add assertion to ExprTypeConvert to detect error earlier than without it
authorChris Lattner <sabre@nondot.org>
Tue, 16 Jul 2002 17:33:13 +0000 (17:33 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 16 Jul 2002 17:33:13 +0000 (17:33 +0000)
* Fix bug in LevelRaise.cpp, correcting this problem:
    test/Regression/Transforms/LevelRaise/2002-07-16-RaiseCrash.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2920 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/ExprTypeConvert.cpp
lib/Transforms/LevelRaise.cpp

index a6106b08227b9e23f4192ae2c62ce3ebb0611cbc..eea8607ed08aea3ffb822b58b362ca80d3d3c940 100644 (file)
@@ -903,6 +903,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
   Instruction *I = cast<Instruction>(U);  // Only Instructions convertable
 
   BasicBlock *BB = I->getParent();
+  assert(BB != 0 && "Instruction not embedded in basic block!");
   BasicBlock::InstListType &BIL = BB->getInstList();
   std::string Name = I->getName();  if (!Name.empty()) I->setName("");
   Instruction *Res;     // Result of conversion
index afc2ad5d7a670bcf0ad7b7acc15e421e8b751556..2b9ff6d41b29cc53266d365ad721574e054490b0 100644 (file)
@@ -227,6 +227,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
       // source type of the cast...
       //
       ConvertedTypes.clear();
+      ConvertedTypes[CI] = Src->getType();  // Make sure the cast _does_ change
       if (ValueConvertableToType(CI, Src->getType(), ConvertedTypes)) {
         PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", Src, CI, BB->getParent());