<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 10, 2017, at 7:01 PM, jin chuan see <<a href="mailto:jinchuansee@hotmail.com" class="">jinchuansee@hotmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div class="">Sorry about the previous message<span class="Apple-converted-space"> </span><br class=""><br class=""></div>This message showed up:<br class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div class="">llc: /home/jc/Desktop/Project/For_Testing/llvm/lib/CodeGen/MachineRegisterInfo.cpp:366: llvm::MachineInstr* llvm::MachineRegisterInfo::getVRegDef(unsigned int) const: Assertion `(I.atEnd() || std::next(I) == def_instr_end()) && "getVRegDef assumes a single definition or no definition"' failed.<br class=""></div></div></div></blockquote><div>Earlier backend phases are in "Machine SSA" form (you can check MachineRegisterInfo::isSSA() for that), meaning virtual registers are only allowed to have a single definition.</div><div><br class=""></div><div>- Matthias</div><br class=""><blockquote type="cite" class=""><div class=""><div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class=""><div class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">I am assuming that i messed up the virtual register allocation when i am using BuildMI().</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Also, i cannot invoke the clang as -O1 and so on as it will optimize my code and the generated .ll file will contain nothing other than the prologue and epilogue code.<br class="">Is there any information i can provide you so that we can discuss the issue further?<span class="Apple-converted-space"> </span><br class=""><br class="">Chuan.<span class="Apple-converted-space"> </span><br class=""></div><br class=""><div style="" class=""><hr tabindex="-1" style="display: inline-block; width: 979.015625px;" class=""><div id="divRplyFwdMsg" dir="ltr" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span>jin chuan see <<a href="mailto:jinchuansee@hotmail.com" class="">jinchuansee@hotmail.com</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Monday, September 11, 2017 9:57 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Matthias Braun<br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [llvm-dev] Live Register Spilling</font><div class=""> </div></div><div class=""><div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class="">Hi Matthias,</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Sorry for the late reply. </div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Yes, you are correct, I do have optnone attribute on my function.<span class="Apple-converted-space"> </span><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">I did pass -O0 to the tools. </div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">For your information, my invocations are as below:</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">clang  --target=mips-unknown-linux  -mips32  test.c  -emit-llvm  -S</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">llc  -O0  -march=mips  -mcpu=mips32  test.ll  -o  test.s</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">Based on the generated .ll file, there is optnone attribute on the function, i am guessing this is due to the default optimization -O0 by clang if not specified.</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">As for the llc, i tried to invoke it with -O1,-O2,-O3. All of them resulted in failure during the phase "PROCESS IMPLICIT DEFS"</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">This message showed up:<br class=""></div><br class=""><br class=""><div style="" class=""><hr tabindex="-1" style="display: inline-block; width: 979.015625px;" class=""><div id="divRplyFwdMsg" dir="ltr" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span><a href="mailto:mbraun@apple.com" class="">mbraun@apple.com</a> <<a href="mailto:mbraun@apple.com" class="">mbraun@apple.com</a>> on behalf of Matthias Braun <<a href="mailto:mbraun@apple.com" class="">mbraun@apple.com</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Saturday, September 9, 2017 2:06 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>jin chuan see<br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [llvm-dev] Live Register Spilling</font><div class=""> </div></div><div class=""><div class="">This would be a lot easier to discuss having a concrete example, llc invocations etc.</div><div class=""><br class=""></div><div class="">It sounds like you are using RegAllocFast, have you tried using the optimized register allocators (= make sure you don't have the optnone attribute on your function and are not passing -O0 to the tools).</div><div class=""><br class=""></div><div class="">- Matthias</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Sep 8, 2017, at 12:10 AM, jin chuan see via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="divtagdefaultwrapper" dir="ltr" class="" style="font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;"><div class="" style="margin-top: 0px; margin-bottom: 0px;">Hi All,<span class="Apple-converted-space"> </span><br class=""></div><br class=""><div class="" style="margin-top: 0px; margin-bottom: 0px;">I faced some problems while using the BuildMI().</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">Currently, i am trying to replace specific MI with a series of new MI.</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">I wrote a routine under the processFunctionAfterISel() to detect the targeted MI and replace it accordingly.</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">After using BuildMI() to perform my replacement, i realize there are unnecessary spilling and reloading of registers in the assembly generated.</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">By checking the llc debug output, i am suspecting that the virtual register states have been completely messed up.</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">This is because the spilling and reloading codes are only inserted at the register allocation phase, especially during the state of "Spilling live registers at the end of block".</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">These spilling and reloading codes are messing up the assembly generated, and the behavior of the code generated is undetermined.<span class="Apple-converted-space"> </span><br class=""></div><div class="" style="margin-top: 0px; margin-bottom: 0px;">I would like to know is there anything i can do to fix the virtual register use-def relationship?</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">Or is there any standard procedure i should follow to handle the MachineOperands while using BuildMI()?</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">Any opinions or suggestion are welcomed.<br class=""></div><div class="" style="margin-top: 0px; margin-bottom: 0px;"><br class=""></div><div class="" style="margin-top: 0px; margin-bottom: 0px;">Regards,</div><div class="" style="margin-top: 0px; margin-bottom: 0px;">JC<br class=""></div></div><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline !important;">_______________________________________________</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline !important;">LLVM Developers mailing list</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><a href="mailto:llvm-dev@lists.llvm.org" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">llvm-dev@lists.llvm.org</a><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div></blockquote></div></div></div></div></div></div></div></div></blockquote></div><br class=""></body></html>