[LLVMdev] insertion points for newly created instructions
Nuno Lopes
nunoplopes at sapo.pt
Thu Mar 25 12:40:34 PDT 2010
Thanks for your reply!
> On Wed, Mar 24, 2010 at 4:16 PM, Nuno Lopes <nunoplopes at sapo.pt> wrote:
>> Hi,
>>
>> I've been scratching my head with a little problem: how to determine the
>> insertion point for a newly created instruction?
>> The operands of these instructions can be defined in different BBs, and
>> they
>> may have several users. Thereby determining where to put those
>> instructions
>> is not obvious. In my case, these instructions don't have side-effects,
>> and
>> so they could be placed anywhere after the definition of the
>> "more-recently-defined" operand, but before the last dominator of all the
>> users.
>>
>> Does LLVM already has any function that will do this (i.e., magically
>> insert
>> an instruction in a valid point)?
>
> There is no magical utility function available to do this.
That's what I was afraid of :)
>> If not, is there any way I can implement
>> this without transversing all the instructions in the enclosing function?
>
> Find a user that dominates all other users and then insert this
> instruction just before the dominating users.
The problem is if none of the users dominates the other ones. That's why I
wanted to somewhat insert the new instruction after the last definition of
the operands. I guess that's a tricky business..
Nuno
More information about the llvm-dev
mailing list