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 | 3e0c99a26f365bddb667124db40a5734e35c5a2d (patch) | |
tree | 406ef499eb4ee0c0b5f704d726d1d9c39ad79694 /lib/VMCore | |
parent | a45bfd31de14321262dd5f5123d04fc953a79ff1 (diff) | |
download | external_llvm-3e0c99a26f365bddb667124db40a5734e35c5a2d.zip external_llvm-3e0c99a26f365bddb667124db40a5734e35c5a2d.tar.gz external_llvm-3e0c99a26f365bddb667124db40a5734e35c5a2d.tar.bz2 |
Revert 82694 "Auto-upgrade malloc instructions to malloc calls." because it causes regressions in the nightly tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82784 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Core.cpp | 8 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 20 |
2 files changed, 10 insertions, 18 deletions
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index 248127d..1dbf5c4 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -1636,16 +1636,12 @@ LLVMValueRef LLVMBuildNot(LLVMBuilderRef B, LLVMValueRef V, const char *Name) { LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, const char *Name) { - const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), IntPtrT, - unwrap(Ty), 0, 0, Twine(Name))); + return wrap(unwrap(B)->CreateMalloc(unwrap(Ty), 0, Name)); } LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Val, const char *Name) { - const Type* IntPtrT = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext()); - return wrap(CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(), IntPtrT, - unwrap(Ty), unwrap(Val), 0, Twine(Name))); + return wrap(unwrap(B)->CreateMalloc(unwrap(Ty), unwrap(Val), Name)); } LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty, diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 611bf16..b7acce7 100644 --- a/lib/VMCore/Instructions.cpp +++ b/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); } //===----------------------------------------------------------------------===// |