* Remove dead code from ExprTypeConvert.cpp

- I->use_empty() can never be true because of the IHolder's
* Fix bug: test/Regression/Transforms/LevelRaise/2002-07-16-SourceAndDestCrash.ll
   - Add a new NewCasts member to VMC to keep track of casts that have been
     created and to ensure there is always a reference to the cast.
   - Extend ValueHandle a bit so it can be used in an STL container
   - Make sure we destroy the ValueMapCache before verifying the function
     in LevelRaise.cpp


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2936 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-07-17 17:11:33 +00:00
parent 1ab8425c1c
commit b1b4262387
3 changed files with 83 additions and 66 deletions

View File

@ -225,17 +225,20 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
PRINT_PEEPHOLE3("CAST-SRC-EXPR-CONV:in ", Src, CI, BB->getParent());
DEBUG(cerr << "\nCONVERTING SRC EXPR TYPE:\n");
ValueMapCache ValueMap;
Value *E = ConvertExpressionToType(Src, DestTy, ValueMap);
if (Constant *CPV = dyn_cast<Constant>(E))
CI->replaceAllUsesWith(CPV);
{ // ValueMap must be destroyed before function verified!
ValueMapCache ValueMap;
Value *E = ConvertExpressionToType(Src, DestTy, ValueMap);
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
PRINT_PEEPHOLE1("CAST-SRC-EXPR-CONV:out", E);
DEBUG(cerr << "DONE CONVERTING SRC EXPR TYPE: \n" << BB->getParent());
if (Constant *CPV = dyn_cast<Constant>(E))
CI->replaceAllUsesWith(CPV);
PRINT_PEEPHOLE1("CAST-SRC-EXPR-CONV:out", E);
DEBUG(cerr << "DONE CONVERTING SRC EXPR TYPE: \n" << BB->getParent());
}
DEBUG(assert(verifyFunction(*BB->getParent()) == false &&
"Function broken!"));
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
++NumExprTreesConv;
return true;
}
@ -249,15 +252,17 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", Src, CI, BB->getParent());
DEBUG(cerr << "\nCONVERTING EXPR TYPE:\n");
ValueMapCache ValueMap;
ConvertValueToNewType(CI, Src, ValueMap); // This will delete CI!
{ // ValueMap must be destroyed before function verified!
ValueMapCache ValueMap;
ConvertValueToNewType(CI, Src, ValueMap); // This will delete CI!
}
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
PRINT_PEEPHOLE1("CAST-DEST-EXPR-CONV:out", Src);
DEBUG(cerr << "DONE CONVERTING EXPR TYPE: \n\n" << BB->getParent());
DEBUG(assert(verifyFunction(*BB->getParent()) == false &&
"Function broken!"));
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
++NumExprTreesConv;
return true;
}