[llvm-commits] [llvm] r84374 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Core.cpp lib/VMCore/Instructions.cpp test/Bindings/Ocaml/vmcore.ml

Nick Lewycky nicholas at mxc.ca
Sat Oct 17 16:52:26 PDT 2009


Author: nicholas
Date: Sat Oct 17 18:52:26 2009
New Revision: 84374

URL: http://llvm.org/viewvc/llvm-project?rev=84374&view=rev
Log:
Fix test/Bindings/Ocaml/vmcore.ml. When IRBuilder::CreateMalloc was removed,
LLVMBuildMalloc was reimplemented but with the bug that it didn't insert the
resulting instruction.

Modified:
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/lib/VMCore/Instructions.cpp
    llvm/trunk/test/Bindings/Ocaml/vmcore.ml

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=84374&r1=84373&r2=84374&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Sat Oct 17 18:52:26 2009
@@ -992,12 +992,14 @@
   ///    constant 1.
   /// 2. Call malloc with that argument.
   /// 3. Bitcast the result of the malloc call to the specified type.
-  static Value *CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy,
-                             const Type *AllocTy, Value *ArraySize = 0,
-                             const Twine &Name = "");
-  static Value *CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy,
-                             const Type *AllocTy, Value *ArraySize = 0,
-                             Function* MallocF = 0, const Twine &Name = "");
+  static Instruction *CreateMalloc(Instruction *InsertBefore,
+                                   const Type *IntPtrTy, const Type *AllocTy,
+                                   Value *ArraySize = 0,
+                                   const Twine &Name = "");
+  static Instruction *CreateMalloc(BasicBlock *InsertAtEnd,
+                                   const Type *IntPtrTy, const Type *AllocTy,
+                                   Value *ArraySize = 0, Function* MallocF = 0,
+                                   const Twine &Name = "");
 
   ~CallInst();
 

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=84374&r1=84373&r2=84374&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Sat Oct 17 18:52:26 2009
@@ -1700,15 +1700,17 @@
 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)->Insert(CallInst::CreateMalloc(
+      unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), 0, 0, ""),
+      Twine(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)->Insert(CallInst::CreateMalloc(
+      unwrap(B)->GetInsertBlock(), IntPtrT, unwrap(Ty), unwrap(Val), 0, ""),
+      Twine(Name)));
 }
 
 LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef B, LLVMTypeRef Ty,

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=84374&r1=84373&r2=84374&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Sat Oct 17 18:52:26 2009
@@ -460,10 +460,10 @@
   return Amt;
 }
 
-static Value *createMalloc(Instruction *InsertBefore, BasicBlock *InsertAtEnd,
-                           const Type *IntPtrTy, const Type *AllocTy,
-                           Value *ArraySize, Function* MallocF, 
-                           const Twine &NameStr) {
+static Instruction *createMalloc(Instruction *InsertBefore,
+                                 BasicBlock *InsertAtEnd, const Type *IntPtrTy,
+                                 const Type *AllocTy, Value *ArraySize,
+                                 Function *MallocF, const Twine &NameStr) {
   assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) &&
          "createMalloc needs either InsertBefore or InsertAtEnd");
 
@@ -507,7 +507,7 @@
   if (!MallocF->doesNotAlias(0)) MallocF->setDoesNotAlias(0);
   const PointerType *AllocPtrType = PointerType::getUnqual(AllocTy);
   CallInst *MCall = NULL;
-  Value    *Result = NULL;
+  Instruction *Result = NULL;
   if (InsertBefore) {
     MCall = CallInst::Create(MallocF, AllocSize, "malloccall", InsertBefore);
     Result = MCall;
@@ -536,9 +536,9 @@
 ///    constant 1.
 /// 2. Call malloc with that argument.
 /// 3. Bitcast the result of the malloc call to the specified type.
-Value *CallInst::CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy,
-                              const Type *AllocTy, Value *ArraySize,
-                              const Twine &Name) {
+Instruction *CallInst::CreateMalloc(Instruction *InsertBefore,
+                                    const Type *IntPtrTy, const Type *AllocTy,
+                                    Value *ArraySize, const Twine &Name) {
   return createMalloc(InsertBefore, NULL, IntPtrTy, AllocTy, 
                       ArraySize, NULL, Name);
 }
@@ -551,9 +551,10 @@
 /// 3. Bitcast the result of the malloc call to the specified type.
 /// Note: This function does not add the bitcast to the basic block, that is the
 /// responsibility of the caller.
-Value *CallInst::CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy,
-                              const Type *AllocTy, Value *ArraySize, 
-                              Function* MallocF, const Twine &Name) {
+Instruction *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);
 }

Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=84374&r1=84373&r2=84374&view=diff

==============================================================================
--- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original)
+++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Sat Oct 17 18:52:26 2009
@@ -936,9 +936,9 @@
   group "memory"; begin
     let bb08 = append_block context "Bb08" fn in
     let b = builder_at_end context bb08 in
-    
-    (* RUN: grep {Inst20.*malloc.*i8 } < %t.ll
-     * RUN: grep {Inst21.*malloc.*i8.*P1} < %t.ll
+
+    (* RUN: grep {Inst20.*malloc} < %t.ll
+     * RUN: grep {Inst21.*malloc} < %t.ll
      * RUN: grep {Inst22.*alloca.*i32 } < %t.ll
      * RUN: grep {Inst23.*alloca.*i32.*P2} < %t.ll
      * RUN: grep {free.*Inst20} < %t.ll





More information about the llvm-commits mailing list