[MCA][NFC] Remove redundant calls to std::move.
authorAndrea Di Biagio <andrea.dibiagio@sony.com>
Thu, 26 Aug 2021 18:43:18 +0000 (19:43 +0100)
committerAndrea Di Biagio <andrea.dibiagio@sony.com>
Thu, 26 Aug 2021 18:47:59 +0000 (19:47 +0100)
This fixes some redundant move in return statement [-Wredundant-move] gcc 9.3.0
warnings.

This also fixes a minor coverity issue reported agaist class MCAOperand about
the lack of proper initialization for field Index.

No functional change intended.

llvm/include/llvm/MCA/Instruction.h
llvm/lib/MCA/InstrBuilder.cpp
llvm/lib/MCA/Pipeline.cpp

index 988cddc..326b933 100644 (file)
@@ -46,7 +46,7 @@ class MCAOperand {
     kSFPImmediate, ///< Single-floating-point immediate operand.
     kDFPImmediate, ///< Double-Floating-point immediate operand.
   };
-  MCAOperandType Kind = kInvalid;
+  MCAOperandType Kind;
 
   union {
     unsigned RegVal;
@@ -62,7 +62,8 @@ class MCAOperand {
   unsigned Index;
 
 public:
-  MCAOperand() : FPImmVal(0) {}
+
+  MCAOperand() : Kind(kInvalid), FPImmVal(), Index() {}
 
   bool isValid() const { return Kind != kInvalid; }
   bool isReg() const { return Kind == kRegister; }
index 4067d86..633df8a 100644 (file)
@@ -604,7 +604,7 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI) {
   computeMaxLatency(*ID, MCDesc, SCDesc, STI);
 
   if (Error Err = verifyOperands(MCDesc, MCI))
-    return std::move(Err);
+    return Err;
 
   populateWrites(*ID, MCI, SchedClassID);
   populateReads(*ID, MCI, SchedClassID);
@@ -614,7 +614,7 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI) {
 
   // Sanity check on the instruction descriptor.
   if (Error Err = verifyInstrDesc(*ID, MCI))
-    return std::move(Err);
+    return Err;
 
   // Now add the new descriptor.
   bool IsVariadic = MCDesc.isVariadic();
@@ -707,7 +707,7 @@ InstrBuilder::createInstruction(const MCInst &MCI) {
 
   // Early exit if there are no writes.
   if (D.Writes.empty())
-    return std::move(NewIS);
+    return NewIS;
 
   // Track register writes that implicitly clear the upper portion of the
   // underlying super-registers using an APInt.
@@ -736,7 +736,7 @@ InstrBuilder::createInstruction(const MCInst &MCI) {
     ++WriteIndex;
   }
 
-  return std::move(NewIS);
+  return NewIS;
 }
 } // namespace mca
 } // namespace llvm
index 22b9d07..eb651c3 100644 (file)
@@ -40,7 +40,8 @@ Expected<unsigned> Pipeline::run() {
   do {
     notifyCycleBegin();
     if (Error Err = runCycle())
-      return std::move(Err);
+      return Err;
+
     notifyCycleEnd();
     ++Cycles;
   } while (hasWorkToProcess());