[LLVMdev] insertion points for newly created instructions
John Criswell
criswell at uiuc.edu
Thu Mar 25 13:19:52 PDT 2010
Nuno Lopes wrote:
> 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..
>
I'm a little confused: are you trying to find a place where your new
instruction is dominated by all of the values it uses as operands, are
you trying to find a place where your new instruction dominates all
instructions that use its value, or both?
-- John T.
> Nuno
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list