[LLVMdev] insertion points for newly created instructions
Devang Patel
devang.patel at gmail.com
Thu Mar 25 08:25:36 PDT 2010
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.
> 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.
-
Devang
More information about the llvm-dev
mailing list