Add 'llvm_unreachable' to passify GCC's understanding of the constraints
authorChandler Carruth <chandlerc@gmail.com>
Tue, 10 Jan 2012 18:08:01 +0000 (18:08 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 10 Jan 2012 18:08:01 +0000 (18:08 +0000)
of several newly un-defaulted switches. This also helps optimizers
(including LLVM's) recognize that every case is covered, and we should
assume as much.

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

13 files changed:
include/llvm/Bitcode/BitCodes.h
include/llvm/Target/TargetLowering.h
lib/AsmParser/LLParser.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/CodeGen/GCMetadata.cpp
lib/CodeGen/LLVMTargetMachine.cpp
lib/CodeGen/MachineInstr.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/CodeGen/Spiller.cpp
lib/MC/MCExpr.cpp
lib/Support/APFloat.cpp
lib/Target/TargetLoweringObjectFile.cpp
lib/VMCore/Verifier.cpp

index fdaec57b51339942c8cd6023a09cb52bed1a6902..fa1325e329fc9167a59d518df4171e483fbbe02a 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Support/ErrorHandling.h"
 #include <cassert>
 
 namespace llvm {
@@ -122,6 +123,7 @@ public:
     case Blob:
       return false;
     }
+    llvm_unreachable("Invalid encoding");
   }
 
   /// isChar6 - Return true if this character is legal in the Char6 encoding.
index c2a1cadbb6707e926a3438cd3788fa44d80f3f84..e3b2ebbfeeeec002a03ef7ed4048425b0c6407e5 100644 (file)
@@ -117,6 +117,7 @@ public:
       // Extend by copying the sign bit.
       return ISD::SIGN_EXTEND;
     }
+    llvm_unreachable("Invalid content kind");
   }
 
   /// NOTE: The constructor takes ownership of TLOF.
index a5072be50a85f198659da46bbfe01cc45db11957..bab4f9d32821cf88ddbfad24f608d2911aff5cb3 100644 (file)
@@ -2549,6 +2549,7 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
       return Error(ID.Loc, "constant expression type mismatch");
     return false;
   }
+  llvm_unreachable("Invalid ValID");
 }
 
 bool LLParser::ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS) {
index a9104ea00a9b973d78d4de86429e2f118aec71ca..b6da85e295739469ac830fc2f9d4172896c3c05a 100644 (file)
@@ -134,6 +134,7 @@ static unsigned GetEncodedOrdering(AtomicOrdering Ordering) {
   case AcquireRelease: return bitc::ORDERING_ACQREL;
   case SequentiallyConsistent: return bitc::ORDERING_SEQCST;
   }
+  llvm_unreachable("Invalid ordering");
 }
 
 static unsigned GetEncodedSynchScope(SynchronizationScope SynchScope) {
@@ -141,6 +142,7 @@ static unsigned GetEncodedSynchScope(SynchronizationScope SynchScope) {
   case SingleThread: return bitc::SYNCHSCOPE_SINGLETHREAD;
   case CrossThread: return bitc::SYNCHSCOPE_CROSSTHREAD;
   }
+  llvm_unreachable("Invalid synch scope");
 }
 
 static void WriteStringRecord(unsigned Code, StringRef Str,
@@ -372,6 +374,7 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
   case GlobalValue::LinkerPrivateWeakLinkage:        return 14;
   case GlobalValue::LinkerPrivateWeakDefAutoLinkage: return 15;
   }
+  llvm_unreachable("Invalid linkage");
 }
 
 static unsigned getEncodedVisibility(const GlobalValue *GV) {
@@ -380,6 +383,7 @@ static unsigned getEncodedVisibility(const GlobalValue *GV) {
   case GlobalValue::HiddenVisibility:    return 1;
   case GlobalValue::ProtectedVisibility: return 2;
   }
+  llvm_unreachable("Invalid visibility");
 }
 
 // Emit top-level description of module, including target triple, inline asm,
index 45a64d2e04316d1b84209a409d49052d55221191..1caf8c233976eb3e47947113a5cc092184627157 100644 (file)
@@ -148,6 +148,7 @@ static const char *DescKind(GC::PointKind Kind) {
     case GC::PreCall:  return "pre-call";
     case GC::PostCall: return "post-call";
   }
+  llvm_unreachable("Invalid point kind");
 }
 
 bool Printer::runOnFunction(Function &F) {
index 28c63a794c0cf0acd9c00ab677d262e56fe31743..a11c55dea3ecb84dd06f4f6d3fde457e01d4ca6f 100644 (file)
@@ -96,6 +96,7 @@ static bool getVerboseAsm() {
   case cl::BOU_TRUE:  return true;
   case cl::BOU_FALSE: return false;
   }
+  llvm_unreachable("Invalid verbose asm state");
 }
 
 // Enable or disable FastISel. Both options are needed, because
index f7a0e102df13f8b7abf295c248dfdd845f013216..99081bdbae1cb9dfbbd9001fb85f0af5bb331d61 100644 (file)
@@ -221,6 +221,7 @@ bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
   case MachineOperand::MO_Metadata:
     return getMetadata() == Other.getMetadata();
   }
+  llvm_unreachable("Invalid machine operand type");
 }
 
 /// print - Print the specified machine operand.
index 8ed13517480d6b6be4f76d86241df029124a13be..bd930d8ef190bf5bc57ca5aca0fb3b3aa4231e50 100644 (file)
@@ -3016,6 +3016,7 @@ static unsigned getConstraintGenerality(TargetLowering::ConstraintType CT) {
   case TargetLowering::C_Memory:
     return 3;
   }
+  llvm_unreachable("Invalid constraint type");
 }
 
 /// Examine constraint type and operand type and determine a weight value.
index ec44d87a20bb112506e13dc6ca8699e77d052b75..260eceab8ab53533fc7ebb1cf5ee58d0680398f5 100644 (file)
@@ -194,4 +194,5 @@ llvm::Spiller* llvm::createSpiller(MachineFunctionPass &pass,
   case trivial: return new TrivialSpiller(pass, mf, vrm);
   case inline_: return createInlineSpiller(pass, mf, vrm);
   }
+  llvm_unreachable("Invalid spiller optimization");
 }
index 00465153b3c813b91d7ecd56e75d3ef6c035015e..455c03d1614d9098163475409f9df085bdee2407 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/MC/MCValue.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
@@ -216,6 +217,7 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
   case VK_Mips_GOT_PAGE: return "GOT_PAGE";
   case VK_Mips_GOT_OFST: return "GOT_OFST";
   }
+  llvm_unreachable("Invalid variant kind");
 }
 
 MCSymbolRefExpr::VariantKind
index f4ca0fb014491eb18b1e187b339da91ea2e11fde..8913dd6def56dbe252d2af2cc154ac643c6020ab 100644 (file)
@@ -1172,6 +1172,7 @@ APFloat::roundAwayFromZero(roundingMode rounding_mode,
   case rmTowardNegative:
     return sign == true;
   }
+  llvm_unreachable("Invalid rounding mode found");
 }
 
 APFloat::opStatus
index 9f2b715481e91bb3d0000b14d6b3c821744b55bc..70abe5a05276158722ef0c7014a6151647ec051e 100644 (file)
@@ -240,6 +240,7 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
   case Constant::GlobalRelocations:
     return SectionKind::getDataRel();
   }
+  llvm_unreachable("Invalid relocation");
 }
 
 /// SectionForGlobal - This method computes the appropriate section to emit
index ad971aa4b49364b799efc6f313546cdf40311b02..ea773b3a62d1f46976b00916f8fce70c93d988d2 100644 (file)
@@ -238,6 +238,7 @@ namespace {
         MessagesStr << "compilation terminated.\n";
         return true;
       }
+      llvm_unreachable("Invalid action");
     }