[LLVMdev] removnig instructions with uses
Misha Brukman
brukman at uiuc.edu
Tue Jun 15 15:29:01 PDT 2004
On Tue, Jun 15, 2004 at 03:07:18PM -0500, Patrick Meredith wrote:
> How do you remove an instruction with uses before replacing said uses?
You cannot, here's why:
a = add b, c
d = add a, b
Now if we delete the first instruction that defines a, what do we get?
d = add <invalid>, b
Now try to iterate over the values of this instruction and read their
properties.... You can't, because the instruction is invalid as it's
pointing to deallocated memory. Hence, you must delete uses before
deleting the instruction itself.
This is not to make life difficult for you, it's to keep code
well-formed at all times.
> Opt exits immediately if you do this, it seems like it should wait
> until your pass finishes running. The only way I can get around it
> now is to work recursively post order removing the use before the def,
> which is slower than if I could just remove them in linear order! Oh
> well.
Perhaps you should consider what exactly you are trying to do if this
instruction really does have so many uses... If you are deleting a temporary
instruction, it probably doesn't have such a "deep" tree of uses below it.
--
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
More information about the llvm-dev
mailing list