The ConstantExpr::getCast call can cause a CPR to be generated. If so,
authorChris Lattner <sabre@nondot.org>
Mon, 9 Feb 2004 00:20:55 +0000 (00:20 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 9 Feb 2004 00:20:55 +0000 (00:20 +0000)
strip it off.

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

lib/Transforms/LevelRaise.cpp

index c128688da2f732e3973d2c45402916e6f53cb600..12268edbeda6e6f72c13769bb35c1d6f1a342707 100644 (file)
@@ -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<ConstantPointerRef>(NewCast))
+        NewCast = CPR->getValue();
+
       // Create a new call instruction...
       CallInst *NewCall = new CallInst(NewCast,
                            std::vector<Value*>(CI->op_begin()+1, CI->op_end()));