summaryrefslogtreecommitdiffstats
path: root/llvm/examples/BrainF/BrainF.cpp
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
commit46cd46731082e7ad6cd3901e2a13f68d7a774cab (patch)
tree20ff75183155d9aea9233c735252cd4a21da91d6 /llvm/examples/BrainF/BrainF.cpp
parent5fe313d6e04677908225d4e570f9d989151ba377 (diff)
downloadbcm5719-llvm-46cd46731082e7ad6cd3901e2a13f68d7a774cab.tar.gz
bcm5719-llvm-46cd46731082e7ad6cd3901e2a13f68d7a774cab.zip
Auto-upgrade malloc instructions to malloc calls.
Reviewed by Devang Patel. llvm-svn: 82694
Diffstat (limited to 'llvm/examples/BrainF/BrainF.cpp')
-rw-r--r--llvm/examples/BrainF/BrainF.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/examples/BrainF/BrainF.cpp b/llvm/examples/BrainF/BrainF.cpp
index 5cf2b883bc4..c64b87f2f39 100644
--- a/llvm/examples/BrainF/BrainF.cpp
+++ b/llvm/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)
{
OpenPOWER on IntegriCloud