[llvm-commits] [llvm] r86525 - /llvm/trunk/lib/VMCore/Instructions.cpp
Chris Lattner
sabre at nondot.org
Sun Nov 8 23:12:01 PST 2009
Author: lattner
Date: Mon Nov 9 01:12:01 2009
New Revision: 86525
URL: http://llvm.org/viewvc/llvm-project?rev=86525&view=rev
Log:
make this handle redefinition of malloc with different prototype correctly.
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=86525&r1=86524&r2=86525&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Nov 9 01:12:01 2009
@@ -568,8 +568,7 @@
const Type *VoidTy = Type::getVoidTy(M->getContext());
const Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
// prototype free as "void free(void*)"
- Function *FreeFunc = cast<Function>(M->getOrInsertFunction("free", VoidTy,
- IntPtrTy, NULL));
+ Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL);
CallInst* Result = NULL;
Value *PtrCast = Source;
if (InsertBefore) {
@@ -582,7 +581,8 @@
Result = CallInst::Create(FreeFunc, PtrCast, "");
}
Result->setTailCall();
- Result->setCallingConv(FreeFunc->getCallingConv());
+ if (Function *F = dyn_cast<Function>(FreeFunc))
+ Result->setCallingConv(F->getCallingConv());
return Result;
}
More information about the llvm-commits
mailing list