diff options
author | Victor Hernandez <vhernandez@apple.com> | 2009-09-25 18:11:52 +0000 |
---|---|---|
committer | Victor Hernandez <vhernandez@apple.com> | 2009-09-25 18:11:52 +0000 |
commit | e6ff7662b67a358cf985c5133f9cb30f9d979e97 (patch) | |
tree | 9b2d337a2da01bb61d8059dd4f0088f4e9cad744 /llvm/lib/VMCore/Instructions.cpp | |
parent | 5aec1b54bce5f7e916acb7d758e052b04e0c2996 (diff) | |
download | bcm5719-llvm-e6ff7662b67a358cf985c5133f9cb30f9d979e97.tar.gz bcm5719-llvm-e6ff7662b67a358cf985c5133f9cb30f9d979e97.zip |
Revert 82694 "Auto-upgrade malloc instructions to malloc calls." because it causes regressions in the nightly tests.
llvm-svn: 82784
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 611bf160d08..b7acce71e3a 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -462,8 +462,7 @@ static Value *checkArraySize(Value *Amt, const Type *IntPtrTy) { static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, - Value *ArraySize, Function* MallocF, - const Twine &NameStr) { + Value *ArraySize, const Twine &NameStr) { assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) && "createMalloc needs either InsertBefore or InsertAtEnd"); @@ -500,11 +499,10 @@ static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, BasicBlock* BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd; Module* M = BB->getParent()->getParent(); const Type *BPTy = PointerType::getUnqual(Type::getInt8Ty(BB->getContext())); - if (!MallocF) - // prototype malloc as "void *malloc(size_t)" - MallocF = cast<Function>(M->getOrInsertFunction("malloc", BPTy, - IntPtrTy, NULL)); - if (!MallocF->doesNotAlias(0)) MallocF->setDoesNotAlias(0); + // prototype malloc as "void *malloc(size_t)" + Constant *MallocF = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, NULL); + if (!cast<Function>(MallocF)->doesNotAlias(0)) + cast<Function>(MallocF)->setDoesNotAlias(0); const PointerType *AllocPtrType = PointerType::getUnqual(AllocTy); CallInst *MCall = NULL; Value *MCast = NULL; @@ -533,8 +531,7 @@ static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd, Value *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, const Type *AllocTy, Value *ArraySize, const Twine &Name) { - return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, - ArraySize, NULL, Name); + return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, ArraySize, Name); } /// CreateMalloc - Generate the IR for a call to malloc: @@ -547,9 +544,8 @@ Value *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, /// responsibility of the caller. Value *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, const Type *AllocTy, Value *ArraySize, - Function* MallocF, const Twine &Name) { - return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, - ArraySize, MallocF, Name); + const Twine &Name) { + return createMalloc(NULL, InsertAtEnd, IntPtrTy, AllocTy, ArraySize, Name); } //===----------------------------------------------------------------------===// |