search for: setcallingconv

Displaying 20 results from an estimated 71 matches for "setcallingconv".

2016 Jun 20
7
Suggestion / Help regarding new calling convention
...procedural register allocation (IPRA) , we have planned to set callee saved registers to none for local functions, currently I am doing it in following way: if (F->hasLocalLinkage() && !F->hasAddressTaken()) { DEBUG(dbgs() << "Function has LocalLinkage \n"); F->setCallingConv(CallingConv::GHC); } but we think threre should be clean and properway to do this perhaps like: if (F->hasLocalLinkage() && !F->hasAddressTaken()) { DEBUG(dbgs() << "Function has LocalLinkage \n"); F->setCallingConv(CallingConv::NO_Callee_Saved); } So...
2017 Nov 16
2
About mismatching calling conventions
Hi llvm-dev, Every now and then, when building a direct ``CallInst`` either from IRBuilder or through ``Create*``, I have a latent bug because the calling convention (CC) expected by the function is not set on the call, and I need to manually call ``setCallingConv``. Now, from LangRef#calling-conventions, The calling convention of any pair of dynamic caller/callee must match, or the behavior of the program is undefined. So the behavior is correctly defined, as emphasised by the check in ``InstCombineCalls`` that turns mismatching convention into a...
2010 May 11
2
[LLVMdev] How to create Global Variables using LLVM API?
...reate global variables. but it doesn't work. my code looks like this: Module* mod = new Module("test", getGlobalContext()); Constant* c = mod->getOrInsertFunction("main", IntegerType::get(getGlobalContext(), 32), NULL); Function* main = cast<Function> (c); main->setCallingConv(CallingConv::C); Twine s("foo"); StringRef s1("foo"); Constant *cons = ConstantArray::get(getGlobalContext(),s1, true); GlobalVariable val(*mod, (Type*) ArrayType::get(Type::getInt8Ty(getGlobalContext()), 4), true,GlobalValue::ExternalLinkage, cons, s); Application stops runni...
2013 Sep 03
1
[LLVMdev] X86_thiscall
...push_back(any); arguments.push_back(instance_ptr); auto get_interface_type=FunctionType::get(any, arguments, false); interface_group_get_interface=Function::Create(get_interface_type, Function::ExternalLinkage, "get_interface", llvm_module); interface_group_get_interface->setCallingConv(CallingConv::X86_ThisCall); execution_engine->addGlobalMapping(interface_group_get_interface, (void *)as_ptr(&InterfaceGroup::get_interface)); The following call generates the code for the call: vector<Value *> get_interface_args; get_interface_args.push_back(interface_grou...
2011 Sep 16
0
[LLVMdev] How to duplicate a function?
...matched function\n"; } #endif #if 0 // f = M.getOrInsertFunction(StringRef Name, FunctionType *T, AttrListPtr AttributeList); #endif // set the calling convention to C. // so, we interoperate with C Code properly. // Function *tmp = cast<Function>(f); // tmp->setCallingConv(CallingConv::C); Function *tmp = cast<Function>(Fn); tmp->setCallingConv(CallingConv::C); return true; } bool DP::runOnFunction(Function &F) { #if 1 Value *param; // Find the instruction before which you want to insert the function call Instruction *nextInstr...
2013 Apr 23
0
[LLVMdev] LLVM JIT Questions
...fair amount of work because the older JIT engine isn't designed around object loading as the MCJIT engine is. Regarding your second question, there might be more than one way to do this, but once you have an llvm::Function (but before you JIT the code) you should be able to use llvm::Function::setCallingConv(). -Andy -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Dmitri Rubinstein Sent: Tuesday, April 23, 2013 5:25 AM To: LLVM Dev Subject: [LLVMdev] LLVM JIT Questions Hi all, For my current project I need a couple of informations...
2011 Sep 16
2
[LLVMdev] How to duplicate a function?
...he old function, but has an extra argument. FTy = Fn->getFunctionType(); // Find out the return value. RetTy = FTy->getReturnType(); // set the calling convention to C. // so, we interoperate with C Code properly. Function *tmp = cast<Function>(Fn); tmp->setCallingConv(CallingConv::C); return true; } bool DP::runOnFunction(Function &F) { #if 0 Value *param; // Find the instruction before which you want to insert the function call Instruction *nextInstr = F.back().getTerminator(); // Create the actual parameter for the function call...
2011 Apr 05
3
[LLVMdev] inserting a print statement into IR
...)); FunctionType *fType = FunctionType::get(Type::getInt32Ty(M.getContext()), params, true); Constant *temp = M.getOrInsertFunction("printf",fType); if(!temp){ errs() << "printf function not in symbol table\n"; exit(1); } Function *f = cast<Function>(temp); f->setCallingConv(CallingConv::C); const char *str = "value: %d\n"; Value *intparam = ... Value *strPtr = builder.CreateGlobalStringPtr(str,""); builder.CreateCall2(PrintF, strPtr, intparam,"tmp6"); -------------- next part -------------- An HTML attachment was scrubbed... URL: <htt...
2016 Jun 24
2
Suggestion / Help regarding new calling convention
...n (IPRA) , we have > planned to set callee saved registers to none for local functions, > currently I am doing it in following way: > > if (F->hasLocalLinkage() && !F->hasAddressTaken()) { > DEBUG(dbgs() << "Function has LocalLinkage \n"); > F->setCallingConv(CallingConv::GHC); > } > > but we think threre should be clean and properway to do this perhaps like: > > if (F->hasLocalLinkage() && !F->hasAddressTaken()) { > DEBUG(dbgs() << "Function has LocalLinkage \n"); > F->setCallingConv(Callin...
2011 Sep 22
2
[LLVMdev] How to const char* Value for function argument
...callargs.begin(), ConstantInt::get(Type::getInt32Ty(context), call->getNumArgOperands())); callargs.insert(callargs.begin(), callee->getName()); CallInst* newcall = CallInst::Create(launch, callargs, "", call); newcall->takeName(call); newcall->setCallingConv(call->getCallingConv()); newcall->setAttributes(call->getAttributes()); newcall->setDebugLoc(call->getDebugLoc()); call->replaceAllUsesWith(newcall); found = true; break; } The line callargs.insert(callargs.begin(), callee->getName()); is inv...
2013 Apr 23
3
[LLVMdev] LLVM JIT Questions
Hi all, For my current project I need a couple of informations about JIT. I seen similar questions already, but the answers are a bit older and I hope somebody can provide me a recent information. 1. In my project I frequently construct LLVM IR, compile it and execute with JIT. Because the constructed IR is often the same (but can vary depending on input data) I would like to cache produced
2013 Nov 26
2
[LLVMdev] Disabling optimizations when using llvm::createPrintModulePass
...IR: llvm::LLVMContext c; llvm::Module module("test", c); llvm::Type * functionType = llvm::IntegerType::get(c, 16); llvm::Function * llvmFunction = llvm::cast <llvm::Function>(module.getOrInsertFunction("foo", functionType, nullptr)); llvmFunction->setCallingConv(llvm::CallingConv::C); llvm::BasicBlock * body = 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::...
2009 Jan 23
1
[LLVMdev] Problem invoking win32 api calls
...e, SetLastError(unsigned int)) always crash the application due to some kind of stack corruption (Unhandled exception at 0x00000000: 0xC0000005: Access violation reading location 0x00000000.) I'm actually using the CallingConv::X86_StdCall calling convention for these external functions (F->setCallingConv(CallingConv::X86_StdCall);) and that doesn't resolve the issue. Any insight is appreciated. Please let me know if you need more details. Thanks, Vijay -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090...
2010 Apr 28
1
[LLVMdev] LLVM Tutorial 1: Something got wrong?
.../*args*/ IntegerType::get(32), IntegerType::get(32), IntegerType::get(32), /*varargs terminated with null*/ NULL); Function* mul_add = cast<Function>(c); mul_add->setCallingConv(CallingConv::C); ------------------------------------------------------------------- when I change it into the following state, it works out smoothly. Module* makeLLVMModule() { // Module Construction Module* mod = new Module("test", getGlobalContext()); Constant* c = mod->ge...
2013 Oct 28
0
[LLVMdev] __fastcall jitting
Hi, We're using LLVM MCJIT on X86 platform. When calling Function::setCallingConv(CallingConv::X86_StdCall) the jitted code indeed conforms __stdcall convention (instead of default __cdecl). However applying Function::setCallingConv(CallingConv::X86_FastCall) seem does not have proper effect; jitted code is still __stdcall. Is it a bug, or am I missing something? Regards, Mikh...
2017 Jun 08
4
DICompileUnit duplication in LLVM 4.0.0?
...isUsage(AU); } Function *FunctionDuplication::duplicate(Module &M, Function &Old, FunctionType *NewTy) const { Function *New = Function::Create(NewTy, Old.getLinkage(), "", &M); New->setAttributes(Old.getAttributes()); New->setCallingConv(Old.getCallingConv()); // Map old arguments to the new arguments. ValueToValueMapTy VMap; for (auto OldFI = Old.arg_begin(), OldFE = Old.arg_end(), NewFI = New->arg_begin(); OldFI != OldFE; ++OldFI, ++NewFI) { Argument &OldA = *OldFI; Argument &NewA = *N...
2010 May 11
0
[LLVMdev] How to create Global Variables using LLVM API?
...doesn't work. my code looks like this: > > Module* mod = new Module("test", getGlobalContext()); > Constant* c = mod->getOrInsertFunction("main", > IntegerType::get(getGlobalContext(), 32), NULL); > Function* main = cast<Function> (c); > main->setCallingConv(CallingConv::C); > Twine s("foo"); > StringRef s1("foo"); > Constant *cons = ConstantArray::get(getGlobalContext(),s1, true); > GlobalVariable val(*mod, (Type*) > ArrayType::get(Type::getInt8Ty(getGlobalContext()), 4), > true,GlobalValue::ExternalLinkage, cons,...
2009 Nov 05
3
[LLVMdev] create dummy function
...aterials up to date. In the end I got following code, that satisfy my needs: llvm::Constant* c = M.getOrInsertFunction(dummyFunctionName, F.getFunctionType()); llvm::Function* dummy = llvm::cast<llvm::Function>(c); dummy->setLinkage(llvm::Function::ExternalLinkage); dummy->setCallingConv(llvm::CallingConv::C); llvm::BasicBlock* block = llvm::BasicBlock::Create("entry", dummy); // no context needed llvm::IRBuilder builder(block); // no need in <> builder.CreateRetVoid(); Cheers, Oleg. 2009/11/5 Renato Golin <rengolin at systemcall.org>: > 2009/11/...
2007 Apr 06
1
[LLVMdev] Integrating LLVM in an existing project
...PPPersonality = TheModule->getOrInsertFunction("__gxx_personality_v0", Type::getPrimitiveType(Type::VoidTyID), - NULL)); - FuncCPPPersonality->setLinkage(Function::ExternalLinkage); - FuncCPPPersonality->setCallingConv(CallingConv::C); + NULL); - FuncUnwindResume = cast<Function>( + FuncUnwindResume = TheModule->getOrInsertFunction("_Unwind_Resume", Type::getPrimitiveType(Type::VoidTyID),...
2007 Apr 06
0
[LLVMdev] Integrating LLVM in an existing project
On Fri, 6 Apr 2007, Nicolas Geoffray wrote: > Like you say, it's not functional for non-calls instructions. Besides, > having to change all CalInst to InvokeInst is just too much pain in our > current vm. ok. > Actually, why is it missing? What's the difference between the code > generator and the JIT? There are two things missing: 1. Testing and working out the set