[llvm-bugs] [Bug 40079] New: CloneMachineInstr doesn't clone machine instructions' register ties, but claims it does

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 18 05:43:27 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=40079

            Bug ID: 40079
           Summary: CloneMachineInstr doesn't clone machine instructions'
                    register ties, but claims it does
           Product: new-bugs
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: harald at gigawatt.nl
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

CloneMachineInstr creates a new machine instruction by copying all operands one
by one. Copying operands does not preserve all information. In particular,
copying operands one by one does not and cannot preserve register ties.

CloneMachineInstr's documentation suggests that it does preserve register ties:

MachineFunction.cpp:326:
> /// Create a new MachineInstr which is a copy of the 'Orig' instruction,
> /// identical in all ways except the instruction has no parent, prev, or next.

MachineFunction.h:691:
> /// Create a new MachineInstr which is a copy of \p Orig, identical in all
> /// ways except the instruction has no parent, prev, or next. Bundling flags
> /// are reset.
> ///
> /// Note: Clones a single instruction, not whole instruction bundles.
> /// Does not perform target specific adjustments; consider using
> /// TargetInstrInfo::duplicate() instead.

Register ties are not about instruction bundles and not target-specific (even
if the reason for the ties is), so I'm not seeing anything in there to say that
ties should be reset.

Either CloneMachineInstr should document that it does not and should not
preserve this, or it should be fixed so that it does preserve it.

Seen in a project based on LLVM 4.0.1, but checked against git master
(f6775ea3ff7d9b047204560b02db191b6dbfb907):

CloneMachineInstr (MachineFunction.cpp:329) invokes MachineInstr's
copy-like-constructor.
MachineInstr's constructor (MachineInstr.cpp:134) calls addOperand for each of
the source instruction's operands.
addOperand invokes MachineOperand's copy constructor (MachineInstr.cpp:262),
but then explicitly drops ties (MachineInstr.cpp:270) and only sets up ties
again when the instruction is marked so (MachineInstr.cpp:282).

When the source instruction has tied imp-use registers, there is nothing to
restore those ties.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181218/73d9d41a/attachment.html>


More information about the llvm-bugs mailing list