[LLVMdev] Is it safe to insert instructions in batches into BBs?

Óscar Fuentes ofv at wanadoo.es
Tue Sep 17 19:40:54 PDT 2013

Marcello Maggioni <marcello at codeplay.com> writes:

> I'm getting a very strange behaviour while adding already created
> instructions in batches into basicblocks instead of creating and
> inserting them immediately.
> Because I need to insert instructions in a certain specific order
> inside multiple different BBs I found it easy to use the IRBuilder to
> create instructions without inserting them into a BB, storing them
> somewhere (vector, map ... etc) and later on inserting all of them in
> one go into their positions in the BBs.
> So , in the end, is it safe to add instructions like in the first
> method I mentioned or actually the only safe way is to use the second
> way? In case it should be safe, what could be the cause of the random
> breakages?
> Cheers,
> Marcello
> PS = Some of the instructions I'm adding are using one the output
> value of the other.

Does your module pass the verifier? (llvm::verifyModule)

More information about the llvm-dev mailing list