Hi all,<br><br>A week agoo I sent an email about reordering instruction in basicblocks.<br>And ... I was able to do it. I guess so, at least.<br><br>Now when compiling my test program, llc dumps:<br><br>--<br>llc: /home/mentat/llvm_work/llvm/lib/CodeGen/LiveVariables.cpp:155: void llvm::LiveVariables::HandleVirtRegUse(llvm::LiveVariables::VarInfo&, llvm::MachineBasicBlock*, llvm::MachineInstr*): Assertion `VRInfo.DefInst && "Register use before def!"' failed.
<br>llc((anonymous namespace)::PrintStackTrace()+0x1a)[0x86a167a]<br>[0x6]<br>/lib/libc.so.6(abort+0x108)[0x556d9dc8]<br>/lib/libc.so.6(__assert_fail+0xfc)[0x556d1f6c]<br>llc(llvm::LiveVariables::HandleVirtRegUse(llvm::LiveVariables::VarInfo&, llvm::MachineBasicBlock*, llvm::MachineInstr*)+0x15a)[0x84ffb0a]
<br>make: *** [qsort_small.s] Aborted<br>--<br><br>The string "Register use before def!" kinda annoyed me. <br>So I wrote and run this test code, wich -should- just remove all instructions in the basic block and put them back:
<br><br>--<br>int total = BB->size();<br>std::vector<MachineInstr*> positionmap(total);<br>  for (int i = 0; i< total; ++i)<br>    positionmap.push_back(BB->remove(BB->begin()));<br>  for(int i = 0; i< total; ++i)
<br>    BB->push_back(positionmap[i]);<br>--<br><br>And the same error ocurred.<br><br>Then I did this:<br><br>--<br>int total = BB->size();<br>for(int i = 0; i<total; ++i)<br>  BB->push_back(BB->remove(BB->begin()));
<br>--<br><br>And this worked. Flawlessly. Without the error. But this is useless ^_^.<br><br>Can someone help me to understand this behavior?<br><br><br>PS, beware code above, I just tested it, not proven it correct, hehe.
<br><br><div><span class="gmail_quote">2007/8/9, Emílio Wuerges <<a href="mailto:wuerges@gmail.com">wuerges@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For adding the nop:<br><br>TII->insertNoop(*BB, BB->end());<br><br><br><div><span class="gmail_quote">2007/8/9, Chris Lattner <<a href="mailto:sabre@nondot.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
sabre@nondot.org</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><span class="e" id="q_1144d374b8d01981_1">
On Thu, 9 Aug 2007, [ISO-8859-1] Emílio Wuerges wrote:<br>> I too believe it should not be complicated.<br>> But I was not being able to do it.<br>> Finally, after some thinking (and tinkering), this worked like a charm:
<br>><br>>  MachineInstr* mi = BB->remove(BB->begin());<br>>  BB->push_back(mi);<br>><br>> But, is there a better way to do it?<br><br>This is a good way to do a single instruction.  You can also use the
<br>splice method, which allows you to move around ranges of instructions in<br>constant time.  It works the same was as std::list::splice.<br><br>-Chris<br><br>--<br><a href="http://nondot.org/sabre/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://nondot.org/sabre/
</a><br><a href="http://llvm.org/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://llvm.org/</a><br></span></div><span class="q">_______________________________________________<br>LLVM Developers mailing list
<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br><br>
</span></blockquote></div><div><span class="e" id="q_1144d374b8d01981_4"><br><br clear="all"><br>-- <br>Emilio Wuerges<br>LAPS - Laboratorio de Automacao de Projeto de Sistemas
<br>UFSC - Universidade Federal de Santa Catarina<br>Brasil
</span></div></blockquote></div><br><br clear="all"><br>-- <br>Emilio Wuerges<br>LAPS - Laboratorio de Automacao de Projeto de Sistemas<br>UFSC - Universidade Federal de Santa Catarina<br>Brasil