search for: getorinsertfunction

Displaying 20 results from an estimated 252 matches for "getorinsertfunction".

2014 May 29
3
[LLVMdev] Module::getOrInsertFunction determinism
Hi All, I’ve got a question about Module::getOrInsertFunction(). I got an impression that it is not deterministic where exactly in the bit code module the new function will be inserted. Is there a way to make it deterministic by explicitly specifying some offset at which the function should be inserted? Please correct me if I’m wrong. Thank you very much in...
2010 Apr 23
2
[LLVMdev] Inserting a varargs function declaration with getOrInsertFunction()?
I need to insert a varargs function declaration from within an LLVM pass. getOrInsertFunction() allows an arbitrary list of type parameters for function arguments to be passed in, but as far as I can tell there is no LLVM "type" to represent the variable-length portion of a function argument list. How is this normally done? --Patrick
2014 Aug 31
2
[LLVMdev] Inserting Calls to var args Functions
...insert my instrumentation code. It works for normal functions for example to insert recordInt32 function below. void recordInt32(int32_t val){ printf("%d, ", val); } I can get recodedInt32 function in my Module using getOrInsert Function. Function* RecordInt32 = cast<Function>(M.getOrInsertFunction("recordInt32", VoidType, Int32Type, NULL)); and insert at desired instPoint using: CallInst::Create(RecordInt32, args, "", instPoint); Wha...
2014 May 29
2
[LLVMdev] Module::getOrInsertFunction determinism
Hi Tim, Thank you very much for quick response. What happens in my case is that mixing calls to getOrInsertFunction with linking another bit code module to the current module seems to be sometimes producing different outputs. Difference might be with the ordering of functions in the file (I¹m looking at LLVM IR representation), with numbers used for constant variables, numbers used in the ³dbg² metadata. Since s...
2014 May 29
2
[LLVMdev] Module::getOrInsertFunction determinism
On 05/29/2014 11:06 AM, Tim Northover wrote: > Hi Tomek, > >> I’ve got a question about Module::getOrInsertFunction(). >> I got an impression that it is not deterministic where exactly in the bit >> code module the new function will be inserted. > Looking at the code (not exhaustively), it seems a new function will > always be added to the end of a module. > > Documenting that probably wo...
2013 Apr 16
2
[LLVMdev] creating and inserting a function with variable arguments
I am working on a pass in which I need to define and insert a function with variable arguments. Can I do it with the help of getOrInsertFunction()? If not can someone tell me any other method? It will be very helpful if anyone can help. Thanks in advance -- *Akshay Jain * -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130416/1974cb5f/attachment.htm...
2013 Jul 25
1
[LLVMdev] Passing String to an external function in llvm
...e help to resolve this issue. testing.cpp is an instrumentation file of llvm, whereas hashtable.cpp is simple c++ code. I want to insert the function named hashtable() (which is already present in hashtable.cpp) after every store instruction. So I have to first DECLARE it, which can be done with getOrInsertFunction() in testing.cpp. Now since declaration of function hashtable() is like void hashtable(string expr) //in hashtable.cpp So in getOrInsertFunction() I have to pass some more details like getOrInsertFunction (name of function in IR, Return type of function, List of argument for the function, et...
2004 Dec 09
1
[LLVMdev] Question about insert call func with pionter parameter
Hi, I got a problem when I am trying to insert a call function with pointer arguments. The function C proto-type is the following, void stat_func(char *); >ConstantArray *Cstr = dyn_cast<ConstantArray>(gI->getInitializer()); ...... >Function *exFunc = M->getOrInsertFunction("stat_func", Type::VoidTy, PointerType::get(Type::SByteTy),0); >std::vector<Value*> Args(1); >Args[0] = constantArray::get(Cstr->getAsString()); >CallInst *call = new CallInst(exFunc, Args,"",InsertPos); If the code look like the above, it could compile succe...
2013 Apr 16
0
[LLVMdev] creating and inserting a function with variable arguments
Akshay Jain <jivan.molu at gmail.com> writes: > I am working on a pass in which I need to define and insert a function with > variable arguments. Can I do it with the help of getOrInsertFunction()? Sure. There is an overload of getOrInsertFunction that takes a FunctionType, and there are FunctionType::get static methods where you say if the function type takes a variable number of arguments. See the doxygen documentation for FunctionType and Module::getOrInsertFunction.
2013 Apr 16
0
[LLVMdev] Name mangling and getOrInsertFunction
...et the file.ll equivalent and I want to replace the original call task (a,b) with a call to one of the other functions, task(a,b,c). The problem is that due to name mangling I cannot find the second function, accepting 3 parameters. I can build the correct FuntionType, but I cannot use the M->getOrInsertFunction, since I cannot get the correct name of the function. Do you have any suggestions on how can I: (i) either retrieve the function name (ii) directly retrieve the function I need, based on its FunctionTy and knowing that the name has a common substring with the other function (or based on the origin...
2018 Mar 17
1
Migration from 3.8 to 6.0 questions (segfault most concerning)
I'm encountering a few problems in my migration that I haven't yet figured out. `getOrInsertFunction` is generating a SEGFAULT at FunctionType::isValidArgumentType(llvm::Type*).  I'm calling it as:     generic_ptr_ = llvm::PointerType::get( llvm::Type::getInt8Ty(context), 0 );     f_natural_int = llvm::IntegerType::get(context, 64);     module->getOrInsertFunction(         "count_mall...
2014 Jun 03
2
[LLVMdev] Module::getOrInsertFunction determinism
...at instruction? It seems to me that cannot rely on >the offset of the instruction within the binary and I cannot rely on the >instruction count. >The problem in my case was that for the same source code base, I was >getting different resulting LLVM IR when doing the same >sequence of getOrInsertFunction and linking with other bit code modules on >each of runs. > >Thank you, >Tomek > >On 29/05/2014 19:34, "Philip Reames" <listmail at philipreames.com> wrote: > >> >>On 05/29/2014 11:06 AM, Tim Northover wrote: >>> Hi Tomek, >>> >&...
2010 Nov 23
1
[LLVMdev] how to get a void type value in llvm
Hi, sivart Thanks for pointing it out. I used it, and it works. Thank you again. BTW, for any later reference, the function prototype declaration with no arguments is not what I wrote: fcall2 = M.getOrInsertFunction("foo", IntegerType::get(M.getContext(), 32), Type::getVoidTy(M.getContext())); INSTEAD, I changed to : fcall2 = M.getOrInsertFunction("foo", FunctionType::get( IntegerType::get(M.getContext(), 32), false)); combining with this, the insertion works finally. Thanks, --Sh...
2010 Nov 23
2
[LLVMdev] how to get a void type value in llvm
Hi, I want to insert a function with a void type parameter, for example: int foo(void); OI declared fcall2 = M.getOrInsertFunction("foo", IntegerType::get(M.getContext(), 32), Type::getVoidTy(M.getContext())); then the question is how to get the void type value to make the CallInst inserted sucessfully? (what should be ********) CallInst::Create(fcall2, ******, "", insertPos); -- --Shuyin...
2012 Apr 10
2
[LLVMdev] How to get the module handle of a .bc file??
Hi all, I want to run a function pass on a certain .bc file. In the process, the pass will insert a check function into the .bc file. I know the .bc file is regarded as a module in LLVM. So, there are two basic steps needed to be done, 1, Use the "getOrInsertFunction"API to add a declaration of the extern "check function". 2, Use the "insertBefore"API to insert the CallInst into the right position. My problem is about the step 1. How can I get the handle of the .bc file (Probably is a Module*)? so I can declare the extern function like...
2014 Oct 27
2
[LLVMdev] How to call a pointer that points to a C function
I have a pointer to a function that I need to invoke without going through llvm::Module::getOrInsertFunction. This example does not work: static int add(int x, int y); llvm::Value *one, *two; llvm::Constant* addfn = llvm::ConstantInt::get(JB->getIntPtrTy(DataLayout), (intptr_t)add); llvm::Type* args[] = { Int32Ty, Int32Ty }; llvm::FunctionType* ftype = llvm::FunctionType::get(Int32Ty, args); addfn...
2006 Mar 03
0
[LLVMdev] Re: Re: New GCC4-based C/C++/ObjC front-end for LLVM
...t.cpp (revision 111673) +++ llvm-convert.cpp (working copy) @@ -795,14 +795,18 @@ void TreeToLLVM::EmitMemCpy(Value *DestP unsigned Align) { const Type *SBP = PointerType::get(Type::SByteTy); static Function *MemCpy = 0; - if (!MemCpy) - MemCpy = TheModule->getOrInsertFunction("llvm.memcpy", Type::VoidTy, SBP, - SBP, Type::UIntTy, Type::UIntTy, + const Type *IntPtr = TD.getIntPtrType(); + if (!MemCpy) { + const char *Name = IntPtr == Type::UIntTy ? + "llvm.memcpy.i32" : "llvm....
2014 Jun 04
3
[LLVMdev] Module::getOrInsertFunction determinism
...ding on your >use case, either might work. (f.y.i. I believe Metadata has changed >radically since earlier versions.) >>> The problem in my case was that for the same source code base, I was >>> getting different resulting LLVM IR when doing the same >>> sequence of getOrInsertFunction and linking with other bit code >>>modules on >>> each of runs. >>> >>> Thank you, >>> Tomek >>> >>> On 29/05/2014 19:34, "Philip Reames" <listmail at philipreames.com> wrote: >>> >>>> On 05/29/2014...
2010 Nov 23
0
[LLVMdev] how to get a void type value in llvm
...: static CallInst* llvm::CallInst::Create ( Value * F, const Twine & NameStr, BasicBlock * InsertAtEnd); Regards On 23/11/2010, at 11:20 AM, Shuying Liang wrote: > Hi, I want to insert a function with a void type parameter, > for example: int foo(void); > OI declared > fcall2 = M.getOrInsertFunction("foo", > IntegerType::get(M.getContext(), 32), > Type::getVoidTy(M.getContext())); > > then the question is how to get the void type value to make the > CallInst inserted sucessfully? (what should be ********) > CallInst::Create(fcall2, ******, "&quot...
2011 May 13
3
[LLVMdev] IO intrinsics?
I found these lines in the BrainF example: //declare i32 @getchar() getchar_func = cast<Function>(module-> getOrInsertFunction("getchar", IntegerType::getInt32Ty(C), NULL)); //declare i32 @putchar(i32) putchar_func = cast<Function>(module-> getOrInsertFunction("putchar", IntegerType::getInt32Ty(C), IntegerType::getInt32Ty(C), NULL)); Since getchar and putcha...