Calling memmove on a MachineOperand is totally safe.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 21 Feb 2015 16:22:48 +0000 (16:22 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 21 Feb 2015 16:22:48 +0000 (16:22 +0000)
While it's not POD due to the user-defined constructor, it's still a trivially
copyable type. No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230141 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineInstr.cpp

index 0514eb6da7209780d6f83f2d383cbdcca2891e73..50c4e814b2ebf58168224dd563e5e40327b3ad7f 100644 (file)
@@ -674,14 +674,8 @@ static void moveOperands(MachineOperand *Dst, MachineOperand *Src,
   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