[llvm-commits] [poolalloc] r132933 - /poolalloc/trunk/lib/AssistDS/ArgCast.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Mon Jun 13 14:02:54 PDT 2011


Author: aggarwa4
Date: Mon Jun 13 16:02:54 2011
New Revision: 132933

URL: http://llvm.org/viewvc/llvm-project?rev=132933&view=rev
Log:
Allow cases where the return type is different too.

Modified:
    poolalloc/trunk/lib/AssistDS/ArgCast.cpp

Modified: poolalloc/trunk/lib/AssistDS/ArgCast.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/ArgCast.cpp?rev=132933&r1=132932&r2=132933&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/ArgCast.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/ArgCast.cpp Mon Jun 13 16:02:54 2011
@@ -90,13 +90,6 @@
           // by the function are the same.
           if(CI->getNumOperands() != I->arg_size() + 1)
             continue;
-          // Check that the return type of the function matches that
-          // expected by the call inst(ensures that the reason for the
-          // cast is not the return type).
-          if(CI->getType() != I->getReturnType()) {
-            if(CI->getNumUses() != 0)
-              continue;
-          }
           // If so, add to worklist
           worklist.push_back(CI);
         }
@@ -169,8 +162,15 @@
     CallInst *CINew = CallInst::Create(F, Args.begin(), Args.end(), "", CI);
     CINew->setCallingConv(CI->getCallingConv());
     CINew->setAttributes(CI->getAttributes());
-    if(!CI->use_empty())
-      CI->replaceAllUsesWith(CINew);
+    if(!CI->use_empty()) {
+      CastInst *RetCast;
+      if(CI->getType() != CINew->getType()) {
+        RetCast = CastInst::CreatePointerCast(CINew, CI->getType(), "", CI);
+        CI->replaceAllUsesWith(RetCast);
+      } else {
+        CI->replaceAllUsesWith(CINew);
+      }
+    }
 
     // Debug printing
     DEBUG(errs() << "ARGCAST:");





More information about the llvm-commits mailing list