Avoid generating COPY instructions with TwoAddressInstructionPass for a region of MachineInstr

Hello.
     Is there a way to avoid generating register-COPY instructions with TwoAddressInstructionPass (the one that does "REWRITING TWO-ADDR INSTRS") for a region of my MachineBasicBlock? (It seems that the RegisterCoalescer is not removing every possible COPY?)
     If I use bundles or I predicate the instructions in the respective region (they are actually predicated instructions) would it help?

   Thank you,
     Alex

1 Like

Hello.
     I come back to say that it seems that indeed bundling several instructions helps - the TwoAddressInstructionPass is not generating COPY instructions in the bundle.
     Following the discussion at http://lists.llvm.org/pipermail/llvm-dev/2017-June/113727.html I created a bundle and set the InternalRead flag to true for all operands that are uses of defined operands inside the bundle (I can provide the code for doing this). (This allowed me to avoid the error that I got before with bundles "Bad machine code: Virtual register defs don't dominate all uses." at a pass after TwoAddressInstructionPass).

     But, I get an error from RegisterCoalescer due to one bundle (or several bundles):
       <<llc: /llvm/lib/CodeGen/RegisterCoalescer.cpp:2258: void {anonymous}::JoinVals::computeAssignment(unsigned int, {anonymous}::JoinVals&): Assertion `Other.Vals[V.OtherVNI->id].isAnalyzed() && "Missing recursion"' failed.>>
     The bundles from the program that generate this error seem well formed.

     Did someone already encounter this error? It's difficult for me to understand exactly what is this error.

   Thank you,
     Alex

hello, alex.
I have encountered similar problems recently. Have you found a solution?

Thx
Dw