similar to: [LLVMdev] ReplaceInstWithInst problem

Displaying 20 results from an estimated 2000 matches similar to: "[LLVMdev] ReplaceInstWithInst problem"

2013 Dec 05
0
[LLVMdev] Help with replacing instructions via function pass
Hi, In my IR code, I have the following: %arr = alloca [30 x i8], align 1 %arraydecay = getelementptr inbounds [16 x i8]* %arr, i32 0, i32 0 %arraydecay1 = getelementptr inbounds [16 x i8]* %arr, i32 0, i32 0 I'm trying to change the capacity of arr via a function pass. I've written the following code in my function pass: ArrayType* b =
2013 Dec 04
0
[LLVMdev] Quick doubt about IR
Create a new alloca instruction, insert it into the IR right before (or after) the old one, RAUW the value, then delete the old instruction. You should be able to find a variety of examples of this sort of thing in most of the IR level optimization passes. I’d look at InstCombine in particular. -Jim On Dec 4, 2013, at 1:40 PM, Shivam Bhagi <shivam.bhagi at outlook.com> wrote: > Hi,
2013 Dec 04
3
[LLVMdev] Quick doubt about IR
Hi, While looking over the IR generated by my source code, I came across the following: %arr = alloca [30 x i8], align 1 In the source code this particular line of code is represented by: int arr[30]; I was wondering how I could change the capacity of arr from 30 to any other integral value via a function-pass. I know that 'alloca' can be used for reserving space on stack; further,
2013 Jul 25
2
[LLVMdev] Error for AllocaInst and Instruction
Hi, For the following code const Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext()); AllocaInst* newInst = new AllocaInst(Int32Type, 0, "flag", Bb); Bb->getInstList().push_back(newInst); It gives me the error " error: no matching constructor for initialization of 'llvm::AllocaInst' AllocaInst* newInst = new
2011 May 07
1
[LLVMdev] ReplaceInstWithInst appears to invalidate BB iterator?
On May 7, 2011, at 1:00 PM, llvmdev-request at cs.uiuc.edu wrote: > > Hi Justin, > >> 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
2013 Jul 31
1
[LLVMdev] Instruction insertion By Module Pass
Thank you for your help I tried Instruction* p=&( Bb->front()); Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext()); AllocaInst* newInst = new AllocaInst(Int32Type,"flag", p); that works well but I need to store the value of the variable too. What's the method that could be used to store specific value?? On 30 July 2013 16:01, John Criswell
2009 Nov 19
0
[LLVMdev] Strange error using CallInst constructor
Please keep replies on the list. Now you've missed "InputIterator must be a random-access iterator pointing to contiguous storage (e.g. a std::vector<>::iterator). Checks are made for random-accessness but not for contiguous storage as that would incur runtime overhead." from CallInst's constructor (although that comment should be on Create()). Function::arg_iterator
2013 Jul 30
0
[LLVMdev] Instruction insertion By Module Pass
On 7/30/13 7:44 AM, Rasha Omar wrote: > Hi, > I need to insert new instruction into every basic block like x=1 > or while loop > I tried this code, but it doesn't work > > Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext()); > AllocaInst* newInst = new AllocaInst(Int32Type,"flag", Bb); > Bb->getInstList().push_back(newInst); The problem is
2012 Aug 22
1
[LLVMdev] Insert Self Written Function Call from a FunctionPass?
Hello all; So my goal is to insert some (self-written) function calls in the LLVM IR. I can achieve it with a ModulePass and using the getOrInsertFunction() call. For a ModulePass I follow the steps- 1. Compile the code (in which call instructions are to be inserted) to LLVM IR 2. Compile the file (which contains the *called* external function ) to LLVM IR 3. Link them together and run the
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
2013 Jul 30
2
[LLVMdev] Instruction insertion By Module Pass
Hi, I need to insert new instruction into every basic block like x=1 or while loop I tried this code, but it doesn't work Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext()); AllocaInst* newInst = new AllocaInst(Int32Type,"flag", Bb); Bb->getInstList().push_back(newInst); the error: void llvm::SymbolTableListTraits<llvm::Instruction,
2003 Nov 21
2
[LLVMdev] Need Help With Verifier
While it is great that LLVM has an IR Verifier, its a little troublesome to use because it separates the point of detection from the source of the problem. That is, the verifier gets run on a module or function after its been built. By that point, the compiler's state has moved past the point at which the error was placed into the module or function. Trying to track down the source of the
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 =
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,
2012 Jun 17
3
[LLVMdev] BlockAddress instruction is copied instead of cloned during module link?
I have a module having the blockaddress instruction. When I link it into another module and delete the original, blockaddress disappears and is replaced by inttoptr (i32 1 to i8*). Please compile and run the attached program to see the demo of this problem. Right after linking modules, blockaddress still exists: @switch.bbs = internal global [3 x i8*] [i8* blockaddress(@my_func,
2019 Sep 03
2
Get constants of undefined types in IR
Hi Tim, My mistake not including the llvm-dev, excuse me. affinityElement.__bits[0] worked fine for me, thank you. I am new in using the API for Constants and I am facing the error "incomplete type is not allowed" on the last last of below code: Type * ET = IntegerType::getInt64Ty(I.getContext()); unsigned long size = cpuAffinityVector.size(); ArrayType * AT = ArrayType::get(ET,size);
2006 May 17
0
[LLVMdev] Obfuscation with LLVM
Hi all, I was trying to implement an obfuscation tool for C-code on the basis of LLVM. I got a prototype of the simple obfuscation transformation which converting control flow graph to something like a state machine. I am not sure I will have time to work on extending further this tool with new transformations like opaque predicates and decided to put here source code I have by now with hope
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())
2008 Jan 14
1
[LLVMdev] Opaque type
Hello, I'm trying to translate part of Java code in LLVM code. I have some problems with the "opaque type", I think because I did not understand how to use. So, the java code is: int[] ai; .... ai = new int[1]; I am using LLVM API in this way: //I create a pointer of Opaque type, because I don't know yet the array size! OpaqueType* ot = OpaqueType::get(); AllocaInst*