<div dir="ltr">Hi,<div><br></div><div>I define a customized node with customized type. The job of this customized node is to move a value from one register class to another class. I find that if there is no use of the destination register, this node will be deleted from SDAG. For some reasons, I want to keep this node. So I attach mayStore attribute to this node and I hope it will not be deleted. However, it does not work like I assume. There must be something wrong. But I don't know it's because this trick does not work in theory  or it's because my implementation is wrong. </div><div><br></div><div><div>def MoveTy : SDTypeProfile<1, 1, []>;</div><div>def MoveFlag : SDNode<"FOOISD::MOVE_FLAG", MoveTy, [SDNPHasChain, SDNPSideEffect, SDNPMayStore, SDNPMayLoad]>;</div><div><br></div><div>let hasSideEffects = 1, mayStore = 1, mayLoad = 1 in { </div><div>def MOVE : InstFOO<(outs ARegs:$dst), (ins BRegs:$src),</div><div>                    "move $dst, $src",</div><div>                     [(set i32:$dst, (MoveFlag i32:$src))]>;</div></div><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>      InVals.push_back(ArgIn_copy);</div><div>    }</div><div>  }</div></div><div><br></div><div>After checking the recursivelyDeleteUnusedNodes() in DAGCombinner.cpp, this function will delete the unused node and it does not care about the other attributes. </div><div><br></div><div>I must have something wrong. I appreciate if you can point it out. Any suggestion is appreciable.</div><div><br></div><div>Regards,</div><div><br></div><div>Xiangyang</div></div>