summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-09 07:12:01 +0000
committerChris Lattner <sabre@nondot.org>2009-11-09 07:12:01 +0000
commit2156c22b3c35d3bffbbd6cab80767cbf82284f22 (patch)
tree0913e36503d283bc4170e31f341ef0370ffc9de3 /llvm/lib/VMCore/Instructions.cpp
parent39c07b2eef503943ca03f2d9ed142814d0fd6ab8 (diff)
downloadbcm5719-llvm-2156c22b3c35d3bffbbd6cab80767cbf82284f22.tar.gz
bcm5719-llvm-2156c22b3c35d3bffbbd6cab80767cbf82284f22.zip
make this handle redefinition of malloc with different prototype correctly.
llvm-svn: 86525
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index f343bd18daa..9817e4c78a8 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -568,8 +568,7 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
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 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
Result = CallInst::Create(FreeFunc, PtrCast, "");
}
Result->setTailCall();
- Result->setCallingConv(FreeFunc->getCallingConv());
+ if (Function *F = dyn_cast<Function>(FreeFunc))
+ Result->setCallingConv(F->getCallingConv());
return Result;
}
OpenPOWER on IntegriCloud