similar to: [LLVMdev] Insert Self Written Function Call from a FunctionPass?

Displaying 20 results from an estimated 1100 matches similar to: "[LLVMdev] Insert Self Written Function Call from a FunctionPass?"

2011 Nov 19
2
[LLVMdev] Insert a function call in the code
Hello, everyone I am new to LLVM, now I got a problem I want to add a function call before sleep(int a, int b) code below #include <stdio.h> int sleep(int a, int b) { return a+b; } int main(int argc, char **argv) { sleep(1,2); } after use opt -load ../llvm-2.8/Release+Asserts/lib/bishe_insert.so -bishe_insert <1.bc> 2.bc I want get the code #include <stdio.h>
2013 Dec 16
3
[LLVMdev] Add call printf instructions problems
Hello, everyone! I want to write a pass which can insert a call "printf" instructions before every instruction in the LLVM IR. here is what I wrote: namespace { class call_print : public FunctionPass{ private: DenseMap<const Value*, int> inst_map; public: static char ID; call_print() : FunctionPass(ID){} //define a extern function "printf" static llvm::Function*
2013 Dec 16
0
[LLVMdev] Add call printf instructions problems
Hi Jin, It's difficult to say just from looking at a pass, but one thing looked odd: > CallInst *call_print = CallInst::Create(call_print,paramArrayRef,"",ins_temp); This looks very dodgy. The "call_print" being used as an argument is the (uninitialised) one that's just been declared. This could be the source of the assertion failure (though a segfault is just as
2011 Nov 20
0
[LLVMdev] Insert a function call in the code
Thank you for your help I found the problem, as hook() is a no paramter function,so for(Function::arg_iterator i = hook->arg_begin(), e = hook->arg_end(); i != e; ++i) { Args.push_back(i); /////////////Wong } we can add a call by Instruction *newInst = CallInst::Create(hook,
2013 Mar 06
1
[LLVMdev] LLVM load instruction query
Duncan Sands <baldrick <at> free.fr> writes: > > Hi Anshul, > > > I am creating a pass that will pass loaded value by load instruction to an > > external function. > > I don't know how to do it.Please Help. > > your question is too vague for anyone to be able to help you. Add details, > for example provide the code for your pass. > >
2012 Sep 05
1
[LLVMdev] Calling a function with a pointer to a global char array as argument
Hello; Thanks to Eli for the pointer to the ConstantDataArray::getString() fucntion. Now I am trying to declare a global char array with the content "hi" and call a function "print" (which takes a char pointer and return an insteger. I am doing the following in the code - Function Creation: PointerType* array = PointerType::get(IntegerType::getInt8Ty(getGlobalContext())
2013 Dec 17
2
[LLVMdev] Add call printf instructions problems
Thanks,Cheers! I found the problem is that the "Function *call_print" using the same name as the “class call_print”, which made the compiler wrongly resolved the call_print type! But I got another problems. I successfully compile the pass and I can insert the call printf (C Lib function) instructions in the LLVM IR(eg: call.bc). If the call.bc didn't contain call printf
2013 Mar 05
5
[LLVMdev] LLVM load instruction query
HI, I am creating a pass that will pass loaded value by load instruction to an external function. I don't know how to do it.Please Help.
2013 Mar 05
0
[LLVMdev] LLVM load instruction query
Hi Anshul, > I am creating a pass that will pass loaded value by load instruction to an > external function. > I don't know how to do it.Please Help. your question is too vague for anyone to be able to help you. Add details, for example provide the code for your pass. Ciao, Duncan.
2012 May 18
3
[LLVMdev] Adding a New Instruction to LLVM IR
Hello; I was planning to add a new instruction to the LLVM IR (and later to MIPS backend) for TLS(Thread level speculation) support. For this I tried to follow the steps described in http://llvm.org/docs/ExtendingLLVM dot html#instruction. But I could not find any llvm/lib/AsmParser/Lexer.l and llvm/lib/AsmParser/llvmAsmParser.y file in both the svn repository and the source code downloaded
2012 Jul 05
3
[LLVMdev] "symbol lookup error" while running a Simple Loop Pass
Hello; I wrote this simple loop pass to collect the number of instructions in each loop of the program. The code is as follows- #define DEBUG_TYPE "loopinst" #include "llvm/Pass.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Statistic.h" #include "llvm/Instructions.h" #include
2013 Nov 05
1
[LLVMdev] Identifying the instructions that uses a pointer used as a function argument
Thanks for the reply. For the source code: int main() { int a = 0; int *p; p = &a; call_arnamoy(p); int *p1; p1 = p; return 1; } The bit code: %retval = alloca i32, align 4 %a = alloca i32, align 4 %p = alloca i32*, align 8 %p1 = alloca i32*, align 8 store i32 0, i32* %retval store i32 0, i32* %a, align 4 store i32* %a, i32** %p, align 8 %0 = load i32** %p, align 8 %call = call i32
2013 Nov 05
2
[LLVMdev] Identifying the instructions that uses a pointer used as a function argument
Hello all; So here is my goal: *** If there is a Call instruction to myFunction(int * val), I need to identify all the instructions that uses val in the IR and replace the uses with a newly created pointer. I will also be changing the argument of myFunction to the new pointer. int * val = malloc/calloc; ... myFunction(val); .... *val = 45; becomes== int * val = malloc/calloc; int * val1 =
2013 Oct 25
0
[LLVMdev] Question About Function Cloning
Hi Arnamoy, > Any idea, why the output looks like - > Hello World > Hello World > val is 58 > > While the it should print 4 times? Both your loops are sharing the counter variable (%i1) without resetting it to 0 in between calls. I think that accounts for the behaviour. Cheers. Tim.
2012 Sep 05
2
[LLVMdev] llvm::ConstantArray::get(llvm::LLVMContext&, llvm::StringRef, bool) deprecated?
Hi all; I have been trying to use the llvm::ConstantArray::get(llvm::LLVMContext&, llvm::StringRef, bool) function but seems it has been deprecated. ProfileDependence.cpp:68:73: error: no matching function for call to ‘llvm::ConstantArray::get(llvm::LLVMContext&, llvm::StringRef, bool)’ ProfileDependence.cpp:68:73: note: candidate is:
2012 Jun 20
3
[LLVMdev] Is Loop Dependence Analysis Printing Correct Stats?
Hi; I was playing with the -lda pass of LLVM on the following program- #include <stdio.h> void main() { int a[10]; int i; for(i = 0; i < 4; i ++) { a[i] = a[i-1]+1; } } I run the following commands - clang a.c -emit-llvm -S opt -analyze -stats -lda a.s The output is - Printing analysis 'Loop Dependence Analysis': Loop at depth 1, header block: %for.cond Load/store
2013 Nov 05
0
[LLVMdev] Identifying the instructions that uses a pointer used as a function argument
I think I understood the problem you're trying to solve. I didn't, however, understand the problems you are having (maybe you're not running mem2reg?). I do have a little piece of code that I think does (more or less) what you want. Take a look at it, try understanding it, and see if it helps you out. You might have to change it a bit since you're replacing uses after an
2012 Jul 05
1
[LLVMdev] "symbol lookup error" while running a Simple Loop Pass
Hi, > Problem solved. I was building llvm in a separate llvm-build directory. I > built it within the llvm-src directory (which kept all the llvm .so and my > pass' .so in the llvm-src/Release+Asserts/lib directory) to solve the > problem. I do not fully understand what you mean, there should be no difference on building out of source AFAIK. > Can anyone tell me what's
2012 Jul 05
0
[LLVMdev] "symbol lookup error" while running a Simple Loop Pass
Problem solved. I was building llvm in a separate llvm-build directory. I built it within the llvm-src directory (which kept all the llvm .so and my pass' .so in the llvm-src/Release+Asserts/lib directory) to solve the problem. Can anyone tell me what's the difference between writing a pass as a "struct" (as in the tutorial) and as a "class" (as most developers do)?
2013 Oct 25
3
[LLVMdev] Question About Function Cloning
Hello all; I have been writing this LLVM pass that extracts loops in a function and then duplicates the function so the loop is executed twice. The pass executes fine but the produced bit code does not behave correctly as it should (both the original and duplicated function in which the loop is extracted is called, but from the output it seems only one of them is executed.) Here is the source: