<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 Jan 31, 2016, at 20:27, Xiangyang Guo via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><br class=""></div><div class="">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 class="">  ....</div><div class=""><div class="">  for (auto &VA : ArgLocs) {</div><div class="">    if (VA.isRegLoc()) {</div><div class="">      // Arguments passed in registers</div><div class="">      EVT RegVT = VA.getLocVT();</div><div class="">      VReg = RegInfo.createVirtualRegister(&FOO::BRegsRegClass);</div><div class="">      RegInfo.addLiveIn(VA.getLocReg(), VReg);</div><div class="">      SDValue ArgIn = DAG.getCopyFromReg(Chain, dl, VReg, RegVT);</div><div class="">      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 class=""></div><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 class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><div class="">      InVals.push_back(ArgIn_copy);</div></div></div></div></blockquote><div><br class=""></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.<br class=""><br class=""></div><div>-Matt</div><br class=""></body></html>