diff options
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index f343bd18da..9817e4c78a 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; } |