diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index c128688da2f..12268edbeda 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -539,6 +539,10 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { NewCast = new CastInst(CI->getCalledValue(), NewPFunTy, CI->getCalledValue()->getName()+"_c",CI); + // Strip off unneeded CPR's. + if (ConstantPointerRef *CPR = dyn_cast(NewCast)) + NewCast = CPR->getValue(); + // Create a new call instruction... CallInst *NewCall = new CallInst(NewCast, std::vector(CI->op_begin()+1, CI->op_end()));