Hi, when I delete some instruction, I got some error prompt message. - %i.0.reg2mem.0 = phi i32 [ 0, %bb5 ], [ %indvar.next, %bb12 ] ; <i32> [#uses=2] - %s.0.reg2mem.0 = phi i32 [ 0, %bb5 ], [ %tmp16, %bb12 ] ; <i32> [#uses=1] - %tmp14 = tail call i32 @foobar(i32 %i.0.reg2mem.0) nounwind ; <i32> [#uses=1] - %tmp16 = add i32 %tmp14, %s.0.reg2mem.0 ; <i32> [#uses=2] %indvar.next = add i32 %i.0.reg2mem.0, 1 ; <i32> [#uses=2] %exitcond = icmp eq i32 %indvar.next, %n ; <i1> [#uses=1] br i1 %exitcond, label %bb25, label %bb12 For example, I want to delete the instructions above with symbol '-' in front, but when I delete the first one, I got the next prompt message: While deleting: i32 %s.0.reg2mem.0 Use still stuck around after Def is destroyed: %tmp16 = add i32 %tmp14, %s.0.reg2mem.0 ; <i32> [#uses=1] opt: Value.cpp:81: virtual llvm::Value::~Value(): Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed. Program received signal SIGABRT, Aborted. I know I should do some work before the deletion to guarantee that no other instructions will use the instruction being deleted. Who can tell me what I should do? With Best Regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100420/3ca43f3a/attachment.html>
lucefe wrote:> Hi, > > when I delete some instruction, I got some error prompt message.Deleting instructions can be a little tricky. The problem is that you can't delete an instruction until there are no other instructions that are using it. There are two things that you can do: 1) Order your deletions so that the instructions at the end of def-use chains are deleted first; or 2) Replace all uses of the instructions to delete with an Undef value first and then delete the instruction. -- John T.> > - %i.0.reg2mem.0 = phi i32 [ 0, %bb5 ], [ %indvar.next, %bb12 ] ; > <i32> [#uses=2] > - %s.0.reg2mem.0 = phi i32 [ 0, %bb5 ], [ %tmp16, %bb12 ] ; <i32> > [#uses=1] > - %tmp14 = tail call i32 @foobar(i32 %i.0.reg2mem.0) nounwind ; <i32> > [#uses=1] > - %tmp16 = add i32 %tmp14, %s.0.reg2mem.0 ; <i32> [#uses=2] > %indvar.next = add i32 %i.0.reg2mem.0, 1 ; <i32> [#uses=2] > %exitcond = icmp eq i32 %indvar.next, %n ; <i1> [#uses=1] > br i1 %exitcond, label %bb25, label %bb12 > > For example, I want to delete the instructions above with symbol '-' > in front, but when I delete the first one, I got the next prompt message: > > While deleting: i32 %s.0.reg2mem.0 > Use still stuck around after Def is destroyed: %tmp16 = add i32 > %tmp14, %s.0.reg2mem.0 ; <i32> [#uses=1] > opt: Value.cpp:81: virtual llvm::Value::~Value(): Assertion > `use_empty() && "Uses remain when a value is destroyed!"' failed. > > Program received signal SIGABRT, Aborted. > > I know I should do some work before the deletion to guarantee that no > other instructions will use the instruction being deleted. Who can > tell me what I should do? > > With Best Regards! > > > >
I did a simple test just now, but I alse failed. I delete several ordered instructions from end to begin, but after deleting the first instruction(the last instruction of F), the program crashed. My test code is below (F is a function only containing several sequential instructions): for (inst_iterator inst == --inst_end(F); inst != inst_begin(F); --inst) { Instruction * i = &*inst; i->eraseFromParent(); } Best Regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100421/14ae2a33/attachment.html>