similar to: [LLVMdev] creating and inserting a function with variable arguments

Displaying 20 results from an estimated 4000 matches similar to: "[LLVMdev] creating and inserting a function with variable arguments"

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
2013 Apr 16
2
[LLVMdev] creating and inserting a function with variable arguments
I have tried it, but I always end up with some kind of error. Can you explain how can I get a function type for function which returns void (nothing) and it's arguments are (int, int, int, void *, void *, ...) ?? Thanks in advance. On Tue, Apr 16, 2013 at 7:22 AM, Óscar Fuentes <ofv at wanadoo.es> wrote: > Akshay Jain <jivan.molu at gmail.com> writes: > > > I am
2013 Apr 16
0
[LLVMdev] creating and inserting a function with variable arguments
Akshay Jain <jivan.molu at gmail.com> writes: > I have tried it, but I always end up with some kind of error. Can you > explain how can I get a function type for function which returns void > (nothing) and it's arguments are (int, int, int, void *, void *, ...) ?? Instead of getting something to cut&paste, you would be much more enriched if the problematic code and the
2013 Apr 16
1
[LLVMdev] creating and inserting a function with variable arguments
The code that I have written to get the function type is: const std::vector<Type *> ParamTys; ParamTys.push_back(IntegerType::getInt32Ty(Context)); ParamTys.push_back(IntegerType::getInt32Ty(Context)); ParamTys.push_back(IntegerType::getInt32Ty(Context)); ParamTys.push_back(PointerType::get(Type::getVoidTy(Context), 0)); ParamTys.push_back(PointerType::get(Type::getVoidTy(Context), 0));
2014 Aug 31
2
[LLVMdev] Inserting Calls to var args Functions
Hi All, I am using code similar to giri instrumentation <https://github.com/liuml07/giri> framework to 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 =
2011 Mar 31
3
[LLVMdev] inserting exit function into IR
Hi Joshua, I have a function foo and I want to insert exit(0) at the end of foo. The problem is M.getFunction returns null, which is understandable. I am not sure what to do. Below is the code snippet. void foo(int argc, char* argv[]) { printf("hello world\n"); exit(0); //***I want to insert this exit } My llvm code snippet is vector<const Type *> params =
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
2011 Mar 31
0
[LLVMdev] inserting exit function into IR
On Thu, Mar 31, 2011 at 9:31 PM, George Baah <georgebaah at gmail.com> wrote: > Hi Joshua, >       I have a function foo and I want to insert exit(0) at the end of foo. > The problem is M.getFunction returns null, which is understandable. I am not > sure what to do. Below is the code snippet. > void foo(int argc, char* argv[]) { >   printf("hello world\n"); >
2011 Apr 05
3
[LLVMdev] inserting a print statement into IR
Hi Everyone, I am trying to construct the print statement : printf("value:%d\n", value); This is my llvm code. It is seg faulting at builder.CreateGlobalStringPtr(str,""). Thanks. George vector<const Type *> params; params.push_back(Type::getInt8PtrTy(M.getContext())); FunctionType *fType = FunctionType::get(Type::getInt32Ty(M.getContext()), params, true); Constant
2010 Nov 29
3
[LLVMdev] FunctionType as a function argument
Hi all. I would like to declare a function that takes a function pointer as an argument. In C, it would be : void execute(char (*func)(void*), void *param) So, in my compiler, I have : std::vector<const Type *> cbFPtrArgs(1, Type::getInt8PtrTy(C)); FunctionType * cbFPtrTy = FunctionType::get(Type::getInt8Ty(C), cbFPtrArgs, false); Function * func =
2011 Mar 30
2
[LLVMdev] inserting exit function into IR
Hi Everyone, I am trying to insert an exit function into my IR. However, I thought I can get access to exit by using Module.getOrInsertFunction or Module.getFunction. However, I am getting a null value returned. I have searched through the llvmdev archives but not found any thing that addresses this question. Any help will be greatly appreciated. Thanks. George -------------- next part
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,
2012 Feb 01
1
[LLVMdev] Function Insertion Error
Hi, I am trying to insert a function into the LLVM IR. But i get a stack dump exception. My code is as follows.   #include "llvm/Pass.h" #include "llvm/Function.h" #include "llvm/Module.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/IRBuilder.h" using namespace llvm;   namespace {
2013 Nov 26
2
[LLVMdev] Disabling optimizations when using llvm::createPrintModulePass
Hello, using the LLVM API, I've build one very simple function that adds two ConstantInts and returns the result. I noticed that, when I emit IR code, it is optimized to a simple "ret i16 42" when I add 40 and 2. I'd like to see the operations that are necessary to compute the result, though. Can I somehow disable this optimization in the pass, leading to more verbose IR code?
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*>
2008 Aug 19
7
[LLVMdev] Please help with LLVM C++ integration
Hi Gordon, I wrote a small example, but while running I get an error("Tied to execute an unknown external function"), where I am wrong? Thanks in advance. Kirill. int some_test_func( int ){ std::cout << "!!!!" << std::endl; return 8848; } int _tmain(int argc, _TCHAR* argv[]){ Module *M = new Module("test"); ExistingModuleProvider* MP = new
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 Mar 31
0
[LLVMdev] inserting exit function into IR
Hi George, Could you be a more specific about what you are trying to do, how you are trying to do it, and what is failing. A couple of relevant snippets of code would do wonders in helping you. Thanks, Joshua On Wed, Mar 30, 2011 at 3:59 PM, George Baah <georgebaah at gmail.com> wrote: > Hi Everyone, > I am trying to insert an exit function into my IR. > However, I thought
2007 Aug 17
1
[LLVMdev] Inserting trace information during opt transformations
Hi all, In several of the transformations I'm working on I need to embed the logical equivalent of puts/printf/etc. calls inline with code. I am having some difficulties getting the transformation code right. As I understand it, I should be creating a ConstantArray based on the string (in this case I'm taking an instruction, 'disassembling' it to an ostringstream then turning
2011 Apr 05
0
[LLVMdev] inserting a print statement into IR
On 4/4/2011 6:26 PM, George Baah wrote: > Hi Everyone, > I am trying to construct the print statement : printf("value:%d\n", > value); > This is my llvm code. It is seg faulting at > builder.CreateGlobalStringPtr(str,""). This might be easier to debug with a stack trace. Use a debugger to see the call stack when the segfault occurs. Also try to isolate