[llvm-dev] TableGen customized node with mayStore attribute is deleted if there is no use

Matt Arsenault via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 1 01:12:22 PST 2016

> On Jan 31, 2016, at 20:27, Xiangyang Guo via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 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:
>   ....
>   for (auto &VA : ArgLocs) {
>     if (VA.isRegLoc()) {
>       // Arguments passed in registers
>       EVT RegVT = VA.getLocVT();
>       VReg = RegInfo.createVirtualRegister(&FOO::BRegsRegClass);
>       RegInfo.addLiveIn(VA.getLocReg(), VReg);
>       SDValue ArgIn = DAG.getCopyFromReg(Chain, dl, VReg, RegVT);
>       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

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.

>       InVals.push_back(ArgIn_copy);

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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160201/6809f5c0/attachment.html>

More information about the llvm-dev mailing list