Displaying 20 results from an estimated 40 matches for "createret".
2017 Mar 31
2
How to write the same things as `opt` command in C++ API
...asicBlock *block = llvm::BasicBlock::Create(context, "entry", aFun);
/// @brief builder
llvm::IRBuilder<> builder(block);
builder.SetInsertPoint(block);
llvm::CallInst *cCall = builder.CreateCall(cFun, {}, "c");
llvm::Value *res = cCall;
builder.CreateRet(res);
llvm::verifyFunction(*aFun);
}
// Body of the `b` function
{
/// @brief Set entry label
llvm::BasicBlock *block = llvm::BasicBlock::Create(context, "entry", bFun);
/// @brief builder
llvm::IRBuilder<> builder(block);
builder.SetInsertPoint(block);...
2011 Aug 31
2
[LLVMdev] How to place call(s) to functions found in other llvm modules ???
...ntInt::get(Type::getInt32Ty(Context), 30);
Value *Fifty = ConstantInt::get(Type::getInt32Ty(Context), 50);
std::vector<Value*> args;
args.push_back(Thirty);
args.push_back(Fifty);
Value *gcd_val = builder.CreateCall(gcd, args.begin(), args.end(),
"tmp");
builder.CreateRet(gcd_val);
return mod;
}
Module* makeLLVMModule(LLVMContext& Context) {
// Module Construction
Module* mod = new Module("GCD", Context);
FunctionType *FT = FunctionType::get(Type::getInt32Ty(Context),
std::vector<const llvm::Type*, std::allocator<const llvm::Type*&...
2013 Nov 26
2
[LLVMdev] Disabling optimizations when using llvm::createPrintModulePass
...llvm::BasicBlock::Create(c, "__entry__",
llvmFunction);
llvm::IRBuilder <> builder(body);
llvm::Value * result =
builder.CreateBinOp(llvm::Instruction::BinaryOps::Add,
llvm::ConstantInt::getSigned(functionType, 40),
llvm::ConstantInt::getSigned(functionType, 2));
builder.CreateRet(result);
llvm::verifyModule(module, llvm::PrintMessageAction);
std::string errorInfo;
llvm::raw_fd_ostream fileStream("test.ll", errorInfo);
llvm::PassManager pm;
pm.add(llvm::createPrintModulePass(& fileStream));
pm.run(module);
And here is the result:...
2010 Apr 18
2
[LLVMdev] Creating a Return Instruction.
Hi all,
I have to create a return instruction in a function. The function is of
type -- void * func (void *) . So i have to create a return instruction for
the function that should return a void pointer. But actually the function
will not return anything useful . it will be something like -- return void
* null. The problem i am facing is to create a return instruction the
Create function
2012 Jul 02
1
[LLVMdev] Intrinsic::getDeclaration causing dump() segfault
...:getInt1Ty(getGlobalContext()), false);
Function *func = Function::Create(ft, Function::ExternalLinkage,
"", module);
BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entry", func);
builder.SetInsertPoint(bb);
builder.CreateRet(ConstantInt::getTrue(getGlobalContext()));
// Value *memcpy = Intrinsic::getDeclaration(
// module, Intrinsic::memcpy, Type::getInt64Ty(getGlobalContext()));
func->dump();
delete module;
return 0;
}
--
Michael Welsh Duggan
(md5i at md5i.com)
2012 Jul 04
1
[LLVMdev] Non-tail calls
Hi all.
I am using LLVM to develop a procedural language. Can anybody point me to an example that uses CreateCall for a non-tail call? I am having trouble doing anything with the return value from the call besides returning it immediately.
i.e. Passing the CallInst created by CreateCall to CreateRet is working fine, but I am having trouble storing the returned value in a local variable or passing it to another call.
Adelle.
2012 Feb 01
1
[LLVMdev] Function Insertion Error
...::Create(M.getContext(), "bb1", func);
IRBuilder<> builder(BB);
Value *One = builder.getInt32(1);
Argument *ArgX = func->arg_begin();
ArgX->setName("firstarg");
Value *Add = builder.CreateAdd(One, ArgX);
builder.CreateRet(Add);
return true;
}
};
}
char FunctionInsert::ID = 0;
static RegisterPass<FunctionInsert> X("FunctionInsert", "Function Insertion Pass");
Most of the above code is from the file examples/HowToUseJIT/HowToUseJIT.cpp.
Thanks
-------------- next part ----...
2019 May 12
2
Why does verifyFunction dislike this?
...nType::get(rty, pty, false);
auto f = Function::Create(ty, GlobalValue::CommonLinkage, "f", module);
// Entry block
auto entry = BasicBlock::Create(context, "entry", f);
builder.SetInsertPoint(entry);
// return 0
auto val = ConstantInt::getSigned(rty, 0);
builder.CreateRet(val);
// Check
f->dump();
outs() << verifyFunction(*f) << '\n';
return 0;
}
Output:
define common i32 @f() {
entry:
ret i32 0
}
1
So the verifier says there is a problem, but I don't see anywhere the
problem could be. What am I missing?
-------------- next...
2016 Sep 19
3
llvm interpreter does not find function defined by addGlobalMapping
...llvm::IRBuilder<> builder(context);
builder.SetInsertPoint(pBlock);
// code for call of the c function.
auto pFunction2 = pModule->getFunction("testFunction");
auto temp = builder.CreateCall(pFunction2, std::vector<llvm::Value*>(), "calltmp");
builder.CreateRet(temp);
// generation of the llvm function calling the c function
llvm::FunctionType* ftWrapper = llvm::FunctionType::get(llvm::Type::getDoubleTy(context),noArgTypes, false);
auto pWrapperFunction = llvm::Function::Create(ftWrapper, llvm::Function::ExternalLinkage, "AFunction",pModu...
2015 Aug 05
2
[BUG] Incorrect ASCII escape characters on Mac
On Wed, 2015-08-05 at 10:02 -0400, Ramkumar Ramachandra wrote:
>
> - at 5 = internal global [10 x i8] c"\22\D0\12\F4!\00\15\F9\EC\E1"
> - at 6 = internal global [10 x i8] c"\D0\19\FB+\FD\F8#\03\E2\11"
> + at 5 = internal global [10 x i8] c"\22Ð\12ô!\00\15ùìá"
> + at 6 = internal global [10 x i8] c"Ð\19û+ýø#\03â\11"
>
> The diff
2011 Oct 13
1
[LLVMdev] problems running JIT code on Mac 32-bit
...t,
GlobalValue::ExternalLinkage,
"f", module);
Value* arg = f->arg_begin();
BasicBlock* bb = BasicBlock::Create(context, "entry", f);
IRBuilder<> builder(bb);
Value* one = builder.getInt32(1);
Value* v = builder.CreateAdd(one, arg);
builder.CreateRet(v);
ExecutionEngine* engine = EngineBuilder(module).create();
void* vpf = engine->getPointerToFunction(f);
int32_t (*fp)(int32_t) =
(int32_t (*)(int32_t))(intptr_t)vpf;
int32_t out = fp(10);
cout << "out is: " << out << endl;
return 0;...
2013 Nov 28
0
[LLVMdev] Disabling optimizations when using llvm::createPrintModulePass
...t;__entry__",
> llvmFunction);
> llvm::IRBuilder <> builder(body);
> llvm::Value * result =
> builder.CreateBinOp(llvm::Instruction::BinaryOps::Add,
> llvm::ConstantInt::getSigned(functionType, 40),
> llvm::ConstantInt::getSigned(functionType, 2));
> builder.CreateRet(result);
>
> llvm::verifyModule(module, llvm::PrintMessageAction);
>
> std::string errorInfo;
> llvm::raw_fd_ostream fileStream("test.ll", errorInfo);
>
> llvm::PassManager pm;
> pm.add(llvm::createPrintModulePass(& fileStream));
> pm.ru...
2017 Oct 14
2
Bug in replaceUsesOfWith: does not keep addrspace consistent in GEP
...ot = cast<Instruction>(Builder.CreateGEP(Arg2,
{Builder.getInt64(1)}, "slot"));
}
* Value *TypedSlot = Builder.CreateBitCast(Slot,
PointerType::get(Builder.getInt64Ty(), 1), "slot_typed");
Value *Load = Builder.CreateLoad(TypedSlot, "Val");
Builder.CreateRet(Load);
if (verifyModule(*m) == 1) {
errs() << "module has an error: ";
verifyModule(*m, &errs());
report_fatal_error("buggy module.");
}
outs() << *m << "\n";
// llvm::WriteBitcodeToFile(m, outs());
re...
2015 Oct 27
3
Add a mapping to a C++ lambda
...nction("main",
Type::getInt32Ty(Context), (Type *) 0));
BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", mainF);
IRBuilder<> builder(BB);
CallInst *lambdaRes = builder.CreateCall(lambdaFN, std::vector<Value
*>(), "lambdaRetVar");
builder.CreateRet(lambdaRes);
ExecutionEngine *EE = EngineBuilder(std::move(Owner)).create();
EE->addGlobalMapping(lambdaFN, &lambdaBody);
outs() << "We just constructed this LLVM module:\n\n" << *M;
outs() << "\n\nRunning main: ";
std::vector<GenericValue...
2012 Apr 23
1
[LLVMdev] Problem about the type of Function's arguement in llvm
...;
BasicBlock * block = BasicBlock::Create(Context, "mainBlock", fun);
IRBuilder<> builder(block);
Function::arg_iterator itr = fun->arg_begin();
builder.CreateLoad(itr);
Value *result = ConstantFP::get(Type::getDoubleTy(getGlobalContext()),
1.0);
builder.CreateRet(result);
vector<GenericValue> args;
ExecutionEngine *e = EngineBuilder(module).create();
outs()<<*module<<"\n";
outs().flush();
return 0;
}
I'm confused that arg_iterator itr ( Function::arg_iterator itr =
fun->arg_begin(); ) can be used...
2019 Jan 02
2
JIT compiler, Windows, external functions like cos
...td::vector<Type *> args(1, Type::getDoubleTy(context));
FunctionType *FT = FunctionType::get(Type::getDoubleTy(context), args,
false);
auto externalFn_llvm = Function::Create(FT, Function::ExternalLinkage,
externalFnName, pModule);
auto ret = builder.CreateCall(externalFn_llvm, x);
builder.CreateRet(ret);
errs() << "Created Module:\n\n" << *pModule;
auto jitCompiler =
EngineBuilder(std::move(module)).setOptLevel(CodeGenOpt::Level::Default).create();
JitCompiledFn externalFn =
(JitCompiledFn)jitCompiler->getFunctionAddress(externalFn_IR->getName());
errs() <...
2016 May 17
3
External function resolution: MCJIT vs ORC JIT
...ilder (Context);
auto block = llvm::BasicBlock::Create (Context, "", myfunc);
builder.SetInsertPoint (block);
llvm::Value *a = llvm::cast<llvm::Value>(myfunc->arg_begin());
llvm::Value *asq = builder.CreateCall (M->getFunction ("sqr"), a);
builder.CreateRet (asq);
// Set up compilation
if (orc) {
auto Resolver = llvm::orc::createLambdaResolver(
// External lookup functor
[&](const std::string &name) {
if (auto Sym = Compilelayer.findSymbol(name, true))
return llvm::Ru...
2009 Oct 03
1
[LLVMdev] LLVM-Kaleidoscope tutorial
...add);
IRBuilder<> builder(block);
Value *tmp = builder.CreateBinOp(Instruction::Mul,
x, y, "tmp");
Value *tmp2 = builder.CreateBinOp(Instruction::Add,
tmp, z, "tmp2");
builder.CreateRet(tmp2);
return mod;
}
__________________________
Remy Demarest
remy.demarest at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091003/045f77c9/attachment.html>
2012 Nov 02
0
[LLVMdev] Instruction does not dominate all uses! <badref> ??
Hi edA-qa mort-ora-y,
On 02/11/12 10:20, edA-qa mort-ora-y wrote:
> I'm having trouble figuring out what the error "Instruction does not
> dominate all uses!" means. I'm trying to construct a call to a function
> with two parameters. The printed IR, with error, looks like this:
>
> define i32 @add(i32, i32) {
> EntryBlock:
> %2 = add i32 %0, %1
>
2009 Oct 03
1
[LLVMdev] code generation goes into an infinite loop
...in_function->arg_begin();
llvm::Value* arg1 = args++;
arg1->setName("argc");
printf("%s:%d make block\n", __FILE__, __LINE__);
llvm::BasicBlock *block = llvm::BasicBlock::Create("entry", main_function);
llvm::IRBuilder<> builder(block);
builder.CreateRet(arg1);
// verify the module
printf("%s:%d verify\n", __FILE__, __LINE__);
verifyModule(*mod, llvm::PrintMessageAction);
// render the module
printf("%s:%d render\n", __FILE__, __LINE__);
llvm::PassManager PM;
llvm::ModulePass *pmp = llvm::createPrintModulePass(0)...