[llvm-commits] [llvm] r86290 - /llvm/trunk/lib/VMCore/Instructions.cpp

Victor Hernandez vhernandez at apple.com
Fri Nov 6 13:43:21 PST 2009


Author: hernande
Date: Fri Nov  6 15:43:21 2009
New Revision: 86290

URL: http://llvm.org/viewvc/llvm-project?rev=86290&view=rev
Log:
CallInst::CreateMalloc() and CallInst::CreateFree() need to create calls with correct calling convention

Modified:
    llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=86290&r1=86289&r2=86290&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Nov  6 15:43:21 2009
@@ -524,6 +524,7 @@
     }
   }
   MCall->setTailCall();
+  MCall->setCallingConv(MallocF->getCallingConv());
   assert(MCall->getType() != Type::getVoidTy(BB->getContext()) &&
          "Malloc has void return type");
 
@@ -572,8 +573,8 @@
   const Type *VoidTy = Type::getVoidTy(M->getContext());
   const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
   // prototype free as "void free(void*)"
-  Constant *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL);
-
+  Function *FreeFunc = cast<Function>(M->getOrInsertFunction("free", VoidTy,
+                                                             IntPtrTy, NULL));
   CallInst* Result = NULL;
   Value *PtrCast = Source;
   if (InsertBefore) {
@@ -586,6 +587,7 @@
     Result = CallInst::Create(FreeFunc, PtrCast, "");
   }
   Result->setTailCall();
+  Result->setCallingConv(FreeFunc->getCallingConv());
 
   return Result;
 }





More information about the llvm-commits mailing list