aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
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
commite0efca5e6470972e944ea2fc546690652eb4a6ea (patch)
tree6f85711113c3135a529b6cd8f5344f19bbdc8e55 /lib/VMCore
parent69a7075dc8caf9332f5c105577d0ea36a1cfd00e (diff)
downloadexternal_llvm-e0efca5e6470972e944ea2fc546690652eb4a6ea.zip
external_llvm-e0efca5e6470972e944ea2fc546690652eb4a6ea.tar.gz
external_llvm-e0efca5e6470972e944ea2fc546690652eb4a6ea.tar.bz2
make this handle redefinition of malloc with different prototype correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Instructions.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index f343bd1..9817e4c 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/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;
}