summaryrefslogtreecommitdiffstats
path: root/llvm/examples
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2019-02-01 03:23:42 +0000
committerJames Y Knight <jyknight@google.com>2019-02-01 03:23:42 +0000
commit473e3420ce37fae60f7c6d1e6b08adc1fd0de71e (patch)
tree7b87b6d4a65766167a4d0cfc377af02a77a5246c /llvm/examples
parentb6c06dc28f96032d5bf101ed8e61549442dc912d (diff)
downloadbcm5719-llvm-473e3420ce37fae60f7c6d1e6b08adc1fd0de71e.tar.gz
bcm5719-llvm-473e3420ce37fae60f7c6d1e6b08adc1fd0de71e.zip
Fix compilation of examples after 13680223b9d8 / r352827
Who knew...they're not built by default or as part of the tests. llvm-svn: 352830
Diffstat (limited to 'llvm/examples')
-rw-r--r--llvm/examples/BrainF/BrainF.cpp3
-rw-r--r--llvm/examples/BrainF/BrainF.h2
-rw-r--r--llvm/examples/BrainF/BrainFDriver.cpp5
-rw-r--r--llvm/examples/ParallelJIT/ParallelJIT.cpp22
4 files changed, 18 insertions, 14 deletions
diff --git a/llvm/examples/BrainF/BrainF.cpp b/llvm/examples/BrainF/BrainF.cpp
index b4cbc780a04..2937f8c6cc1 100644
--- a/llvm/examples/BrainF/BrainF.cpp
+++ b/llvm/examples/BrainF/BrainF.cpp
@@ -82,7 +82,8 @@ void BrainF::header(LLVMContext& C) {
//Function header
//define void @brainf()
- brainf_func = module->getOrInsertFunction("brainf", Type::getVoidTy(C));
+ brainf_func = Function::Create(FunctionType::get(Type::getVoidTy(C), false),
+ Function::ExternalLinkage, "brainf", module);
builder = new IRBuilder<>(BasicBlock::Create(C, label, brainf_func));
diff --git a/llvm/examples/BrainF/BrainF.h b/llvm/examples/BrainF/BrainF.h
index 9d6848e5bc6..3bd6b16f716 100644
--- a/llvm/examples/BrainF/BrainF.h
+++ b/llvm/examples/BrainF/BrainF.h
@@ -78,7 +78,7 @@ class BrainF {
CompileFlags comflag;
std::istream *in;
Module *module;
- FunctionCallee brainf_func;
+ Function *brainf_func;
FunctionCallee getchar_func;
FunctionCallee putchar_func;
Value *ptr_arr;
diff --git a/llvm/examples/BrainF/BrainFDriver.cpp b/llvm/examples/BrainF/BrainFDriver.cpp
index 2c63b254246..1eef5fcf853 100644
--- a/llvm/examples/BrainF/BrainFDriver.cpp
+++ b/llvm/examples/BrainF/BrainFDriver.cpp
@@ -75,9 +75,10 @@ void addMainFunction(Module *mod) {
FunctionType *main_func_fty = FunctionType::get(
Type::getInt32Ty(mod->getContext()),
{Type::getInt32Ty(mod->getContext()),
- Type::getInt8Ty(mod->getContext())->getPointerTo()->getPointerTo()});
+ Type::getInt8Ty(mod->getContext())->getPointerTo()->getPointerTo()},
+ false);
Function *main_func =
- Function::create(main_func_fty, Function::ExternalLinkage, "main", mod);
+ Function::Create(main_func_fty, Function::ExternalLinkage, "main", mod);
{
Function::arg_iterator args = main_func->arg_begin();
diff --git a/llvm/examples/ParallelJIT/ParallelJIT.cpp b/llvm/examples/ParallelJIT/ParallelJIT.cpp
index b5815dd2f78..9c148a08017 100644
--- a/llvm/examples/ParallelJIT/ParallelJIT.cpp
+++ b/llvm/examples/ParallelJIT/ParallelJIT.cpp
@@ -47,6 +47,7 @@
using namespace llvm;
static Function* createAdd1(Module *M) {
+ LLVMContext &Context = M->getContext();
// Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int".
Function *Add1F =
@@ -56,10 +57,10 @@ static Function* createAdd1(Module *M) {
// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
- BasicBlock *BB = BasicBlock::Create(M->getContext(), "EntryBlock", Add1F);
+ BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", Add1F);
// Get pointers to the constant `1'.
- Value *One = ConstantInt::get(Type::getInt32Ty(M->getContext()), 1);
+ Value *One = ConstantInt::get(Type::getInt32Ty(Context), 1);
// Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -70,13 +71,14 @@ static Function* createAdd1(Module *M) {
Instruction *Add = BinaryOperator::CreateAdd(One, ArgX, "addresult", BB);
// Create the return instruction and add it to the basic block
- ReturnInst::Create(M->getContext(), Add, BB);
+ ReturnInst::Create(Context, Add, BB);
// Now, function add1 is ready.
return Add1F;
}
static Function *CreateFibFunction(Module *M) {
+ LLVMContext &Context = M->getContext();
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
FunctionType *FibFTy = FunctionType::get(Type::getInt32Ty(Context),
@@ -85,27 +87,27 @@ static Function *CreateFibFunction(Module *M) {
Function::Create(FibFTy, Function::ExternalLinkage, "fib", M);
// Add a basic block to the function.
- BasicBlock *BB = BasicBlock::Create(M->getContext(), "EntryBlock", FibF);
+ BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", FibF);
// Get pointers to the constants.
- Value *One = ConstantInt::get(Type::getInt32Ty(M->getContext()), 1);
- Value *Two = ConstantInt::get(Type::getInt32Ty(M->getContext()), 2);
+ Value *One = ConstantInt::get(Type::getInt32Ty(Context), 1);
+ Value *Two = ConstantInt::get(Type::getInt32Ty(Context), 2);
// Get pointer to the integer argument of the add1 function...
Argument *ArgX = &*FibF->arg_begin(); // Get the arg.
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the true_block.
- BasicBlock *RetBB = BasicBlock::Create(M->getContext(), "return", FibF);
+ BasicBlock *RetBB = BasicBlock::Create(Context, "return", FibF);
// Create an exit block.
- BasicBlock* RecurseBB = BasicBlock::Create(M->getContext(), "recurse", FibF);
+ BasicBlock *RecurseBB = BasicBlock::Create(Context, "recurse", FibF);
// Create the "if (arg < 2) goto exitbb"
Value *CondInst = new ICmpInst(*BB, ICmpInst::ICMP_SLE, ArgX, Two, "cond");
BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
// Create: ret int 1
- ReturnInst::Create(M->getContext(), One, RetBB);
+ ReturnInst::Create(Context, One, RetBB);
// create fib(x-1)
Value *Sub = BinaryOperator::CreateSub(ArgX, One, "arg", RecurseBB);
@@ -120,7 +122,7 @@ static Function *CreateFibFunction(Module *M) {
BinaryOperator::CreateAdd(CallFibX1, CallFibX2, "addresult", RecurseBB);
// Create the return instruction and add it to the basic block
- ReturnInst::Create(M->getContext(), Sum, RecurseBB);
+ ReturnInst::Create(Context, Sum, RecurseBB);
return FibF;
}
OpenPOWER on IntegriCloud