[PATCH] D47876: [Mips] Silencing warnings in instruction info (NFC)

Nikola Prica via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 7 04:55:54 PDT 2018


NikolaPrica created this revision.
NikolaPrica added a reviewer: petarj.
Herald added subscribers: atanasyan, arichardson, sdardis.

isORCopyInst and isReadOrWriteToDSPReg functions were producing warning that some statements my fall through.


https://reviews.llvm.org/D47876

Files:
  lib/Target/Mips/MipsSEInstrInfo.cpp


Index: lib/Target/Mips/MipsSEInstrInfo.cpp
===================================================================
--- lib/Target/Mips/MipsSEInstrInfo.cpp
+++ lib/Target/Mips/MipsSEInstrInfo.cpp
@@ -181,31 +181,36 @@
 
 static bool isORCopyInst(const MachineInstr &MI) {
   switch (MI.getOpcode()) {
+  default:
+    break;
   case Mips::OR_MM:
   case Mips::OR:
     if (MI.getOperand(2).getReg() == Mips::ZERO)
       return true;
+    break;
   case Mips::OR64:
     if (MI.getOperand(2).getReg() == Mips::ZERO_64)
       return true;
-  default:
-      return false;
+    break;
   }
+  return false;
 }
 
 /// If @MI is WRDSP/RRDSP instruction return true with @isWrite set to true
 /// if it is WRDSP instruction.
-static bool isReadOrWritToDSPReg(const MachineInstr &MI, bool &isWrite) {
+static bool isReadOrWriteToDSPReg(const MachineInstr &MI, bool &isWrite) {
   switch (MI.getOpcode()) {
-    case Mips::WRDSP:
-    case Mips::WRDSP_MM:
-      isWrite = true;
-    case Mips::RDDSP:
-    case Mips::RDDSP_MM:
-      return true;
-    default:
-     return false;
+  default:
+   return false;
+  case Mips::WRDSP:
+  case Mips::WRDSP_MM:
+    isWrite = true;
+    break;
+  case Mips::RDDSP:
+  case Mips::RDDSP_MM:
+    break;
   }
+  return true;
 }
 
 /// We check for the common case of 'or', as it's MIPS' preferred instruction
@@ -217,7 +222,7 @@
   bool isDSPControlWrite = false;
   // Condition is made to match the creation of WRDSP/RDDSP copy instruction
   // from copyPhysReg function.
-  if (isReadOrWritToDSPReg(MI, isDSPControlWrite)) {
+  if (isReadOrWriteToDSPReg(MI, isDSPControlWrite)) {
     if (!MI.getOperand(1).isImm() || MI.getOperand(1).getImm() != (1<<4))
       return false;
     else if (isDSPControlWrite) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47876.150298.patch
Type: text/x-patch
Size: 1747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180607/35345df5/attachment.bin>


More information about the llvm-commits mailing list