[LLVMdev] Changing basic blocks
Chris Lattner
sabre at nondot.org
Thu Aug 9 15:10:19 PDT 2007
On Thu, 9 Aug 2007, [ISO-8859-1] Emílio Wuerges wrote:
> I too believe it should not be complicated.
> But I was not being able to do it.
> Finally, after some thinking (and tinkering), this worked like a charm:
>
> MachineInstr* mi = BB->remove(BB->begin());
> BB->push_back(mi);
>
> But, is there a better way to do it?
This is a good way to do a single instruction. You can also use the
splice method, which allows you to move around ranges of instructions in
constant time. It works the same was as std::list::splice.
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list