I'm working on translating llvm's optimized intermediate code to another compiler's intermediate code, and I'm working on the PHI instruction.<br><br>Here's an example phi instruction to help explain what I'm trying to do: %inc25 = phi i32 [ 1, %entry ], [ %inc, %for.body ]<br>
<br>What I would want to do here is allocate some memory memory (i'm trying to use %phi1 = alloca  i32, allign 4 ). Then, I want to go to the %entry block and say "store i32  1, i32* %phi1", and in the %for.body I want to add  "store i32  1, i32* %phi1".<br>
<br>So first, I'm iterating through my function and basicblock: <br>    int phi = 0;<br>    Function::iterator func_bblock_itr = func->begin();<br>    for(; func_bblock_itr != func->end(); ++func_bblock_itr)<br>
    {<br>        BasicBlock::iterator bblock_inst_itr = func_bblock_itr->begin();<br>        for(; bblock_inst_itr != func_bblock_itr->end(); ++bblock_inst_itr)<br>        {<br>Then, I look for PHI instructions: <br>
            if(bblock_inst_itr->getOpcode() == Instruction::PHI) {<br>If I find one, I allocate space: <br>                string name = "phi";<br>                name.insert(3,to_string(phi));<br>                Twine tname= Twine(name);<br>
                AllocaInst alloca = AllocaInst(bblock_inst_itr->getOperand(0)->getType(),tname,func_bblock_itr->begin());<br>and then i go through the operands one by one to find where to put store instructions: <br>
                for(unsigned int i = 0; i < bblock_inst_itr->getNumOperands();i++) {<br>                    Value *v = bblock_inst_itr->getOperand(i);<br>Here's where I don't know what to do: I want to create a store instruction in that place<br>
<br>