aboutsummaryrefslogtreecommitdiffstats
path: root/examples/BrainF
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-09-24 17:47:49 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-09-24 17:47:49 +0000
commit96b930ddc7f0df9e278a5cb65ad77a559a20964e (patch)
treedd7af062fff46c35323ed13331eda6126609cf91 /examples/BrainF
parentc34666ee1871d47dfa4865c7138902dd1b770101 (diff)
downloadexternal_llvm-96b930ddc7f0df9e278a5cb65ad77a559a20964e.zip
external_llvm-96b930ddc7f0df9e278a5cb65ad77a559a20964e.tar.gz
external_llvm-96b930ddc7f0df9e278a5cb65ad77a559a20964e.tar.bz2
Auto-upgrade malloc instructions to malloc calls.
Reviewed by Devang Patel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82694 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples/BrainF')
-rw-r--r--examples/BrainF/BrainF.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp
index 5cf2b88..c64b87f 100644
--- a/examples/BrainF/BrainF.cpp
+++ b/examples/BrainF/BrainF.cpp
@@ -25,6 +25,7 @@
#include "BrainF.h"
#include "llvm/Constants.h"
+#include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
#include "llvm/ADT/STLExtras.h"
#include <iostream>
@@ -78,7 +79,11 @@ void BrainF::header(LLVMContext& C) {
//%arr = malloc i8, i32 %d
ConstantInt *val_mem = ConstantInt::get(C, APInt(32, memtotal));
- ptr_arr = builder->CreateMalloc(IntegerType::getInt8Ty(C), val_mem, "arr");
+ BasicBlock* BB = builder->GetInsertBlock();
+ const Type* IntPtrTy = IntegerType::getInt32Ty(C);
+ ptr_arr = CallInst::CreateMalloc(BB, IntPtrTy, IntegerType::getInt8Ty(C),
+ val_mem, NULL, "arr");
+ BB->getInstList().push_back(cast<Instruction>(ptr_arr));
//call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1)
{