remove extractMallocCallFromBitCast, since it was tailor maded for its sole user...
authorNuno Lopes <nunoplopes@sapo.pt>
Fri, 22 Jun 2012 00:25:01 +0000 (00:25 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Fri, 22 Jun 2012 00:25:01 +0000 (00:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158952 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/MemoryBuiltins.h
lib/Analysis/MemoryBuiltins.cpp
lib/Transforms/IPO/GlobalOpt.cpp

index 3694f8f8642a1cca939c37e3637bbbf3398c9a72..4072878f39b5aa14e7fa554a3a7ab93c2f850411 100644 (file)
@@ -69,13 +69,6 @@ static inline CallInst *extractMallocCall(Value *I) {
   return const_cast<CallInst*>(extractMallocCall((const Value*)I));
 }
 
-/// extractMallocCallFromBitCast - Returns the corresponding CallInst if the
-/// instruction is a bitcast of the result of a malloc call.
-const CallInst *extractMallocCallFromBitCast(const Value *I);
-static inline CallInst *extractMallocCallFromBitCast(Value *I) {
-  return const_cast<CallInst*>(extractMallocCallFromBitCast((const Value*)I));
-}
-
 /// isArrayMalloc - Returns the corresponding CallInst if the instruction 
 /// is a call to malloc whose array size can be determined and the array size
 /// is not constant 1.  Otherwise, return NULL.
index 26d466ed31a313f4aeada0d8a27217b5263b3b3a..d1a9363b411c57086099ff130c76ec6cead98120 100644 (file)
@@ -170,14 +170,7 @@ bool llvm::isReallocLikeFn(const Value *V, bool LookThroughBitCast) {
 /// is a malloc call.  Since CallInst::CreateMalloc() only creates calls, we
 /// ignore InvokeInst here.
 const CallInst *llvm::extractMallocCall(const Value *I) {
-  return isMallocLikeFn(I) ? cast<CallInst>(I) : 0;
-}
-
-/// extractMallocCallFromBitCast - Returns the corresponding CallInst if the
-/// instruction is a bitcast of the result of a malloc call.
-const CallInst *llvm::extractMallocCallFromBitCast(const Value *I) {
-  const BitCastInst *BCI = dyn_cast<BitCastInst>(I);
-  return BCI ? extractMallocCall(BCI->getOperand(0)) : 0;
+  return isMallocLikeFn(I) ? dyn_cast<CallInst>(I) : 0;
 }
 
 static Value *computeArraySize(const CallInst *CI, const TargetData *TD,
index cca959b2476e10fadb1c7f2a45c00e90e3724659..ab58c41bf4ed82a3910f5758d34e916515faefe4 100644 (file)
@@ -1567,8 +1567,10 @@ static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV,
       Instruction *Cast = new BitCastInst(Malloc, CI->getType(), "tmp", CI);
       CI->replaceAllUsesWith(Cast);
       CI->eraseFromParent();
-      CI = dyn_cast<BitCastInst>(Malloc) ?
-        extractMallocCallFromBitCast(Malloc) : cast<CallInst>(Malloc);
+      if (BitCastInst *BCI = dyn_cast<BitCastInst>(Malloc))
+        CI = cast<CallInst>(BCI->getOperand(0));
+      else
+      CI = cast<CallInst>(Malloc);
     }
 
     GVI = PerformHeapAllocSRoA(GV, CI, getMallocArraySize(CI, TD, true), TD);