[llvm-commits] [llvm] r55873 - /llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp

Nuno Lopes nunoplopes at sapo.pt
Sat Sep 6 10:44:06 PDT 2008


Author: nlopes
Date: Sat Sep  6 12:44:06 2008
New Revision: 55873

URL: http://llvm.org/viewvc/llvm-project?rev=55873&view=rev
Log:
fix crash when the malloc/free function is defined or is a declaration with 0 parameters.
this pass doesnt seem to be used, but still it's now a little more correct

Modified:
    llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp

Modified: llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp?rev=55873&r1=55872&r2=55873&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IndMemRemoval.cpp Sat Sep  6 12:44:06 2008
@@ -51,8 +51,7 @@
   //happen through intrinsics.
   bool changed = false;
   if (Function* F = M.getFunction("free")) {
-    assert(F->isDeclaration() && "free not external?");
-    if (!F->use_empty()) {
+    if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) {
       Function* FN = Function::Create(F->getFunctionType(),
                                       GlobalValue::LinkOnceLinkage,
                                       "free_llvm_bounce", &M);
@@ -66,8 +65,7 @@
     }
   }
   if (Function* F = M.getFunction("malloc")) {
-    assert(F->isDeclaration() && "malloc not external?");
-    if (!F->use_empty()) {
+    if (F->isDeclaration() && F->arg_size() == 1 && !F->use_empty()) {
       Function* FN = Function::Create(F->getFunctionType(), 
                                       GlobalValue::LinkOnceLinkage, 
                                       "malloc_llvm_bounce", &M);





More information about the llvm-commits mailing list