<div dir="ltr">Thanks, Matt.<div><br></div><div>It works now.</div><div><br></div><div>Regards,</div><div><br></div><div>Xiangyang </div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-01 4:12 GMT-05:00 Matt Arsenault <span dir="ltr"><<a href="mailto:arsenm2@gmail.com" target="_blank">arsenm2@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Jan 31, 2016, at 20:27, Xiangyang Guo via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br></div><div>For example, I add this node into SDAG when I want to move the formal argument from the specific register class to other register class. I implement it in LowerFormalArguments() like this:</div><div>  ....</div><div><div>  for (auto &VA : ArgLocs) {</div><div>    if (VA.isRegLoc()) {</div><div>      // Arguments passed in registers</div><div>      EVT RegVT = VA.getLocVT();</div><div>      VReg = RegInfo.createVirtualRegister(&FOO::BRegsRegClass);</div><div>      RegInfo.addLiveIn(VA.getLocReg(), VReg);</div><div>      SDValue ArgIn = DAG.getCopyFromReg(Chain, dl, VReg, RegVT);</div><div>      SDValue ArgIn_copy = DAG.getNode(FOOISD::MOVE_FLAG , dl, MVT::i32, Chain, ArgIn); // this node is added in order to move the value from BRegs class to ARegs class and I want it be kept even it is not used later on</div></div></div></div></blockquote><div><br></div></span><div>Here if you just want a register class copy, you should create a new virtual register with the other class and use a CopyToReg node. No need for a custom node here.</div><div><br></div><br><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div>      InVals.push_back(ArgIn_copy);</div></div></div></div></blockquote><div><br></div>You are losing the chain. You need to add ArgIn_copy.getValue(1) to a vector, and then the return value of LowerFormalArguments should be a TokenFactor over all of the chains produced.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>-Matt</div><br></font></span></div></blockquote></div><br></div>