[llvm] r230141 - Calling memmove on a MachineOperand is totally safe.
Pete Cooper
peter_cooper at apple.com
Sun Feb 22 09:21:11 PST 2015
Ah. No worries then. Thanks for the explanation.
Pete
Sent from my iPhone
> On Feb 22, 2015, at 4:11 AM, Benjamin Kramer <benny.kra at gmail.com> wrote:
>
>
>> On 22.02.2015, at 01:58, Pete Cooper <peter_cooper at apple.com> wrote:
>>
>> Are you sure this is safe? I thought register operands had use lists which memmove isn't going to know to update?
>
> Yes, that's what the other code path in this function does. The path I changed is only used when the MachineInstr containing the operand is not part of a MachineFunction and thus has no use lists.
>
> - Ben
>
>>
>> Pete
>>
>> Sent from my iPhone
>>
>>> On Feb 21, 2015, at 8:22 AM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
>>>
>>> Author: d0k
>>> Date: Sat Feb 21 10:22:48 2015
>>> New Revision: 230141
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=230141&view=rev
>>> Log:
>>> Calling memmove on a MachineOperand is totally safe.
>>>
>>> While it's not POD due to the user-defined constructor, it's still a trivially
>>> copyable type. No functional change.
>>>
>>> Modified:
>>> llvm/trunk/lib/CodeGen/MachineInstr.cpp
>>>
>>> Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=230141&r1=230140&r2=230141&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
>>> +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Sat Feb 21 10:22:48 2015
>>> @@ -674,14 +674,8 @@ static void moveOperands(MachineOperand
>>> if (MRI)
>>> return MRI->moveOperands(Dst, Src, NumOps);
>>>
>>> - // Here it would be convenient to call memmove, so that isn't allowed because
>>> - // MachineOperand has a constructor and so isn't a POD type.
>>> - if (Dst < Src)
>>> - for (unsigned i = 0; i != NumOps; ++i)
>>> - new (Dst + i) MachineOperand(Src[i]);
>>> - else
>>> - for (unsigned i = NumOps; i ; --i)
>>> - new (Dst + i - 1) MachineOperand(Src[i - 1]);
>>> + // MachineOperand is a trivially copyable type so we can just use memmove.
>>> + std::memmove(Dst, Src, NumOps * sizeof(MachineOperand));
>>> }
>>>
>>> /// addOperand - Add the specified operand to the instruction. If it is an
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list