similar to: [LLVMdev] Help needed with creating new and replacing an old instruction

Displaying 20 results from an estimated 300 matches similar to: "[LLVMdev] Help needed with creating new and replacing an old instruction"

2013 Dec 03
1
[LLVMdev] Help with creating and replacing instructions in LLVM
Hi, I have the following instruction in my IR- %call2 = call i8* @strcpy(i8* %1, i8* %2) #2 I intend to change call to strcpy with strncpy. I have included the following code in runOnFunction, so that when it is strcpy's turn to be invoked, strncpy is invoked instead. Assuming I* is the strcpy instruction, CallInst* x=new
2013 Dec 03
0
[LLVMdev] Help needed with creating new and replacing an old instruction
<div><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <div>Hi,</div><div><br></div><div>I have the following instruction in my IR-</div><div><b>%call2 = call i8* @strcpy(i8* %1, i8* %2)</b> #2</div><div><br></div><div>I intend to change call to
2015 Nov 24
2
How to create a sprintf call in IR
Hi, I created a global char array, char buffer[1024]. I want to call a function to append the string information to the buffer repeatedly. For example, I need to implement the following code, where length, a, b, c, are global variables. int length = 0; length += sprintf(buffer+length, "str%d", a); length += sprintf(buffer+length, "str%c", b); length += sprintf(buffer+length,
2011 May 12
0
[LLVMdev] Extract operations as function
Hi Manish, > I am planning to extract every operation as function. > > eg. z=x+y; ==> z=func(x,y,op); > > I wish to write a custom definition of op. Which I would like to define in func. > > It would be really helpful if someone could suggest passes already available in > llvm to look for or point some references how should one proceed on it. I think you should write
2011 May 12
2
[LLVMdev] Extract operations as function
Great!! Thanks Duncan. By step 1 that you mentioned it seems I can write my function func(x,y,op) in mypass.cpp itself. Please elaborate how can add it to the module? On Thu, May 12, 2011 at 1:22 AM, Duncan Sands <baldrick at free.fr> wrote: > Hi Manish, > > > I am planning to extract every operation as function. > > > > eg. z=x+y; ==> z=func(x,y,op); > >
2016 Jun 20
3
function call replacement
Hi everyone, I am trying to replace the call of a certain function with a call to another function. It would for example replace the following: %call = tail call noalias i8* @func(i64 10) by %call = tail call noalias i8* @other_func(i64 10) I managed to declare other_func correctly but I am having troubles to understand how I should proceed to do the replacement. I tried to use
2011 May 12
0
[LLVMdev] Extract operations as function
Hi Manish, > Great!! Thanks Duncan. > By step 1 that you mentioned it seems I can write my function func(x,y,op) in > mypass.cpp itself. Please elaborate how can add it to the module? the minimum is to add a prototype for "func" to the module. For that you can use getOrInsertFunction. If you want to insert the code defining "func" too, then insert the prototype,
2016 Jun 21
3
function call replacement
Hi, Thanks both of you for the help. I just missed that Create function had many optional arguments... sorry for that. However my problem wasn't coming from here (IRBuilder CreateCall function still return a pointer to CallInst so I just added 2 times the call?). I didn't wanted to detail the all issue previously because I knew I had a problem with my syntax. So here's my problem: I
2019 May 17
3
Copy Function from one LLVM IR file to another
Hello everyone, I wanted to copy a function from one file to another. The file that I wanted to copy the function into contains a function with the same name and same number of instructions. I decided to just replace the instructions with those of the other function. I am doing all of this from within a function pass. *1.* I created a function pass in which I extract a function using
2011 May 06
1
[LLVMdev] ReplaceInstWithInst appears to invalidate BB iterator?
Hello, I have a call to ReplaceInstWithInst(Instruction *From, Instruction *To) inside of a for loop iterating through a BasicBlock::iterator. On the very next pass after I replace the instruction, the iterator appears to be invalidated. Is this supposed to happen or am I doing something silly? Is there a more appropriate way to do this? Thanks, -Justin
2015 Jun 18
3
[LLVMdev] problem with replacing an instruction
I am trying to change this define void @main(float* noalias %arg0, float* noalias %arg1, float* noalias %arg2) { entrypoint: %0 = bitcast float* %arg1 to <4 x float>* intothis define void @main(float* noalias %arg0, float* noalias %arg1, float* noalias %arg2) { entrypoint: %0 = getelementptr float* %arg1, i64 0 %1 = bitcast float* %0 to <4 x float>* I must be close but
2011 May 12
2
[LLVMdev] Extract operations as function
Hi, I am planning to extract every operation as function. eg. z=x+y; ==> z=func(x,y,op); I wish to write a custom definition of op. Which I would like to define in func. It would be really helpful if someone could suggest passes already available in llvm to look for or point some references how should one proceed on it. Is codeExtractor.cpp useful for this. I was also thinking of going like
2009 Nov 18
2
[LLVMdev] Strange error using CallInst constructor
Hi, This is probably more of a standard C++ question instead of an actual LLVM question, but here it goes anyway. I'm trying to invoke the following constructor: CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, const Twine &NameStr, BasicBlock *InsertAtEnd); My code is: using namespace llvm; void replaceByClone(Function *f, CallInst *I){ Function *clone =
2016 May 09
4
Some questions about phase ordering in OPT and LLC
Hi, I'm a PhD student doing phase ordering as part of my PhD topic and I would like to ask some questions about LLVM. Executing the following command to see what passes does OPT execute when targeting a SPARC V8 processor: /opt/clang+llvm-3.7.1-x86_64-linux-gnu-ubuntu-15.10/bin/llvm-as < /dev/null | /opt/clang+llvm-3.7.1-x86_64-linux-gnu-ubuntu-15.10/bin/opt -O3 -march=sparc -mcpu=v8
2018 Aug 08
3
Error Calling eraseFromParent()
LLVM is built in Release mode. The version is 6.0.0. I think that a similar code worked on verison 3.9.0. It is probably a null pointer dereference occurring in eraseFromParent(). I checked and reconfirmed that the instruction had no uses. Perhaps I should rebuild LLVM. Thanks. On Wed, Aug 8, 2018 at 9:03 PM, mayuyu.io <admin at mayuyu.io> wrote: > Hmmmm that’s strange. Do you get an
2002 Sep 26
2
[LLVMdev] modify instructions
Hi, I have a question about the modify of instruction: Say I want to modify %a = getelementptr %struct %S, long 0, ubyte 1 into %a.f0 = getelementptr int* %S.f0, long 0 There are 3 ways I can think of to implement, but I'm not sure what should I do. 1. I can use new GetElementPtr to create a new instruction and use ReplaceInstWithInst() function to replace the old one. 2. I can use new
2014 Feb 21
12
[LLVMdev] asan coverage
> > > > We may need some additional info. What kind of additional info? > I haven't put a ton of thought into > this, but I'm hoping we can either (a) use debug info as is or add some > extra (valid) debug info to support this, or (b) add an extra > debug-info-like section to instrumented binaries with the information we > need. > I'd try this data
2013 Jul 31
1
[LLVMdev] Problem to remove successors
Hi All, I need to remove successors from every basic block to insert new ones I tried this code, but it doesn't work void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) { assert(SuccNum < TI->getNumSuccessors() && "Trying to remove a nonexistant successor!"); // If our old successor block contains any PHI nodes, remove the entry in the //
2004 Dec 07
1
[LLVMdev] Question adding dummy basic blocks
Hi, I got a problem when I am trying to add a dummy basic block. Let say there are two blocks, A and B. A----->B I am trying to generate new BB called C which is located between A and B, but not break the edge of AB. The graph is like the following A---->B \ / \ / C There is new BB 'C' with edges AC and CB. It is kind of like what breakcriticaledge pass does.
2013 Nov 26
0
[LLVMdev] Help needed with a pass
I'm a newbie to LLVM and I've really been struggling to write a pass which changes the behavior of the following function: #include<stdlib.h>#include<stdio.h>#include<string.h>void foo(char* bar){const char* path;path=getenv(<SOME_ENV_VAR>); if (path!=NULL){strcpy(bar,path);}else{printf("env_var not set!");}} In the pass, I hope to invoke