Переглянути джерело

Fallthrough (#4843)

A common source of bugs. Although many of these were harmless, some were
not. By eliminating them and enabling this warning as an error, we won't
add more in the future.


Fixed a real SPIRV bug that required a test update to expect the correct behavior.
SPIRV testing was expecting incorrect results that came from a fallthrough error
Greg Roth 2 роки тому
батько
коміт
7ad9c9c032
100 змінених файлів з 293 додано та 178 видалено
  1. 1 1
      cmake/modules/HandleLLVMOptions.cmake
  2. 5 0
      external/CMakeLists.txt
  3. 4 2
      include/dxc/DXIL/DxilSigPoint.inl
  4. 0 1
      include/dxc/Support/WinAdapter.h
  5. 11 0
      include/llvm/Support/Compiler.h
  6. 1 1
      lib/Analysis/BasicAliasAnalysis.cpp
  7. 5 5
      lib/Analysis/InstructionSimplify.cpp
  8. 2 0
      lib/Analysis/MemoryDependenceAnalysis.cpp
  9. 12 6
      lib/Analysis/ScalarEvolution.cpp
  10. 2 1
      lib/Analysis/ValueTracking.cpp
  11. 3 3
      lib/Bitcode/Reader/BitcodeReader.cpp
  12. 11 11
      lib/DXIL/DxilCompType.cpp
  13. 4 2
      lib/DXIL/DxilMetadataHelper.cpp
  14. 1 0
      lib/DXIL/DxilOperations.cpp
  15. 3 3
      lib/DXIL/DxilShaderFlags.cpp
  16. 6 6
      lib/DxilContainer/DxilContainerAssembler.cpp
  17. 1 0
      lib/DxilContainer/RDATDxilSubobjects.cpp
  18. 3 2
      lib/HLSL/DxilContainerReflection.cpp
  19. 3 3
      lib/HLSL/DxilLinker.cpp
  20. 3 2
      lib/HLSL/DxilValidation.cpp
  21. 4 4
      lib/HLSL/HLLowerUDT.cpp
  22. 3 1
      lib/HLSL/HLOperationLower.cpp
  23. 2 0
      lib/HLSL/HLOperations.cpp
  24. 2 2
      lib/IR/ConstantFold.cpp
  25. 3 3
      lib/IR/Function.cpp
  26. 1 0
      lib/IR/InlineAsm.cpp
  27. 2 2
      lib/IR/Value.cpp
  28. 1 1
      lib/Option/OptTable.cpp
  29. 2 0
      lib/Support/APFloat.cpp
  30. 3 0
      lib/Support/CommandLine.cpp
  31. 7 0
      lib/Support/ConvertUTF.c
  32. 2 0
      lib/Support/FoldingSet.cpp
  33. 1 0
      lib/Support/FormattedStream.cpp
  34. 1 0
      lib/Support/GraphWriter.cpp
  35. 1 0
      lib/Support/Path.cpp
  36. 4 0
      lib/Support/YAMLParser.cpp
  37. 4 4
      lib/Support/raw_ostream.cpp
  38. 2 2
      lib/TableGen/TGLexer.cpp
  39. 1 1
      lib/Transforms/IPO/FunctionAttrs.cpp
  40. 1 1
      lib/Transforms/InstCombine/InstCombineCalls.cpp
  41. 7 6
      lib/Transforms/InstCombine/InstCombineCompares.cpp
  42. 1 1
      lib/Transforms/InstCombine/InstCombineShifts.cpp
  43. 1 1
      lib/Transforms/InstCombine/InstructionCombining.cpp
  44. 1 0
      lib/Transforms/Scalar/IndVarSimplify.cpp
  45. 3 3
      lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
  46. 1 0
      lib/Transforms/Scalar/LoopRotation.cpp
  47. 1 1
      lib/Transforms/Scalar/LoopUnswitch.cpp
  48. 1 1
      lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp
  49. 4 4
      lib/Transforms/Utils/SimplifyLibCalls.cpp
  50. 14 14
      projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp
  51. 7 7
      projects/dxilconv/lib/DxbcConverter/DxbcUtil.cpp
  52. 1 0
      tools/clang/lib/AST/ASTContext.cpp
  53. 3 0
      tools/clang/lib/AST/ASTContextHLSL.cpp
  54. 1 0
      tools/clang/lib/AST/ASTDiagnostic.cpp
  55. 1 1
      tools/clang/lib/AST/ASTDumper.cpp
  56. 1 0
      tools/clang/lib/AST/ASTImporter.cpp
  57. 2 2
      tools/clang/lib/AST/Decl.cpp
  58. 3 1
      tools/clang/lib/AST/Expr.cpp
  59. 1 1
      tools/clang/lib/AST/ExprCXX.cpp
  60. 1 1
      tools/clang/lib/AST/ExprClassification.cpp
  61. 6 2
      tools/clang/lib/AST/ExprConstant.cpp
  62. 2 1
      tools/clang/lib/AST/ItaniumMangle.cpp
  63. 1 0
      tools/clang/lib/AST/NestedNameSpecifier.cpp
  64. 1 1
      tools/clang/lib/AST/TypeLoc.cpp
  65. 1 1
      tools/clang/lib/AST/TypePrinter.cpp
  66. 1 1
      tools/clang/lib/Analysis/PseudoConstantAnalysis.cpp
  67. 1 1
      tools/clang/lib/Analysis/ReachableCode.cpp
  68. 2 0
      tools/clang/lib/Basic/IdentifierTable.cpp
  69. 1 0
      tools/clang/lib/Basic/OpenMPKinds.cpp
  70. 2 0
      tools/clang/lib/Basic/TargetInfo.cpp
  71. 7 7
      tools/clang/lib/CodeGen/CGAtomic.cpp
  72. 2 2
      tools/clang/lib/CodeGen/CGCall.cpp
  73. 1 1
      tools/clang/lib/CodeGen/CGClass.cpp
  74. 1 1
      tools/clang/lib/CodeGen/CGExprAgg.cpp
  75. 1 1
      tools/clang/lib/CodeGen/CGExprCXX.cpp
  76. 5 0
      tools/clang/lib/CodeGen/CGExprConstant.cpp
  77. 5 5
      tools/clang/lib/CodeGen/CGExprScalar.cpp
  78. 4 1
      tools/clang/lib/CodeGen/CGHLSLMS.cpp
  79. 1 1
      tools/clang/lib/CodeGen/CGStmt.cpp
  80. 1 0
      tools/clang/lib/CodeGen/CodeGenModule.cpp
  81. 2 2
      tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
  82. 1 1
      tools/clang/lib/Frontend/CompilerInvocation.cpp
  83. 1 1
      tools/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  84. 1 0
      tools/clang/lib/Frontend/SerializedDiagnosticReader.cpp
  85. 1 0
      tools/clang/lib/Index/CommentToXML.cpp
  86. 1 1
      tools/clang/lib/Index/USRGeneration.cpp
  87. 2 1
      tools/clang/lib/Lex/Lexer.cpp
  88. 4 1
      tools/clang/lib/Lex/LiteralSupport.cpp
  89. 14 12
      tools/clang/lib/Parse/ParseCXXInlineMethods.cpp
  90. 8 3
      tools/clang/lib/Parse/ParseDecl.cpp
  91. 2 1
      tools/clang/lib/Parse/ParseDeclCXX.cpp
  92. 7 5
      tools/clang/lib/Parse/ParseExpr.cpp
  93. 1 0
      tools/clang/lib/Parse/ParseInit.cpp
  94. 2 0
      tools/clang/lib/Parse/ParseOpenMP.cpp
  95. 3 3
      tools/clang/lib/Parse/ParseStmt.cpp
  96. 5 3
      tools/clang/lib/Parse/ParseTentative.cpp
  97. 3 2
      tools/clang/lib/Parse/Parser.cpp
  98. 2 1
      tools/clang/lib/Rewrite/HTMLRewrite.cpp
  99. 2 0
      tools/clang/lib/SPIRV/CapabilityVisitor.cpp
  100. 2 1
      tools/clang/lib/SPIRV/DeclResultIdMapper.cpp

+ 1 - 1
cmake/modules/HandleLLVMOptions.cmake

@@ -379,7 +379,7 @@ if( MSVC )
 
 
 elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
 elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
   if (LLVM_ENABLE_WARNINGS)
   if (LLVM_ENABLE_WARNINGS)
-    append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+    append("-Wall -W -Wno-unused-parameter -Wwrite-strings -Wimplicit-fallthrough" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
     append("-Wcast-qual" CMAKE_CXX_FLAGS)
     append("-Wcast-qual" CMAKE_CXX_FLAGS)
 
 
     # Disable unknown pragma warnings because the output is just too long with them.
     # Disable unknown pragma warnings because the output is just too long with them.

+ 5 - 0
external/CMakeLists.txt

@@ -39,6 +39,11 @@ if (${ENABLE_SPIRV_CODEGEN})
 
 
   if (NOT TARGET SPIRV-Tools)
   if (NOT TARGET SPIRV-Tools)
     if (IS_DIRECTORY ${DXC_SPIRV_TOOLS_DIR})
     if (IS_DIRECTORY ${DXC_SPIRV_TOOLS_DIR})
+      # Avoid implicit fallthrough warning from clang
+      # This add_compile_options() will only affect the current directory and its subdirectories.
+      if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+        add_compile_options(-Wno-implicit-fallthrough)
+      endif(NOT WIN32)
       # We only need the library from SPIRV-Tools.
       # We only need the library from SPIRV-Tools.
       set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "Skip building SPIRV-Tools executables")
       set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "Skip building SPIRV-Tools executables")
       if (NOT HLSL_ENABLE_DEBUG_ITERATORS)
       if (NOT HLSL_ENABLE_DEBUG_ITERATORS)

+ 4 - 2
include/dxc/DXIL/DxilSigPoint.inl

@@ -166,11 +166,13 @@ DXIL::SigPointKind SigPoint::GetKind(DXIL::ShaderKind shaderKind, DXIL::Signatur
   if (isSpecialInput) {
   if (isSpecialInput) {
     switch (shaderKind) {
     switch (shaderKind) {
     case DXIL::ShaderKind::Hull:
     case DXIL::ShaderKind::Hull:
-    if (sigKind == DXIL::SignatureKind::Input)
-      return isPatchConstantFunction ? DXIL::SigPointKind::PCIn : DXIL::SigPointKind::HSIn;
+      if (sigKind == DXIL::SignatureKind::Input)
+        return isPatchConstantFunction ? DXIL::SigPointKind::PCIn : DXIL::SigPointKind::HSIn;
+          break;
     case DXIL::ShaderKind::Geometry:
     case DXIL::ShaderKind::Geometry:
       if (sigKind == DXIL::SignatureKind::Input)
       if (sigKind == DXIL::SignatureKind::Input)
         return DXIL::SigPointKind::GSIn;
         return DXIL::SigPointKind::GSIn;
+      break;
     default:
     default:
       break;
       break;
     }
     }

+ 0 - 1
include/dxc/Support/WinAdapter.h

@@ -312,7 +312,6 @@
 
 
 #define _Printf_format_string_
 #define _Printf_format_string_
 #define _Null_terminated_
 #define _Null_terminated_
-#define __fallthrough
 
 
 #define _Field_size_(size)
 #define _Field_size_(size)
 #define _Field_size_full_(size)
 #define _Field_size_full_(size)

+ 11 - 0
include/llvm/Support/Compiler.h

@@ -220,6 +220,17 @@
 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS
 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS
 #endif
 #endif
 
 
+#if __cplusplus > 201402L
+#define LLVM_FALLTHROUGH [[fallthrough]]
+#elif defined(__clang__)
+#define LLVM_FALLTHROUGH [[clang::fallthrough]]
+#elif defined(_MSC_VER)
+#define LLVM_FALLTHROUGH __fallthrough
+#else
+#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
+#endif
+
+
 /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
 /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
 /// pedantic diagnostics.
 /// pedantic diagnostics.
 #ifdef __GNUC__
 #ifdef __GNUC__

+ 1 - 1
lib/Analysis/BasicAliasAnalysis.cpp

@@ -216,7 +216,7 @@ static Value *GetLinearExpression(Value *V, APInt &Scale, APInt &Offset,
         if (!MaskedValueIsZero(BOp->getOperand(0), RHSC->getValue(), DL, 0, AC,
         if (!MaskedValueIsZero(BOp->getOperand(0), RHSC->getValue(), DL, 0, AC,
                                BOp, DT))
                                BOp, DT))
           break;
           break;
-        // FALL THROUGH.
+        LLVM_FALLTHROUGH; // HLSL Change
       case Instruction::Add:
       case Instruction::Add:
         V = GetLinearExpression(BOp->getOperand(0), Scale, Offset, Extension,
         V = GetLinearExpression(BOp->getOperand(0), Scale, Offset, Extension,
                                 DL, Depth + 1, AC, DT);
                                 DL, Depth + 1, AC, DT);

+ 5 - 5
lib/Analysis/InstructionSimplify.cpp

@@ -2721,7 +2721,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
                      Q.CxtI, Q.DT);
                      Q.CxtI, Q.DT);
       if (!KnownNonNegative)
       if (!KnownNonNegative)
         break;
         break;
-      // fall-through
+      LLVM_FALLTHROUGH; // HLSL Change
     case ICmpInst::ICMP_EQ:
     case ICmpInst::ICMP_EQ:
     case ICmpInst::ICMP_UGT:
     case ICmpInst::ICMP_UGT:
     case ICmpInst::ICMP_UGE:
     case ICmpInst::ICMP_UGE:
@@ -2732,7 +2732,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
                      Q.CxtI, Q.DT);
                      Q.CxtI, Q.DT);
       if (!KnownNonNegative)
       if (!KnownNonNegative)
         break;
         break;
-      // fall-through
+      LLVM_FALLTHROUGH; // HLSL Change
     case ICmpInst::ICMP_NE:
     case ICmpInst::ICMP_NE:
     case ICmpInst::ICMP_ULT:
     case ICmpInst::ICMP_ULT:
     case ICmpInst::ICMP_ULE:
     case ICmpInst::ICMP_ULE:
@@ -2752,7 +2752,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
                      Q.CxtI, Q.DT);
                      Q.CxtI, Q.DT);
       if (!KnownNonNegative)
       if (!KnownNonNegative)
         break;
         break;
-      // fall-through
+      LLVM_FALLTHROUGH; // HLSL Change
     case ICmpInst::ICMP_NE:
     case ICmpInst::ICMP_NE:
     case ICmpInst::ICMP_UGT:
     case ICmpInst::ICMP_UGT:
     case ICmpInst::ICMP_UGE:
     case ICmpInst::ICMP_UGE:
@@ -2763,7 +2763,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
                      Q.CxtI, Q.DT);
                      Q.CxtI, Q.DT);
       if (!KnownNonNegative)
       if (!KnownNonNegative)
         break;
         break;
-      // fall-through
+      LLVM_FALLTHROUGH; // HLSL Change
     case ICmpInst::ICMP_EQ:
     case ICmpInst::ICMP_EQ:
     case ICmpInst::ICMP_ULT:
     case ICmpInst::ICMP_ULT:
     case ICmpInst::ICMP_ULE:
     case ICmpInst::ICMP_ULE:
@@ -2823,7 +2823,7 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
     case Instruction::LShr:
     case Instruction::LShr:
       if (ICmpInst::isSigned(Pred))
       if (ICmpInst::isSigned(Pred))
         break;
         break;
-      // fall-through
+      LLVM_FALLTHROUGH; // HLSL Change
     case Instruction::SDiv:
     case Instruction::SDiv:
     case Instruction::AShr:
     case Instruction::AShr:
       if (!LBO->isExact() || !RBO->isExact())
       if (!LBO->isExact() || !RBO->isExact())

+ 2 - 0
lib/Analysis/MemoryDependenceAnalysis.cpp

@@ -641,6 +641,7 @@ MemDepResult MemoryDependenceAnalysis::getPointerDependencyFrom(
       // load query, we can safely ignore it (scan past it).
       // load query, we can safely ignore it (scan past it).
       if (isLoad)
       if (isLoad)
         continue;
         continue;
+      LLVM_FALLTHROUGH; // HLSL Change
     default:
     default:
       // Otherwise, there is a potential dependence.  Return a clobber.
       // Otherwise, there is a potential dependence.  Return a clobber.
       return MemDepResult::getClobber(Inst);
       return MemDepResult::getClobber(Inst);
@@ -1014,6 +1015,7 @@ SortNonLocalDepInfoCache(MemoryDependenceAnalysis::NonLocalDepInfo &Cache,
       std::upper_bound(Cache.begin(), Cache.end()-1, Val);
       std::upper_bound(Cache.begin(), Cache.end()-1, Val);
     Cache.insert(Entry, Val);
     Cache.insert(Entry, Val);
     // FALL THROUGH.
     // FALL THROUGH.
+    LLVM_FALLTHROUGH; // HLSL Change
   }
   }
   case 1:
   case 1:
     // One new entry, Just insert the new value at the appropriate position.
     // One new entry, Just insert the new value at the appropriate position.

+ 12 - 6
lib/Analysis/ScalarEvolution.cpp

@@ -4380,7 +4380,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
       case ICmpInst::ICMP_SLT:
       case ICmpInst::ICMP_SLT:
       case ICmpInst::ICMP_SLE:
       case ICmpInst::ICMP_SLE:
         std::swap(LHS, RHS);
         std::swap(LHS, RHS);
-        // fall through
+        LLVM_FALLTHROUGH; // HLSL Change
       case ICmpInst::ICMP_SGT:
       case ICmpInst::ICMP_SGT:
       case ICmpInst::ICMP_SGE:
       case ICmpInst::ICMP_SGE:
         // a >s b ? a+x : b+x  ->  smax(a, b)+x
         // a >s b ? a+x : b+x  ->  smax(a, b)+x
@@ -4404,7 +4404,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
       case ICmpInst::ICMP_ULT:
       case ICmpInst::ICMP_ULT:
       case ICmpInst::ICMP_ULE:
       case ICmpInst::ICMP_ULE:
         std::swap(LHS, RHS);
         std::swap(LHS, RHS);
-        // fall through
+        LLVM_FALLTHROUGH; // HLSL Change
       case ICmpInst::ICMP_UGT:
       case ICmpInst::ICMP_UGT:
       case ICmpInst::ICMP_UGE:
       case ICmpInst::ICMP_UGE:
         // a >u b ? a+x : b+x  ->  umax(a, b)+x
         // a >u b ? a+x : b+x  ->  umax(a, b)+x
@@ -4458,7 +4458,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
       default:
       default:
         break;
         break;
       }
       }
-    }
+    } break;
 
 
   default: // We cannot analyze this expression.
   default: // We cannot analyze this expression.
     break;
     break;
@@ -6696,6 +6696,7 @@ ScalarEvolution::isKnownPredicateWithRanges(ICmpInst::Predicate Pred,
     llvm_unreachable("Unexpected ICmpInst::Predicate value!");
     llvm_unreachable("Unexpected ICmpInst::Predicate value!");
   case ICmpInst::ICMP_SGT:
   case ICmpInst::ICMP_SGT:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
+    LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_SLT: {
   case ICmpInst::ICMP_SLT: {
     ConstantRange LHSRange = getSignedRange(LHS);
     ConstantRange LHSRange = getSignedRange(LHS);
     ConstantRange RHSRange = getSignedRange(RHS);
     ConstantRange RHSRange = getSignedRange(RHS);
@@ -6707,6 +6708,7 @@ ScalarEvolution::isKnownPredicateWithRanges(ICmpInst::Predicate Pred,
   }
   }
   case ICmpInst::ICMP_SGE:
   case ICmpInst::ICMP_SGE:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
+    LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_SLE: {
   case ICmpInst::ICMP_SLE: {
     ConstantRange LHSRange = getSignedRange(LHS);
     ConstantRange LHSRange = getSignedRange(LHS);
     ConstantRange RHSRange = getSignedRange(RHS);
     ConstantRange RHSRange = getSignedRange(RHS);
@@ -6718,6 +6720,7 @@ ScalarEvolution::isKnownPredicateWithRanges(ICmpInst::Predicate Pred,
   }
   }
   case ICmpInst::ICMP_UGT:
   case ICmpInst::ICMP_UGT:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
+    LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_ULT: {
   case ICmpInst::ICMP_ULT: {
     ConstantRange LHSRange = getUnsignedRange(LHS);
     ConstantRange LHSRange = getUnsignedRange(LHS);
     ConstantRange RHSRange = getUnsignedRange(RHS);
     ConstantRange RHSRange = getUnsignedRange(RHS);
@@ -6729,6 +6732,7 @@ ScalarEvolution::isKnownPredicateWithRanges(ICmpInst::Predicate Pred,
   }
   }
   case ICmpInst::ICMP_UGE:
   case ICmpInst::ICMP_UGE:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
+    LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_ULE: {
   case ICmpInst::ICMP_ULE: {
     ConstantRange LHSRange = getUnsignedRange(LHS);
     ConstantRange LHSRange = getUnsignedRange(LHS);
     ConstantRange RHSRange = getUnsignedRange(RHS);
     ConstantRange RHSRange = getUnsignedRange(RHS);
@@ -7052,6 +7056,7 @@ bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred,
           if (isImpliedCondOperands(Pred, LHS, RHS, V,
           if (isImpliedCondOperands(Pred, LHS, RHS, V,
                                     getConstant(SharperMin)))
                                     getConstant(SharperMin)))
             return true;
             return true;
+          LLVM_FALLTHROUGH; // HLSL Change
 
 
         case ICmpInst::ICMP_SGT:
         case ICmpInst::ICMP_SGT:
         case ICmpInst::ICMP_UGT:
         case ICmpInst::ICMP_UGT:
@@ -7066,7 +7071,7 @@ bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred,
 
 
           if (isImpliedCondOperands(Pred, LHS, RHS, V, getConstant(Min)))
           if (isImpliedCondOperands(Pred, LHS, RHS, V, getConstant(Min)))
             return true;
             return true;
-
+          break;
         default:
         default:
           // No change
           // No change
           break;
           break;
@@ -7163,7 +7168,7 @@ static bool IsKnownPredicateViaMinOrMax(ScalarEvolution &SE,
 
 
   case ICmpInst::ICMP_SGE:
   case ICmpInst::ICMP_SGE:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
-    // fall through
+    LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_SLE:
   case ICmpInst::ICMP_SLE:
     return
     return
       // min(A, ...) <= A
       // min(A, ...) <= A
@@ -7173,7 +7178,7 @@ static bool IsKnownPredicateViaMinOrMax(ScalarEvolution &SE,
 
 
   case ICmpInst::ICMP_UGE:
   case ICmpInst::ICMP_UGE:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
-    // fall through
+    LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_ULE:
   case ICmpInst::ICMP_ULE:
     return
     return
       // min(A, ...) <= A
       // min(A, ...) <= A
@@ -8423,6 +8428,7 @@ ScalarEvolution::computeBlockDisposition(const SCEV *S, const BasicBlock *BB) {
       return DoesNotDominateBlock;
       return DoesNotDominateBlock;
   }
   }
   // FALL THROUGH into SCEVNAryExpr handling.
   // FALL THROUGH into SCEVNAryExpr handling.
+  LLVM_FALLTHROUGH; // HLSL Change
   case scAddExpr:
   case scAddExpr:
   case scMulExpr:
   case scMulExpr:
   case scUMaxExpr:
   case scUMaxExpr:

+ 2 - 1
lib/Analysis/ValueTracking.cpp

@@ -2182,6 +2182,7 @@ bool llvm::ComputeMultiple(Value *V, unsigned Base, Value *&Multiple,
   case Instruction::SExt:
   case Instruction::SExt:
     if (!LookThroughSExt) return false;
     if (!LookThroughSExt) return false;
     // otherwise fall through to ZExt
     // otherwise fall through to ZExt
+    LLVM_FALLTHROUGH; // HLSL Change
   case Instruction::ZExt:
   case Instruction::ZExt:
     return ComputeMultiple(I->getOperand(0), Base, Multiple,
     return ComputeMultiple(I->getOperand(0), Base, Multiple,
                            LookThroughSExt, Depth+1);
                            LookThroughSExt, Depth+1);
@@ -2331,7 +2332,7 @@ bool llvm::CannotBeOrderedLessThanZero(const Value *V, unsigned Depth) {
     // x*x is always non-negative or a NaN.
     // x*x is always non-negative or a NaN.
     if (I->getOperand(0) == I->getOperand(1)) 
     if (I->getOperand(0) == I->getOperand(1)) 
       return true;
       return true;
-    // Fall through
+    LLVM_FALLTHROUGH; // HLSL Change
   case Instruction::FAdd:
   case Instruction::FAdd:
   case Instruction::FDiv:
   case Instruction::FDiv:
   case Instruction::FRem:
   case Instruction::FRem:

+ 3 - 3
lib/Bitcode/Reader/BitcodeReader.cpp

@@ -1863,7 +1863,7 @@ std::error_code BitcodeReader::parseSelectNamedMetadata(ArrayRef<StringRef> Name
     }
     }
     case bitc::METADATA_DISTINCT_NODE:
     case bitc::METADATA_DISTINCT_NODE:
       IsDistinct = true;
       IsDistinct = true;
-      // fallthrough...
+      LLVM_FALLTHROUGH; // HLSL Change
     case bitc::METADATA_NODE: {
     case bitc::METADATA_NODE: {
       SmallVector<Metadata *, 8> Elts;
       SmallVector<Metadata *, 8> Elts;
       Elts.reserve(Record.size());
       Elts.reserve(Record.size());
@@ -2066,7 +2066,7 @@ std::error_code BitcodeReader::parseMetadata() {
     }
     }
     case bitc::METADATA_DISTINCT_NODE:
     case bitc::METADATA_DISTINCT_NODE:
       IsDistinct = true;
       IsDistinct = true;
-      // fallthrough...
+      LLVM_FALLTHROUGH; // HLSL Change
     case bitc::METADATA_NODE: {
     case bitc::METADATA_NODE: {
       SmallVector<Metadata *, 8> Elts;
       SmallVector<Metadata *, 8> Elts;
       Elts.reserve(Record.size());
       Elts.reserve(Record.size());
@@ -2987,7 +2987,7 @@ std::error_code BitcodeReader::parseUseLists() {
       break;
       break;
     case bitc::USELIST_CODE_BB:
     case bitc::USELIST_CODE_BB:
       IsBB = true;
       IsBB = true;
-      // fallthrough
+      LLVM_FALLTHROUGH; // HLSL Change
     case bitc::USELIST_CODE_DEFAULT: {
     case bitc::USELIST_CODE_DEFAULT: {
       unsigned RecordLength = Record.size();
       unsigned RecordLength = Record.size();
       if (RecordLength < 3)
       if (RecordLength < 3)

+ 11 - 11
lib/DXIL/DxilCompType.cpp

@@ -204,22 +204,22 @@ bool CompType::Is16Bit() const {
 CompType CompType::GetBaseCompType() const {
 CompType CompType::GetBaseCompType() const {
   switch (m_Kind) {
   switch (m_Kind) {
   case Kind::I1:        return CompType(Kind::I1);
   case Kind::I1:        return CompType(Kind::I1);
-  case Kind::I16:       __fallthrough;
-  case Kind::PackedS8x32: __fallthrough;
-  case Kind::PackedU8x32: __fallthrough;
+  case Kind::I16:       LLVM_FALLTHROUGH;
+  case Kind::PackedS8x32: LLVM_FALLTHROUGH;
+  case Kind::PackedU8x32: LLVM_FALLTHROUGH;
   case Kind::I32:       return CompType(Kind::I32);
   case Kind::I32:       return CompType(Kind::I32);
   case Kind::I64:       return CompType(Kind::I64);
   case Kind::I64:       return CompType(Kind::I64);
-  case Kind::U16:       __fallthrough;
+  case Kind::U16:       LLVM_FALLTHROUGH;
   case Kind::U32:       return CompType(Kind::U32);
   case Kind::U32:       return CompType(Kind::U32);
   case Kind::U64:       return CompType(Kind::U64);
   case Kind::U64:       return CompType(Kind::U64);
-  case Kind::SNormF16:  __fallthrough;
-  case Kind::UNormF16:  __fallthrough;
-  case Kind::F16:       __fallthrough;
-  case Kind::SNormF32:  __fallthrough;
-  case Kind::UNormF32:  __fallthrough;
+  case Kind::SNormF16:  LLVM_FALLTHROUGH;
+  case Kind::UNormF16:  LLVM_FALLTHROUGH;
+  case Kind::F16:       LLVM_FALLTHROUGH;
+  case Kind::SNormF32:  LLVM_FALLTHROUGH;
+  case Kind::UNormF32:  LLVM_FALLTHROUGH;
   case Kind::F32:       return CompType(Kind::F32);
   case Kind::F32:       return CompType(Kind::F32);
-  case Kind::SNormF64:  __fallthrough;
-  case Kind::UNormF64:  __fallthrough;
+  case Kind::SNormF64:  LLVM_FALLTHROUGH;
+  case Kind::UNormF64:  LLVM_FALLTHROUGH;
   case Kind::F64:       return CompType(Kind::F64);
   case Kind::F64:       return CompType(Kind::F64);
   default:
   default:
     DXASSERT(false, "invalid type kind");
     DXASSERT(false, "invalid type kind");

+ 4 - 2
lib/DXIL/DxilMetadataHelper.cpp

@@ -1348,6 +1348,7 @@ const Function *DxilMDHelper::LoadDxilFunctionProps(const MDTuple *pProps,
   case DXIL::ShaderKind::AnyHit:
   case DXIL::ShaderKind::AnyHit:
   case DXIL::ShaderKind::ClosestHit:
   case DXIL::ShaderKind::ClosestHit:
     bRayAttributes = true;
     bRayAttributes = true;
+    LLVM_FALLTHROUGH;
   case DXIL::ShaderKind::Miss:
   case DXIL::ShaderKind::Miss:
   case DXIL::ShaderKind::Callable:
   case DXIL::ShaderKind::Callable:
     // payload/params unioned and first:
     // payload/params unioned and first:
@@ -1711,6 +1712,7 @@ DxilMDHelper::EmitDxilFunctionProps(const hlsl::DxilFunctionProps *props,
   case DXIL::ShaderKind::AnyHit:
   case DXIL::ShaderKind::AnyHit:
   case DXIL::ShaderKind::ClosestHit:
   case DXIL::ShaderKind::ClosestHit:
     bRayAttributes = true;
     bRayAttributes = true;
+    LLVM_FALLTHROUGH;
   case DXIL::ShaderKind::Miss:
   case DXIL::ShaderKind::Miss:
   case DXIL::ShaderKind::Callable:
   case DXIL::ShaderKind::Callable:
     // payload/params unioned and first:
     // payload/params unioned and first:
@@ -1859,7 +1861,7 @@ Metadata *DxilMDHelper::EmitSubobject(const DxilSubobject &obj) {
   }
   }
   case DXIL::SubobjectKind::LocalRootSignature:
   case DXIL::SubobjectKind::LocalRootSignature:
     bLocalRS = true;
     bLocalRS = true;
-    __fallthrough;
+    LLVM_FALLTHROUGH;
   case DXIL::SubobjectKind::GlobalRootSignature: {
   case DXIL::SubobjectKind::GlobalRootSignature: {
     const char * Text;
     const char * Text;
     const void * Data;
     const void * Data;
@@ -1947,7 +1949,7 @@ void DxilMDHelper::LoadSubobject(const llvm::MDNode &MD, DxilSubobjects &Subobje
   }
   }
   case DXIL::SubobjectKind::LocalRootSignature:
   case DXIL::SubobjectKind::LocalRootSignature:
     bLocalRS = true;
     bLocalRS = true;
-    __fallthrough;
+    LLVM_FALLTHROUGH;
   case DXIL::SubobjectKind::GlobalRootSignature: {
   case DXIL::SubobjectKind::GlobalRootSignature: {
     const MDNode *pDataMDWrapper = dyn_cast<MDNode>(MD.getOperand(i++));
     const MDNode *pDataMDWrapper = dyn_cast<MDNode>(MD.getOperand(i++));
     IFTBOOL(pDataMDWrapper != nullptr, DXC_E_INCORRECT_DXIL_METADATA);
     IFTBOOL(pDataMDWrapper != nullptr, DXC_E_INCORRECT_DXIL_METADATA);

+ 1 - 0
lib/DXIL/DxilOperations.cpp

@@ -458,6 +458,7 @@ unsigned OP::GetTypeSlot(Type *pType) {
     case 32:              return 7;
     case 32:              return 7;
     case 64:              return 8;
     case 64:              return 8;
     }
     }
+    llvm_unreachable("Invalid Bits size");
   }
   }
   case Type::PointerTyID: return 9;
   case Type::PointerTyID: return 9;
   case Type::StructTyID:  return 10;
   case Type::StructTyID:  return 10;

+ 3 - 3
lib/DXIL/DxilShaderFlags.cpp

@@ -481,7 +481,7 @@ ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureLoadOffset1OpIdx)) ||
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureLoadOffset1OpIdx)) ||
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureLoadOffset2OpIdx)))
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureLoadOffset2OpIdx)))
             hasAdvancedTextureOps = true;
             hasAdvancedTextureOps = true;
-          __fallthrough;
+          LLVM_FALLTHROUGH;
         case DXIL::OpCode::BufferLoad: {
         case DXIL::OpCode::BufferLoad: {
           if (hasMulticomponentUAVLoads) continue;
           if (hasMulticomponentUAVLoads) continue;
           // This is the old-style computation (overestimating requirements).
           // This is the old-style computation (overestimating requirements).
@@ -551,7 +551,7 @@ ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureSampleOffset1OpIdx)) ||
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureSampleOffset1OpIdx)) ||
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureSampleOffset2OpIdx)))
               !isa<Constant>(CI->getArgOperand(DXIL::OperandIndex::kTextureSampleOffset2OpIdx)))
             hasAdvancedTextureOps = true;
             hasAdvancedTextureOps = true;
-          __fallthrough;
+          LLVM_FALLTHROUGH;
         case DXIL::OpCode::DerivFineX:
         case DXIL::OpCode::DerivFineX:
         case DXIL::OpCode::DerivFineY:
         case DXIL::OpCode::DerivFineY:
         case DXIL::OpCode::DerivCoarseX:
         case DXIL::OpCode::DerivCoarseX:
@@ -579,7 +579,7 @@ ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
         } break;
         } break;
         case DXIL::OpCode::TextureStoreSample:
         case DXIL::OpCode::TextureStoreSample:
           hasWriteableMSAATextures = true;
           hasWriteableMSAATextures = true;
-          __fallthrough;
+          LLVM_FALLTHROUGH;
         case DXIL::OpCode::SampleCmpLevel:
         case DXIL::OpCode::SampleCmpLevel:
         case DXIL::OpCode::TextureGatherRaw:
         case DXIL::OpCode::TextureGatherRaw:
           hasAdvancedTextureOps = true;
           hasAdvancedTextureOps = true;

+ 6 - 6
lib/DxilContainer/DxilContainerAssembler.cpp

@@ -102,7 +102,7 @@ static DxilProgramSigSemantic KindToSystemValue(Semantic::Kind kind, DXIL::Tesse
   case Semantic::Kind::DepthLessEqual: return DxilProgramSigSemantic::DepthLE;
   case Semantic::Kind::DepthLessEqual: return DxilProgramSigSemantic::DepthLE;
   case Semantic::Kind::DepthGreaterEqual: return DxilProgramSigSemantic::DepthGE;
   case Semantic::Kind::DepthGreaterEqual: return DxilProgramSigSemantic::DepthGE;
   case Semantic::Kind::StencilRef:
   case Semantic::Kind::StencilRef:
-    __fallthrough;
+    LLVM_FALLTHROUGH;
   default:
   default:
     DXASSERT(kind == Semantic::Kind::StencilRef, "else Invalid or switch is missing a case");
     DXASSERT(kind == Semantic::Kind::StencilRef, "else Invalid or switch is missing a case");
     return DxilProgramSigSemantic::StencilRef;
     return DxilProgramSigSemantic::StencilRef;
@@ -127,7 +127,7 @@ static DxilProgramSigCompType CompTypeToSigCompType(hlsl::CompType value, bool i
   case CompType::Kind::U64: return DxilProgramSigCompType::UInt64;
   case CompType::Kind::U64: return DxilProgramSigCompType::UInt64;
   case CompType::Kind::F16: return DxilProgramSigCompType::Float16;
   case CompType::Kind::F16: return DxilProgramSigCompType::Float16;
   case CompType::Kind::F64: return DxilProgramSigCompType::Float64;
   case CompType::Kind::F64: return DxilProgramSigCompType::Float64;
-  case CompType::Kind::Invalid: __fallthrough;
+  case CompType::Kind::Invalid: LLVM_FALLTHROUGH;
   default:
   default:
     return DxilProgramSigCompType::Unknown;
     return DxilProgramSigCompType::Unknown;
   }
   }
@@ -139,13 +139,13 @@ static DxilProgramSigMinPrecision CompTypeToSigMinPrecision(hlsl::CompType value
   case CompType::Kind::U32: return DxilProgramSigMinPrecision::Default;
   case CompType::Kind::U32: return DxilProgramSigMinPrecision::Default;
   case CompType::Kind::F32: return DxilProgramSigMinPrecision::Default;
   case CompType::Kind::F32: return DxilProgramSigMinPrecision::Default;
   case CompType::Kind::I1: return DxilProgramSigMinPrecision::Default;
   case CompType::Kind::I1: return DxilProgramSigMinPrecision::Default;
-  case CompType::Kind::U64: __fallthrough;
-  case CompType::Kind::I64: __fallthrough;
+  case CompType::Kind::U64: LLVM_FALLTHROUGH;
+  case CompType::Kind::I64: LLVM_FALLTHROUGH;
   case CompType::Kind::F64: return DxilProgramSigMinPrecision::Default;
   case CompType::Kind::F64: return DxilProgramSigMinPrecision::Default;
   case CompType::Kind::I16: return DxilProgramSigMinPrecision::SInt16;
   case CompType::Kind::I16: return DxilProgramSigMinPrecision::SInt16;
   case CompType::Kind::U16: return DxilProgramSigMinPrecision::UInt16;
   case CompType::Kind::U16: return DxilProgramSigMinPrecision::UInt16;
   case CompType::Kind::F16: return DxilProgramSigMinPrecision::Float16; // Float2_8 is not supported in DXIL.
   case CompType::Kind::F16: return DxilProgramSigMinPrecision::Float16; // Float2_8 is not supported in DXIL.
-  case CompType::Kind::Invalid: __fallthrough;
+  case CompType::Kind::Invalid: LLVM_FALLTHROUGH;
   default:
   default:
     return DxilProgramSigMinPrecision::Default;
     return DxilProgramSigMinPrecision::Default;
   }
   }
@@ -1142,7 +1142,7 @@ private:
         break;
         break;
       case DXIL::SubobjectKind::LocalRootSignature:
       case DXIL::SubobjectKind::LocalRootSignature:
         bLocalRS = true;
         bLocalRS = true;
-        __fallthrough;
+        LLVM_FALLTHROUGH;
       case DXIL::SubobjectKind::GlobalRootSignature: {
       case DXIL::SubobjectKind::GlobalRootSignature: {
         const void *Data;
         const void *Data;
         obj.GetRootSignature(bLocalRS, Data, info.RootSignature.Data.Size);
         obj.GetRootSignature(bLocalRS, Data, info.RootSignature.Data.Size);

+ 1 - 0
lib/DxilContainer/RDATDxilSubobjects.cpp

@@ -34,6 +34,7 @@ bool LoadSubobjectsFromRDAT(DxilSubobjects &subobjects, const RDAT::DxilRuntimeD
         break;
         break;
       case DXIL::SubobjectKind::LocalRootSignature:
       case DXIL::SubobjectKind::LocalRootSignature:
         bLocalRS = true;
         bLocalRS = true;
+        LLVM_FALLTHROUGH;
       case DXIL::SubobjectKind::GlobalRootSignature:
       case DXIL::SubobjectKind::GlobalRootSignature:
         if (!reader.getRootSignature()) {
         if (!reader.getRootSignature()) {
           result = false;
           result = false;

+ 3 - 2
lib/HLSL/DxilContainerReflection.cpp

@@ -1060,6 +1060,7 @@ HRESULT CShaderReflectionType::Initialize(
       OutputDebugStringA("DxilContainerReflection.cpp: error: unknown matrix orientation\n");
       OutputDebugStringA("DxilContainerReflection.cpp: error: unknown matrix orientation\n");
 #endif
 #endif
     // Note: column-major layout is the default
     // Note: column-major layout is the default
+    LLVM_FALLTHROUGH; // HLSL Change
     case hlsl::MatrixOrientation::Undefined:
     case hlsl::MatrixOrientation::Undefined:
     case hlsl::MatrixOrientation::ColumnMajor:
     case hlsl::MatrixOrientation::ColumnMajor:
       m_Desc.Class = D3D_SVC_MATRIX_COLUMNS;
       m_Desc.Class = D3D_SVC_MATRIX_COLUMNS;
@@ -2682,10 +2683,10 @@ void DxilLibraryReflection::AddResourceDependencies() {
       switch (prevClass) {
       switch (prevClass) {
       case DXIL::ResourceClass::Sampler:
       case DXIL::ResourceClass::Sampler:
         SamplersStart = i;
         SamplersStart = i;
-        __fallthrough;
+        LLVM_FALLTHROUGH;
       case DXIL::ResourceClass::SRV:
       case DXIL::ResourceClass::SRV:
         SRVsStart = i;
         SRVsStart = i;
-        __fallthrough;
+        LLVM_FALLTHROUGH;
       case DXIL::ResourceClass::UAV:
       case DXIL::ResourceClass::UAV:
         UAVsStart = i;
         UAVsStart = i;
         break;
         break;

+ 3 - 3
lib/HLSL/DxilLinker.cpp

@@ -540,10 +540,10 @@ void DxilLinkJob::AddResourceToDM(DxilModule &DM) {
       *ptr = *(static_cast<DxilSampler *>(res));
       *ptr = *(static_cast<DxilSampler *>(res));
       ID = DM.AddSampler(std::move(pSampler));
       ID = DM.AddSampler(std::move(pSampler));
       basePtr = &DM.GetSampler(ID);
       basePtr = &DM.GetSampler(ID);
-    }
+
+    } break;
     default:
     default:
-      DXASSERT(res->GetClass() == DXIL::ResourceClass::Sampler,
-               "else invalid resource");
+      DXASSERT(false, "Invalid resource class");
       break;
       break;
     }
     }
     // Update ID.
     // Update ID.

+ 3 - 2
lib/HLSL/DxilValidation.cpp

@@ -4083,7 +4083,7 @@ static void ValidateSignatureElement(DxilSignatureElement &SE,
   case DXIL::SemanticInterpretationKind::NotInSig:
   case DXIL::SemanticInterpretationKind::NotInSig:
   case DXIL::SemanticInterpretationKind::Invalid:
   case DXIL::SemanticInterpretationKind::Invalid:
     bAllowedInSig = false;
     bAllowedInSig = false;
-    __fallthrough;
+    LLVM_FALLTHROUGH;
   case DXIL::SemanticInterpretationKind::NotPacked:
   case DXIL::SemanticInterpretationKind::NotPacked:
   case DXIL::SemanticInterpretationKind::Shadow:
   case DXIL::SemanticInterpretationKind::Shadow:
     bShouldBeAllocated = false;
     bShouldBeAllocated = false;
@@ -4127,7 +4127,7 @@ static void ValidateSignatureElement(DxilSignatureElement &SE,
     break;
     break;
   case DXIL::SemanticKind::Coverage:
   case DXIL::SemanticKind::Coverage:
     DXASSERT(!SE.IsInput() || !bAllowedInSig, "else internal inconsistency between semantic interpretation table and validation code");
     DXASSERT(!SE.IsInput() || !bAllowedInSig, "else internal inconsistency between semantic interpretation table and validation code");
-    __fallthrough;
+    LLVM_FALLTHROUGH;
   case DXIL::SemanticKind::InnerCoverage:
   case DXIL::SemanticKind::InnerCoverage:
   case DXIL::SemanticKind::OutputControlPointID:
   case DXIL::SemanticKind::OutputControlPointID:
     if (compKind != CompType::Kind::U32 || SE.GetCols() != 1) {
     if (compKind != CompType::Kind::U32 || SE.GetCols() != 1) {
@@ -4569,6 +4569,7 @@ static void ValidateEntrySignatures(ValidationContext &ValCtx,
           Ty = Ty->getPointerElementType();
           Ty = Ty->getPointerElementType();
         attrSize = (unsigned)std::min(DL.getTypeAllocSize(Ty), (uint64_t)UINT_MAX);
         attrSize = (unsigned)std::min(DL.getTypeAllocSize(Ty), (uint64_t)UINT_MAX);
       }
       }
+      LLVM_FALLTHROUGH;
     case DXIL::ShaderKind::Miss:
     case DXIL::ShaderKind::Miss:
     case DXIL::ShaderKind::Callable:
     case DXIL::ShaderKind::Callable:
       if (itPayload != F.arg_end()) {
       if (itPayload != F.arg_end()) {

+ 4 - 4
lib/HLSL/HLLowerUDT.cpp

@@ -316,7 +316,7 @@ void hlsl::ReplaceUsesForLoweredUDT(Value *V, Value *NewV) {
         switch (opcode) {
         switch (opcode) {
         case HLMatLoadStoreOpcode::ColMatLoad:
         case HLMatLoadStoreOpcode::ColMatLoad:
           bColMajor = true;
           bColMajor = true;
-          __fallthrough;
+          LLVM_FALLTHROUGH;
         case HLMatLoadStoreOpcode::RowMatLoad: {
         case HLMatLoadStoreOpcode::RowMatLoad: {
           Value *val = UndefValue::get(
           Value *val = UndefValue::get(
             VectorType::get(NewTy->getArrayElementType(),
             VectorType::get(NewTy->getArrayElementType(),
@@ -354,7 +354,7 @@ void hlsl::ReplaceUsesForLoweredUDT(Value *V, Value *NewV) {
         } break;
         } break;
         case HLMatLoadStoreOpcode::ColMatStore:
         case HLMatLoadStoreOpcode::ColMatStore:
           bColMajor = true;
           bColMajor = true;
-          __fallthrough;
+          LLVM_FALLTHROUGH;
         case HLMatLoadStoreOpcode::RowMatStore: {
         case HLMatLoadStoreOpcode::RowMatStore: {
           // HLCast matrix value to vector
           // HLCast matrix value to vector
           unsigned newOpcode = (unsigned)(bColMajor ?
           unsigned newOpcode = (unsigned)(bColMajor ?
@@ -391,7 +391,7 @@ void hlsl::ReplaceUsesForLoweredUDT(Value *V, Value *NewV) {
           break;
           break;
         case HLSubscriptOpcode::ColMatElement:
         case HLSubscriptOpcode::ColMatElement:
           bColMajor = true;
           bColMajor = true;
-          __fallthrough;
+          LLVM_FALLTHROUGH;
         case HLSubscriptOpcode::RowMatElement: {
         case HLSubscriptOpcode::RowMatElement: {
           ConstantDataSequential *cIdx = cast<ConstantDataSequential>(
           ConstantDataSequential *cIdx = cast<ConstantDataSequential>(
             CI->getArgOperand(HLOperandIndex::kMatSubscriptSubOpIdx));
             CI->getArgOperand(HLOperandIndex::kMatSubscriptSubOpIdx));
@@ -401,7 +401,7 @@ void hlsl::ReplaceUsesForLoweredUDT(Value *V, Value *NewV) {
         } break;
         } break;
         case HLSubscriptOpcode::ColMatSubscript:
         case HLSubscriptOpcode::ColMatSubscript:
           bColMajor = true;
           bColMajor = true;
-          __fallthrough;
+          LLVM_FALLTHROUGH;
         case HLSubscriptOpcode::RowMatSubscript: {
         case HLSubscriptOpcode::RowMatSubscript: {
           for (unsigned Idx = HLOperandIndex::kMatSubscriptSubOpIdx; Idx < CI->getNumArgOperands(); ++Idx) {
           for (unsigned Idx = HLOperandIndex::kMatSubscriptSubOpIdx; Idx < CI->getNumArgOperands(); ++Idx) {
             ElemIndices.emplace_back(CI->getArgOperand(Idx));
             ElemIndices.emplace_back(CI->getArgOperand(Idx));

+ 3 - 1
lib/HLSL/HLOperationLower.cpp

@@ -1108,7 +1108,7 @@ Value *TranslateQuadReadAcross(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
   switch (IOP) {
   switch (IOP) {
   case IntrinsicOp::IOP_QuadReadAcrossX: opKind = DXIL::QuadOpKind::ReadAcrossX; break;
   case IntrinsicOp::IOP_QuadReadAcrossX: opKind = DXIL::QuadOpKind::ReadAcrossX; break;
   case IntrinsicOp::IOP_QuadReadAcrossY: opKind = DXIL::QuadOpKind::ReadAcrossY; break;
   case IntrinsicOp::IOP_QuadReadAcrossY: opKind = DXIL::QuadOpKind::ReadAcrossY; break;
-  default: DXASSERT_NOMSG(IOP == IntrinsicOp::IOP_QuadReadAcrossDiagonal);
+  default: DXASSERT_NOMSG(IOP == IntrinsicOp::IOP_QuadReadAcrossDiagonal); LLVM_FALLTHROUGH;
   case IntrinsicOp::IOP_QuadReadAcrossDiagonal: opKind = DXIL::QuadOpKind::ReadAcrossDiagonal; break;
   case IntrinsicOp::IOP_QuadReadAcrossDiagonal: opKind = DXIL::QuadOpKind::ReadAcrossDiagonal; break;
   }
   }
   Constant *OpArg = hlslOP->GetI8Const((unsigned)opKind);
   Constant *OpArg = hlslOP->GetI8Const((unsigned)opKind);
@@ -8154,8 +8154,10 @@ void TranslateHLBuiltinOperation(Function *F, HLOperationLowerHelper &helper,
           switch (opcode) {
           switch (opcode) {
           case HLCastOpcode::RowMatrixToColMatrix:
           case HLCastOpcode::RowMatrixToColMatrix:
             bColDest = true;
             bColDest = true;
+            LLVM_FALLTHROUGH;
           case HLCastOpcode::ColMatrixToRowMatrix:
           case HLCastOpcode::ColMatrixToRowMatrix:
             bTranspose = true;
             bTranspose = true;
+            LLVM_FALLTHROUGH;
           case HLCastOpcode::ColMatrixToVecCast:
           case HLCastOpcode::ColMatrixToVecCast:
           case HLCastOpcode::RowMatrixToVecCast: {
           case HLCastOpcode::RowMatrixToVecCast: {
             Value *matVal = CI->getArgOperand(HLOperandIndex::kInitFirstArgOpIdx);
             Value *matVal = CI->getArgOperand(HLOperandIndex::kInitFirstArgOpIdx);

+ 2 - 0
lib/HLSL/HLOperations.cpp

@@ -73,6 +73,7 @@ static HLOpcodeGroup GetHLOpcodeGroupInternal(StringRef group) {
       case 'r': // createhandle
       case 'r': // createhandle
         return HLOpcodeGroup::HLCreateHandle;
         return HLOpcodeGroup::HLCreateHandle;
       }
       }
+      llvm_unreachable("unrecognized group code");
     case 'i': // init
     case 'i': // init
       return HLOpcodeGroup::HLInit;
       return HLOpcodeGroup::HLInit;
     case 'b': // binaryOp
     case 'b': // binaryOp
@@ -86,6 +87,7 @@ static HLOpcodeGroup GetHLOpcodeGroupInternal(StringRef group) {
       case 'e':
       case 'e':
         return HLOpcodeGroup::HLSelect;
         return HLOpcodeGroup::HLSelect;
       }
       }
+      llvm_unreachable("unrecognized group code");
     case 'm': // matldst
     case 'm': // matldst
       return HLOpcodeGroup::HLMatLoadStore;
       return HLOpcodeGroup::HLMatLoadStore;
     case 'a': // annotatehandle
     case 'a': // annotatehandle

+ 2 - 2
lib/IR/ConstantFold.cpp

@@ -925,7 +925,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
         // Handle undef ^ undef -> 0 special case. This is a common
         // Handle undef ^ undef -> 0 special case. This is a common
         // idiom (misuse).
         // idiom (misuse).
         return Constant::getNullValue(C1->getType());
         return Constant::getNullValue(C1->getType());
-      // Fallthrough
+      LLVM_FALLTHROUGH; // HLSL Change
     case Instruction::Add:
     case Instruction::Add:
     case Instruction::Sub:
     case Instruction::Sub:
       return UndefValue::get(C1->getType());
       return UndefValue::get(C1->getType());
@@ -1657,7 +1657,7 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2,
           }
           }
         }
         }
       }
       }
-    }
+    } break;
     default:
     default:
       break;
       break;
     }
     }

+ 3 - 3
lib/IR/Function.cpp

@@ -705,9 +705,9 @@ static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
   case IIT_EMPTYSTRUCT:
   case IIT_EMPTYSTRUCT:
     OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
     OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
     return;
     return;
-  case IIT_STRUCT5: ++StructElts; // FALL THROUGH.
-  case IIT_STRUCT4: ++StructElts; // FALL THROUGH.
-  case IIT_STRUCT3: ++StructElts; // FALL THROUGH.
+  case IIT_STRUCT5: ++StructElts; LLVM_FALLTHROUGH; // HLSL Change
+  case IIT_STRUCT4: ++StructElts; LLVM_FALLTHROUGH; // HLSL Change
+  case IIT_STRUCT3: ++StructElts; LLVM_FALLTHROUGH; // HLSL Change
   case IIT_STRUCT2: {
   case IIT_STRUCT2: {
     OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
     OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
 
 

+ 1 - 0
lib/IR/InlineAsm.cpp

@@ -264,6 +264,7 @@ bool InlineAsm::Verify(FunctionType *Ty, StringRef ConstStr) {
       }
       }
       ++NumIndirect;
       ++NumIndirect;
       // FALLTHROUGH for Indirect Outputs.
       // FALLTHROUGH for Indirect Outputs.
+      LLVM_FALLTHROUGH; // HLSL Change
     case InlineAsm::isInput:
     case InlineAsm::isInput:
       if (NumClobbers) return false;               // inputs before clobbers.
       if (NumClobbers) return false;               // inputs before clobbers.
       ++NumInputs;
       ++NumInputs;

+ 2 - 2
lib/IR/Value.cpp

@@ -439,7 +439,7 @@ static Value *stripPointerCastsAndOffsets(Value *V) {
       case PSK_InBoundsConstantIndices:
       case PSK_InBoundsConstantIndices:
         if (!GEP->hasAllConstantIndices())
         if (!GEP->hasAllConstantIndices())
           return V;
           return V;
-        // fallthrough
+        LLVM_FALLTHROUGH; // HLSL Change
       case PSK_InBounds:
       case PSK_InBounds:
         if (!GEP->isInBounds())
         if (!GEP->isInBounds())
           return V;
           return V;
@@ -731,7 +731,7 @@ void ValueHandleBase::ValueIsRAUWd(Value *Old, Value *New) {
       // virtual (or inline) interface to handle this though, so instead we make
       // virtual (or inline) interface to handle this though, so instead we make
       // the TrackingVH accessors guarantee that a client never sees this value.
       // the TrackingVH accessors guarantee that a client never sees this value.
 
 
-      // FALLTHROUGH
+      LLVM_FALLTHROUGH; // HLSL CHANGE
     case Weak:
     case Weak:
       // Weak goes to the new value, which will unlink it from Old's list.
       // Weak goes to the new value, which will unlink it from Old's list.
       Entry->operator=(New);
       Entry->operator=(New);

+ 1 - 1
lib/Option/OptTable.cpp

@@ -348,7 +348,7 @@ static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) {
   case Option::SeparateClass: case Option::JoinedOrSeparateClass:
   case Option::SeparateClass: case Option::JoinedOrSeparateClass:
   case Option::RemainingArgsClass:
   case Option::RemainingArgsClass:
     Name += ' ';
     Name += ' ';
-    // FALLTHROUGH
+    LLVM_FALLTHROUGH; // HLSL Change
   case Option::JoinedClass: case Option::CommaJoinedClass:
   case Option::JoinedClass: case Option::CommaJoinedClass:
   case Option::JoinedAndSeparateClass:
   case Option::JoinedAndSeparateClass:
     if (const char *MetaVarName = Opts.getOptionMetaVar(Id))
     if (const char *MetaVarName = Opts.getOptionMetaVar(Id))

+ 2 - 0
lib/Support/APFloat.cpp

@@ -1554,11 +1554,13 @@ APFloat::divideSpecials(const APFloat &rhs)
   case PackCategoriesIntoKey(fcInfinity, fcNaN):
   case PackCategoriesIntoKey(fcInfinity, fcNaN):
     category = fcNaN;
     category = fcNaN;
     copySignificand(rhs);
     copySignificand(rhs);
+    LLVM_FALLTHROUGH; // HLSL Change
   case PackCategoriesIntoKey(fcNaN, fcZero):
   case PackCategoriesIntoKey(fcNaN, fcZero):
   case PackCategoriesIntoKey(fcNaN, fcNormal):
   case PackCategoriesIntoKey(fcNaN, fcNormal):
   case PackCategoriesIntoKey(fcNaN, fcInfinity):
   case PackCategoriesIntoKey(fcNaN, fcInfinity):
   case PackCategoriesIntoKey(fcNaN, fcNaN):
   case PackCategoriesIntoKey(fcNaN, fcNaN):
     sign = false;
     sign = false;
+    LLVM_FALLTHROUGH; // HLSL Change
   case PackCategoriesIntoKey(fcInfinity, fcZero):
   case PackCategoriesIntoKey(fcInfinity, fcZero):
   case PackCategoriesIntoKey(fcInfinity, fcNormal):
   case PackCategoriesIntoKey(fcInfinity, fcNormal):
   case PackCategoriesIntoKey(fcZero, fcInfinity):
   case PackCategoriesIntoKey(fcZero, fcInfinity):

+ 3 - 0
lib/Support/CommandLine.cpp

@@ -1037,6 +1037,7 @@ void CommandLineParser::ParseCommandLineOptions(int argc,
         case cl::Optional:
         case cl::Optional:
           Done = true; // Optional arguments want _at most_ one value
           Done = true; // Optional arguments want _at most_ one value
         // FALL THROUGH
         // FALL THROUGH
+        LLVM_FALLTHROUGH; // HLSL Change
         case cl::ZeroOrMore: // Zero or more will take all they can get...
         case cl::ZeroOrMore: // Zero or more will take all they can get...
         case cl::OneOrMore:  // One or more will take all they can get...
         case cl::OneOrMore:  // One or more will take all they can get...
           ProvidePositionalOption(PositionalOpts[i],
           ProvidePositionalOption(PositionalOpts[i],
@@ -1091,6 +1092,7 @@ void CommandLineParser::ParseCommandLineOptions(int argc,
         ErrorParsing = true;
         ErrorParsing = true;
       }
       }
     // Fall through
     // Fall through
+    LLVM_FALLTHROUGH; // HLSL Change
     default:
     default:
       break;
       break;
     }
     }
@@ -1142,6 +1144,7 @@ bool Option::addOccurrence(unsigned pos, StringRef ArgName, StringRef Value,
     if (NumOccurrences > 1)
     if (NumOccurrences > 1)
       return error("must occur exactly one time!", ArgName);
       return error("must occur exactly one time!", ArgName);
   // Fall through
   // Fall through
+  LLVM_FALLTHROUGH; // HLSL Change
   case OneOrMore:
   case OneOrMore:
   case ZeroOrMore:
   case ZeroOrMore:
   case ConsumeAfter:
   case ConsumeAfter:

+ 7 - 0
lib/Support/ConvertUTF.c

@@ -53,6 +53,13 @@
 #endif
 #endif
 #include <assert.h>
 #include <assert.h>
 
 
+#if !defined(_WIN32) && !defined(__clang__)
+// Disable gcc's warning for fallthrough
+// this file uses it extensively without annotation
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
+
 static const int halfShift  = 10; /* used for shifting by 10 bits */
 static const int halfShift  = 10; /* used for shifting by 10 bits */
 
 
 static const UTF32 halfBase = 0x0010000UL;
 static const UTF32 halfBase = 0x0010000UL;

+ 2 - 0
lib/Support/FoldingSet.cpp

@@ -128,7 +128,9 @@ void FoldingSetNodeID::AddString(StringRef String) {
   // No need to take endianness into account here - this is always executed.
   // No need to take endianness into account here - this is always executed.
   switch (Pos - Size) {
   switch (Pos - Size) {
   case 1: V = (V << 8) | (unsigned char)String[Size - 3]; // Fall thru.
   case 1: V = (V << 8) | (unsigned char)String[Size - 3]; // Fall thru.
+    LLVM_FALLTHROUGH; // HLSL Change
   case 2: V = (V << 8) | (unsigned char)String[Size - 2]; // Fall thru.
   case 2: V = (V << 8) | (unsigned char)String[Size - 2]; // Fall thru.
+    LLVM_FALLTHROUGH; // HLSL Change
   case 3: V = (V << 8) | (unsigned char)String[Size - 1]; break;
   case 3: V = (V << 8) | (unsigned char)String[Size - 1]; break;
   default: return; // Nothing left.
   default: return; // Nothing left.
   }
   }

+ 1 - 0
lib/Support/FormattedStream.cpp

@@ -32,6 +32,7 @@ static void UpdatePosition(std::pair<unsigned, unsigned> &Position, const char *
     switch (*Ptr) {
     switch (*Ptr) {
     case '\n':
     case '\n':
       Line += 1;
       Line += 1;
+      LLVM_FALLTHROUGH; // HLSL Change
     case '\r':
     case '\r':
       Column = 0;
       Column = 0;
       break;
       break;

+ 1 - 0
lib/Support/GraphWriter.cpp

@@ -47,6 +47,7 @@ std::string llvm::DOT::EscapeString(const std::string &Label) {
             Str.erase(Str.begin()+i); continue;
             Str.erase(Str.begin()+i); continue;
           default: break;
           default: break;
         }
         }
+      LLVM_FALLTHROUGH; // HLSL Change
     case '{': case '}':
     case '{': case '}':
     case '<': case '>':
     case '<': case '>':
     case '|': case '"':
     case '|': case '"':

+ 1 - 0
lib/Support/Path.cpp

@@ -1017,6 +1017,7 @@ file_magic identify_magic(StringRef Magic) {
     case 0xc4: // ARMNT Windows
     case 0xc4: // ARMNT Windows
       if (Magic[1] == 0x01)
       if (Magic[1] == 0x01)
         return file_magic::coff_object;
         return file_magic::coff_object;
+      LLVM_FALLTHROUGH; // HLSL Change
 
 
     case 0x90: // PA-RISC Windows
     case 0x90: // PA-RISC Windows
     case 0x68: // mc68K Windows
     case 0x68: // mc68K Windows

+ 4 - 0
lib/Support/YAMLParser.cpp

@@ -2146,6 +2146,7 @@ void MappingNode::increment() {
       break;
       break;
     default:
     default:
       setError("Unexpected token. Expected Key or Block End", T);
       setError("Unexpected token. Expected Key or Block End", T);
+      LLVM_FALLTHROUGH; // HLSL Change
     case Token::TK_Error:
     case Token::TK_Error:
       IsAtEnd = true;
       IsAtEnd = true;
       CurrentEntry = nullptr;
       CurrentEntry = nullptr;
@@ -2158,6 +2159,7 @@ void MappingNode::increment() {
       return increment();
       return increment();
     case Token::TK_FlowMappingEnd:
     case Token::TK_FlowMappingEnd:
       getNext();
       getNext();
+      LLVM_FALLTHROUGH; // HLSL Change
     case Token::TK_Error:
     case Token::TK_Error:
       // Set this to end iterator.
       // Set this to end iterator.
       IsAtEnd = true;
       IsAtEnd = true;
@@ -2200,6 +2202,7 @@ void SequenceNode::increment() {
     default:
     default:
       setError( "Unexpected token. Expected Block Entry or Block End."
       setError( "Unexpected token. Expected Block Entry or Block End."
               , T);
               , T);
+      LLVM_FALLTHROUGH; // HLSL Change
     case Token::TK_Error:
     case Token::TK_Error:
       IsAtEnd = true;
       IsAtEnd = true;
       CurrentEntry = nullptr;
       CurrentEntry = nullptr;
@@ -2228,6 +2231,7 @@ void SequenceNode::increment() {
       return increment();
       return increment();
     case Token::TK_FlowSequenceEnd:
     case Token::TK_FlowSequenceEnd:
       getNext();
       getNext();
+      LLVM_FALLTHROUGH; // HLSL Change
     case Token::TK_Error:
     case Token::TK_Error:
       // Set this to end iterator.
       // Set this to end iterator.
       IsAtEnd = true;
       IsAtEnd = true;

+ 4 - 4
lib/Support/raw_ostream.cpp

@@ -372,10 +372,10 @@ void raw_ostream::copy_to_buffer(const char *Ptr, size_t Size) {
   // Handle short strings specially, memcpy isn't very good at very short
   // Handle short strings specially, memcpy isn't very good at very short
   // strings.
   // strings.
   switch (Size) {
   switch (Size) {
-  case 4: OutBufCur[3] = Ptr[3]; // FALL THROUGH
-  case 3: OutBufCur[2] = Ptr[2]; // FALL THROUGH
-  case 2: OutBufCur[1] = Ptr[1]; // FALL THROUGH
-  case 1: OutBufCur[0] = Ptr[0]; // FALL THROUGH
+  case 4: OutBufCur[3] = Ptr[3]; LLVM_FALLTHROUGH; // HLSL Change
+  case 3: OutBufCur[2] = Ptr[2]; LLVM_FALLTHROUGH; // HLSL Change
+  case 2: OutBufCur[1] = Ptr[1]; LLVM_FALLTHROUGH; // HLSL Change
+  case 1: OutBufCur[0] = Ptr[0]; LLVM_FALLTHROUGH; // HLSL Change
   case 0: break;
   case 0: break;
   default:
   default:
     memcpy(OutBufCur, Ptr, Size);
     memcpy(OutBufCur, Ptr, Size);

+ 2 - 2
lib/TableGen/TGLexer.cpp

@@ -155,7 +155,7 @@ tgtok::TokKind TGLexer::LexToken() {
         case '0': case '1': 
         case '0': case '1': 
           if (NextChar == 'b')
           if (NextChar == 'b')
             return LexNumber();
             return LexNumber();
-          // Fallthrough
+          LLVM_FALLTHROUGH; // HLSL Change
         case '2': case '3': case '4': case '5':
         case '2': case '3': case '4': case '5':
         case '6': case '7': case '8': case '9':
         case '6': case '7': case '8': case '9':
         case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
         case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
@@ -222,7 +222,7 @@ tgtok::TokKind TGLexer::LexString() {
     case '\0':
     case '\0':
       if (CurPtr == CurBuf.end())
       if (CurPtr == CurBuf.end())
         return ReturnError(StrStart, "End of file in string literal");
         return ReturnError(StrStart, "End of file in string literal");
-      // FALL THROUGH
+      LLVM_FALLTHROUGH; // HLSL Change
     default:
     default:
       return ReturnError(CurPtr, "invalid escape in string literal");
       return ReturnError(CurPtr, "invalid escape in string literal");
     }
     }

+ 1 - 1
lib/Transforms/IPO/FunctionAttrs.cpp

@@ -774,7 +774,7 @@ bool FunctionAttrs::IsFunctionMallocLike(Function *F,
           if (CS.getCalledFunction() &&
           if (CS.getCalledFunction() &&
               SCCNodes.count(CS.getCalledFunction()))
               SCCNodes.count(CS.getCalledFunction()))
             break;
             break;
-        } // fall-through
+        } LLVM_FALLTHROUGH; // HLSL Change
         default:
         default:
           return false;  // Did not come from an allocation.
           return false;  // Did not come from an allocation.
       }
       }

+ 1 - 1
lib/Transforms/InstCombine/InstCombineCalls.cpp

@@ -493,7 +493,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
       II->setArgOperand(1, LHS);
       II->setArgOperand(1, LHS);
       return II;
       return II;
     }
     }
-    // fall through
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   case Intrinsic::usub_with_overflow:
   case Intrinsic::usub_with_overflow:
   case Intrinsic::ssub_with_overflow: {
   case Intrinsic::ssub_with_overflow: {

+ 7 - 6
lib/Transforms/InstCombine/InstCombineCompares.cpp

@@ -2159,6 +2159,7 @@ bool InstCombiner::OptimizeOverflowCheck(OverflowCheckFlavor OCF, Value *LHS,
       return SetResult(Builder->CreateAdd(LHS, RHS), Builder->getTrue(), true);
       return SetResult(Builder->CreateAdd(LHS, RHS), Builder->getTrue(), true);
   }
   }
   // FALL THROUGH uadd into sadd
   // FALL THROUGH uadd into sadd
+  LLVM_FALLTHROUGH; // HLSL Change
   case OCF_SIGNED_ADD: {
   case OCF_SIGNED_ADD: {
     // X + 0 -> {X, false}
     // X + 0 -> {X, false}
     if (match(RHS, m_Zero()))
     if (match(RHS, m_Zero()))
@@ -2198,7 +2199,7 @@ bool InstCombiner::OptimizeOverflowCheck(OverflowCheckFlavor OCF, Value *LHS,
                        true);
                        true);
     if (OR == OverflowResult::AlwaysOverflows)
     if (OR == OverflowResult::AlwaysOverflows)
       return SetResult(Builder->CreateMul(LHS, RHS), Builder->getTrue(), true);
       return SetResult(Builder->CreateMul(LHS, RHS), Builder->getTrue(), true);
-  } // FALL THROUGH
+  } LLVM_FALLTHROUGH; // HLSL CHANGE
   case OCF_SIGNED_MUL:
   case OCF_SIGNED_MUL:
     // X * undef -> undef
     // X * undef -> undef
     if (isa<UndefValue>(RHS))
     if (isa<UndefValue>(RHS))
@@ -2704,28 +2705,28 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
 
 
     case ICmpInst::ICMP_UGT:
     case ICmpInst::ICMP_UGT:
       std::swap(Op0, Op1);                   // Change icmp ugt -> icmp ult
       std::swap(Op0, Op1);                   // Change icmp ugt -> icmp ult
-      // FALL THROUGH
+      LLVM_FALLTHROUGH; // HLSL CHANGE
     case ICmpInst::ICMP_ULT:{               // icmp ult i1 A, B -> ~A & B
     case ICmpInst::ICMP_ULT:{               // icmp ult i1 A, B -> ~A & B
       Value *Not = Builder->CreateNot(Op0, I.getName()+"tmp");
       Value *Not = Builder->CreateNot(Op0, I.getName()+"tmp");
       return BinaryOperator::CreateAnd(Not, Op1);
       return BinaryOperator::CreateAnd(Not, Op1);
     }
     }
     case ICmpInst::ICMP_SGT:
     case ICmpInst::ICMP_SGT:
       std::swap(Op0, Op1);                   // Change icmp sgt -> icmp slt
       std::swap(Op0, Op1);                   // Change icmp sgt -> icmp slt
-      // FALL THROUGH
+      LLVM_FALLTHROUGH; // HLSL CHANGE
     case ICmpInst::ICMP_SLT: {               // icmp slt i1 A, B -> A & ~B
     case ICmpInst::ICMP_SLT: {               // icmp slt i1 A, B -> A & ~B
       Value *Not = Builder->CreateNot(Op1, I.getName()+"tmp");
       Value *Not = Builder->CreateNot(Op1, I.getName()+"tmp");
       return BinaryOperator::CreateAnd(Not, Op0);
       return BinaryOperator::CreateAnd(Not, Op0);
     }
     }
     case ICmpInst::ICMP_UGE:
     case ICmpInst::ICMP_UGE:
       std::swap(Op0, Op1);                   // Change icmp uge -> icmp ule
       std::swap(Op0, Op1);                   // Change icmp uge -> icmp ule
-      // FALL THROUGH
+      LLVM_FALLTHROUGH; // HLSL CHANGE
     case ICmpInst::ICMP_ULE: {               //  icmp ule i1 A, B -> ~A | B
     case ICmpInst::ICMP_ULE: {               //  icmp ule i1 A, B -> ~A | B
       Value *Not = Builder->CreateNot(Op0, I.getName()+"tmp");
       Value *Not = Builder->CreateNot(Op0, I.getName()+"tmp");
       return BinaryOperator::CreateOr(Not, Op1);
       return BinaryOperator::CreateOr(Not, Op1);
     }
     }
     case ICmpInst::ICMP_SGE:
     case ICmpInst::ICMP_SGE:
       std::swap(Op0, Op1);                   // Change icmp sge -> icmp sle
       std::swap(Op0, Op1);                   // Change icmp sge -> icmp sle
-      // FALL THROUGH
+      LLVM_FALLTHROUGH; // HLSL CHANGE
     case ICmpInst::ICMP_SLE: {               //  icmp sle i1 A, B -> A | ~B
     case ICmpInst::ICMP_SLE: {               //  icmp sle i1 A, B -> A | ~B
       Value *Not = Builder->CreateNot(Op1, I.getName()+"tmp");
       Value *Not = Builder->CreateNot(Op1, I.getName()+"tmp");
       return BinaryOperator::CreateOr(Not, Op0);
       return BinaryOperator::CreateOr(Not, Op0);
@@ -3476,7 +3477,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
       case Instruction::LShr:
       case Instruction::LShr:
         if (I.isSigned())
         if (I.isSigned())
           break;
           break;
-        // fall-through
+        LLVM_FALLTHROUGH; // HLSL Change
       case Instruction::SDiv:
       case Instruction::SDiv:
       case Instruction::AShr:
       case Instruction::AShr:
         if (!BO0->isExact() || !BO1->isExact())
         if (!BO0->isExact() || !BO1->isExact())

+ 1 - 1
lib/Transforms/InstCombine/InstCombineShifts.cpp

@@ -456,7 +456,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, Constant *Op1,
         }
         }
       }
       }
 
 
-      // FALL THROUGH.
+      LLVM_FALLTHROUGH; // HLSL CHANGE
       case Instruction::Sub: {
       case Instruction::Sub: {
         // Turn ((X >> C) + Y) << C  ->  (X + (Y << C)) & (~0 << C)
         // Turn ((X >> C) + Y) << C  ->  (X + (Y << C)) & (~0 << C)
         if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
         if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&

+ 1 - 1
lib/Transforms/InstCombine/InstructionCombining.cpp

@@ -1885,7 +1885,7 @@ isAllocSiteRemovable(Instruction *AI, SmallVectorImpl<WeakVH> &Users,
             if (MI->isVolatile() || MI->getRawDest() != PI)
             if (MI->isVolatile() || MI->getRawDest() != PI)
               return false;
               return false;
           }
           }
-          // fall through
+          LLVM_FALLTHROUGH; // HLSL Change
           case Intrinsic::dbg_declare:
           case Intrinsic::dbg_declare:
           case Intrinsic::dbg_value:
           case Intrinsic::dbg_value:
           case Intrinsic::invariant_start:
           case Intrinsic::invariant_start:

+ 1 - 0
lib/Transforms/Scalar/IndVarSimplify.cpp

@@ -1485,6 +1485,7 @@ static PHINode *getLoopPhiForCounter(Value *IncV, Loop *L, DominatorTree *DT) {
     // An IV counter must preserve its type.
     // An IV counter must preserve its type.
     if (IncI->getNumOperands() == 2)
     if (IncI->getNumOperands() == 2)
       break;
       break;
+    LLVM_FALLTHROUGH; // HLSL Change
   default:
   default:
     return nullptr;
     return nullptr;
   }
   }

+ 3 - 3
lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp

@@ -281,7 +281,7 @@ InductiveRangeCheck::parseRangeCheckICmp(Loop *L, ICmpInst *ICI,
 
 
   case ICmpInst::ICMP_SLE:
   case ICmpInst::ICMP_SLE:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
-  // fallthrough
+  LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_SGE:
   case ICmpInst::ICMP_SGE:
     if (match(RHS, m_ConstantInt<0>())) {
     if (match(RHS, m_ConstantInt<0>())) {
       Index = LHS;
       Index = LHS;
@@ -291,7 +291,7 @@ InductiveRangeCheck::parseRangeCheckICmp(Loop *L, ICmpInst *ICI,
 
 
   case ICmpInst::ICMP_SLT:
   case ICmpInst::ICMP_SLT:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
-  // fallthrough
+  LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_SGT:
   case ICmpInst::ICMP_SGT:
     if (match(RHS, m_ConstantInt<-1>())) {
     if (match(RHS, m_ConstantInt<-1>())) {
       Index = LHS;
       Index = LHS;
@@ -307,7 +307,7 @@ InductiveRangeCheck::parseRangeCheckICmp(Loop *L, ICmpInst *ICI,
 
 
   case ICmpInst::ICMP_ULT:
   case ICmpInst::ICMP_ULT:
     std::swap(LHS, RHS);
     std::swap(LHS, RHS);
-  // fallthrough
+  LLVM_FALLTHROUGH; // HLSL Change
   case ICmpInst::ICMP_UGT:
   case ICmpInst::ICMP_UGT:
     if (IsNonNegativeAndNotLoopVarying(LHS)) {
     if (IsNonNegativeAndNotLoopVarying(LHS)) {
       Index = RHS;
       Index = RHS;

+ 1 - 0
lib/Transforms/Scalar/LoopRotation.cpp

@@ -228,6 +228,7 @@ static bool shouldSpeculateInstrs(BasicBlock::iterator Begin,
       if (!cast<GEPOperator>(I)->hasAllConstantIndices())
       if (!cast<GEPOperator>(I)->hasAllConstantIndices())
         return false;
         return false;
       // fall-thru to increment case
       // fall-thru to increment case
+      LLVM_FALLTHROUGH; // HLSL Change
     case Instruction::Add:
     case Instruction::Add:
     case Instruction::Sub:
     case Instruction::Sub:
     case Instruction::And:
     case Instruction::And:

+ 1 - 1
lib/Transforms/Scalar/LoopUnswitch.cpp

@@ -747,7 +747,7 @@ static void copyMetadata(Instruction *DstInst, const Instruction *SrcInst,
           MD.second = NewMD;
           MD.second = NewMD;
         }
         }
       }
       }
-      // fallthrough.
+      LLVM_FALLTHROUGH; // HLSL Change
     case LLVMContext::MD_dbg:
     case LLVMContext::MD_dbg:
       DstInst->setMetadata(MD.first, MD.second);
       DstInst->setMetadata(MD.first, MD.second);
     }
     }

+ 1 - 1
lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp

@@ -2738,7 +2738,7 @@ void SROA_Helper::RewriteCall(CallInst *CI) {
           break;
           break;
         }
         }
       }
       }
-      __fallthrough;
+      LLVM_FALLTHROUGH;
       default:
       default:
         // RayQuery this pointer replacement.
         // RayQuery this pointer replacement.
         if (OldVal->getType()->isPointerTy() &&
         if (OldVal->getType()->isPointerTy() &&

+ 4 - 4
lib/Transforms/Utils/SimplifyLibCalls.cpp

@@ -141,7 +141,7 @@ static bool checkStringCopyLibFuncSignature(Function *F, LibFunc::Func Func) {
     llvm_unreachable("Can't check signature for non-string-copy libfunc.");
     llvm_unreachable("Can't check signature for non-string-copy libfunc.");
   case LibFunc::stpncpy_chk:
   case LibFunc::stpncpy_chk:
   case LibFunc::strncpy_chk:
   case LibFunc::strncpy_chk:
-    --NumParams; // fallthrough
+    --NumParams; LLVM_FALLTHROUGH; // HLSL Change
   case LibFunc::stpncpy:
   case LibFunc::stpncpy:
   case LibFunc::strncpy: {
   case LibFunc::strncpy: {
     if (NumParams != 3 || FT->getParamType(0) != FT->getParamType(1) ||
     if (NumParams != 3 || FT->getParamType(0) != FT->getParamType(1) ||
@@ -151,7 +151,7 @@ static bool checkStringCopyLibFuncSignature(Function *F, LibFunc::Func Func) {
   }
   }
   case LibFunc::strcpy_chk:
   case LibFunc::strcpy_chk:
   case LibFunc::stpcpy_chk:
   case LibFunc::stpcpy_chk:
-    --NumParams; // fallthrough
+    --NumParams; LLVM_FALLTHROUGH; // HLSL Change
   case LibFunc::stpcpy:
   case LibFunc::stpcpy:
   case LibFunc::strcpy: {
   case LibFunc::strcpy: {
     if (NumParams != 2 || FT->getParamType(0) != FT->getParamType(1) ||
     if (NumParams != 2 || FT->getParamType(0) != FT->getParamType(1) ||
@@ -161,7 +161,7 @@ static bool checkStringCopyLibFuncSignature(Function *F, LibFunc::Func Func) {
   }
   }
   case LibFunc::memmove_chk:
   case LibFunc::memmove_chk:
   case LibFunc::memcpy_chk:
   case LibFunc::memcpy_chk:
-    --NumParams; // fallthrough
+    --NumParams; LLVM_FALLTHROUGH; // HLSL Change
   case LibFunc::memmove:
   case LibFunc::memmove:
   case LibFunc::memcpy: {
   case LibFunc::memcpy: {
     if (NumParams != 3 || !FT->getParamType(0)->isPointerTy() ||
     if (NumParams != 3 || !FT->getParamType(0)->isPointerTy() ||
@@ -170,7 +170,7 @@ static bool checkStringCopyLibFuncSignature(Function *F, LibFunc::Func Func) {
     break;
     break;
   }
   }
   case LibFunc::memset_chk:
   case LibFunc::memset_chk:
-    --NumParams; // fallthrough
+    --NumParams; LLVM_FALLTHROUGH; // HLSL Change
   case LibFunc::memset: {
   case LibFunc::memset: {
     if (NumParams != 3 || !FT->getParamType(0)->isPointerTy() ||
     if (NumParams != 3 || !FT->getParamType(0)->isPointerTy() ||
         !FT->getParamType(1)->isIntegerTy() || FT->getParamType(2) != SizeTTy)
         !FT->getParamType(1)->isIntegerTy() || FT->getParamType(2) != SizeTTy)

+ 14 - 14
projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp

@@ -1655,7 +1655,7 @@ void DxbcConverter::AnalyzeShader(D3D10ShaderBinary::CShaderCodeParser &Parser)
       case D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_GREATER_EQUAL:
       case D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_GREATER_EQUAL:
       case D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_LESS_EQUAL:
       case D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_LESS_EQUAL:
         m_DepthRegType = RegType;
         m_DepthRegType = RegType;
-        __fallthrough;
+        LLVM_FALLTHROUGH;
       case D3D11_SB_OPERAND_TYPE_OUTPUT_STENCIL_REF:
       case D3D11_SB_OPERAND_TYPE_OUTPUT_STENCIL_REF:
       case D3D10_SB_OPERAND_TYPE_OUTPUT_COVERAGE_MASK: {
       case D3D10_SB_OPERAND_TYPE_OUTPUT_COVERAGE_MASK: {
         m_bHasStencilRef = RegType == D3D11_SB_OPERAND_TYPE_OUTPUT_STENCIL_REF;
         m_bHasStencilRef = RegType == D3D11_SB_OPERAND_TYPE_OUTPUT_STENCIL_REF;
@@ -4260,7 +4260,7 @@ void DxbcConverter::ConvertInstructions(D3D10ShaderBinary::CShaderCodeParser &Pa
         switch (Comp) {
         switch (Comp) {
         case 0: Out[c] = pOpRetClamped; break;
         case 0: Out[c] = pOpRetClamped; break;
         case 1: Out[c] = pOpRetUnclamped; break;
         case 1: Out[c] = pOpRetUnclamped; break;
-        case 2: __fallthrough;
+        case 2: LLVM_FALLTHROUGH;
         case 3: Out[c] = m_pOP->GetFloatConst(0.f); break;
         case 3: Out[c] = m_pOP->GetFloatConst(0.f); break;
         default: DXASSERT_DXBC(false);
         default: DXASSERT_DXBC(false);
         }
         }
@@ -4282,9 +4282,9 @@ void DxbcConverter::ConvertInstructions(D3D10ShaderBinary::CShaderCodeParser &Pa
       break;
       break;
     }
     }
 
 
-    case D3D10_SB_OPCODE_DERIV_RTX:         __fallthrough;
+    case D3D10_SB_OPCODE_DERIV_RTX:         LLVM_FALLTHROUGH;
     case D3D11_SB_OPCODE_DERIV_RTX_COARSE:  ConvertUnary(OP::OpCode::DerivCoarseX, CompType::getF32(), Inst); break;
     case D3D11_SB_OPCODE_DERIV_RTX_COARSE:  ConvertUnary(OP::OpCode::DerivCoarseX, CompType::getF32(), Inst); break;
-    case D3D10_SB_OPCODE_DERIV_RTY:         __fallthrough;
+    case D3D10_SB_OPCODE_DERIV_RTY:         LLVM_FALLTHROUGH;
     case D3D11_SB_OPCODE_DERIV_RTY_COARSE:  ConvertUnary(OP::OpCode::DerivCoarseY, CompType::getF32(), Inst); break;
     case D3D11_SB_OPCODE_DERIV_RTY_COARSE:  ConvertUnary(OP::OpCode::DerivCoarseY, CompType::getF32(), Inst); break;
     case D3D11_SB_OPCODE_DERIV_RTX_FINE:    ConvertUnary(OP::OpCode::DerivFineX, CompType::getF32(), Inst); break;
     case D3D11_SB_OPCODE_DERIV_RTX_FINE:    ConvertUnary(OP::OpCode::DerivFineX, CompType::getF32(), Inst); break;
     case D3D11_SB_OPCODE_DERIV_RTY_FINE:    ConvertUnary(OP::OpCode::DerivFineY, CompType::getF32(), Inst); break;
     case D3D11_SB_OPCODE_DERIV_RTY_FINE:    ConvertUnary(OP::OpCode::DerivFineY, CompType::getF32(), Inst); break;
@@ -5769,12 +5769,12 @@ void DxbcConverter::LoadOperand(OperandValue &SrcVal,
         SrcVal[c] = CastDxbcValue(LoadConstFloat(O.m_Valuef[Comp]), CompType::Kind::F32, CompType::Kind::F16);
         SrcVal[c] = CastDxbcValue(LoadConstFloat(O.m_Valuef[Comp]), CompType::Kind::F32, CompType::Kind::F16);
         break;
         break;
 
 
-      case CompType::Kind::I32: __fallthrough;
+      case CompType::Kind::I32: LLVM_FALLTHROUGH;
       case CompType::Kind::U32:
       case CompType::Kind::U32:
         SrcVal[c] = m_pOP->GetU32Const(O.m_Value[Comp]);
         SrcVal[c] = m_pOP->GetU32Const(O.m_Value[Comp]);
         break;
         break;
 
 
-      case CompType::Kind::I16: __fallthrough;
+      case CompType::Kind::I16: LLVM_FALLTHROUGH;
       case CompType::Kind::U16:
       case CompType::Kind::U16:
         SrcVal[c] = CastDxbcValue(m_pOP->GetU32Const(O.m_Value[Comp]), CompType::Kind::U32, CompType::Kind::I16);
         SrcVal[c] = CastDxbcValue(m_pOP->GetU32Const(O.m_Value[Comp]), CompType::Kind::U32, CompType::Kind::I16);
         break;
         break;
@@ -6806,7 +6806,7 @@ Value *DxbcConverter::CastDxbcValue(Value *pValue, const CompType &SrcType, cons
       return m_pBuilder->CreateBitCast(m_pBuilder->CreateSExt(pValue, Type::getInt16Ty(m_Ctx)), Type::getHalfTy(m_Ctx));
       return m_pBuilder->CreateBitCast(m_pBuilder->CreateSExt(pValue, Type::getInt16Ty(m_Ctx)), Type::getHalfTy(m_Ctx));
     case CompType::Kind::F32:
     case CompType::Kind::F32:
       return m_pBuilder->CreateBitCast(m_pBuilder->CreateSExt(pValue, Type::getInt32Ty(m_Ctx)), Type::getFloatTy(m_Ctx));
       return m_pBuilder->CreateBitCast(m_pBuilder->CreateSExt(pValue, Type::getInt32Ty(m_Ctx)), Type::getFloatTy(m_Ctx));
-    default: __fallthrough;
+    default: LLVM_FALLTHROUGH;
     }
     }
     break;
     break;
 
 
@@ -6830,7 +6830,7 @@ Value *DxbcConverter::CastDxbcValue(Value *pValue, const CompType &SrcType, cons
       pValue = m_pBuilder->CreateSExt(pValue, Type::getInt32Ty(m_Ctx));
       pValue = m_pBuilder->CreateSExt(pValue, Type::getInt32Ty(m_Ctx));
       return CreateBitCast(pValue, CompType::getI32(), CompType::getF32());
       return CreateBitCast(pValue, CompType::getI32(), CompType::getF32());
     }
     }
-    default: __fallthrough;
+    default: LLVM_FALLTHROUGH;
     }
     }
     break;
     break;
 
 
@@ -6854,7 +6854,7 @@ Value *DxbcConverter::CastDxbcValue(Value *pValue, const CompType &SrcType, cons
       pValue = m_pBuilder->CreateZExt(pValue, Type::getInt32Ty(m_Ctx));
       pValue = m_pBuilder->CreateZExt(pValue, Type::getInt32Ty(m_Ctx));
       return CreateBitCast(pValue, CompType::getI32(), CompType::getF32());
       return CreateBitCast(pValue, CompType::getI32(), CompType::getF32());
     }
     }
-    default: __fallthrough;
+    default: LLVM_FALLTHROUGH;
     }
     }
     break;
     break;
 
 
@@ -6876,7 +6876,7 @@ Value *DxbcConverter::CastDxbcValue(Value *pValue, const CompType &SrcType, cons
     }
     }
     case CompType::Kind::F32:
     case CompType::Kind::F32:
       return CreateBitCast(pValue, CompType::getI32(), CompType::getF32());
       return CreateBitCast(pValue, CompType::getI32(), CompType::getF32());
-    default: __fallthrough;
+    default: LLVM_FALLTHROUGH;
     }
     }
     break;
     break;
 
 
@@ -6896,7 +6896,7 @@ Value *DxbcConverter::CastDxbcValue(Value *pValue, const CompType &SrcType, cons
     }
     }
     case CompType::Kind::F32:
     case CompType::Kind::F32:
       return m_pBuilder->CreateFPExt(pValue, Type::getFloatTy(m_Ctx));
       return m_pBuilder->CreateFPExt(pValue, Type::getFloatTy(m_Ctx));
-    default: __fallthrough;
+    default: LLVM_FALLTHROUGH;
     }
     }
     break;
     break;
 
 
@@ -6916,11 +6916,11 @@ Value *DxbcConverter::CastDxbcValue(Value *pValue, const CompType &SrcType, cons
       return CreateBitCast(pValue, CompType::getF32(), CompType::getI32());
       return CreateBitCast(pValue, CompType::getF32(), CompType::getI32());
     case CompType::Kind::F16:
     case CompType::Kind::F16:
       return m_pBuilder->CreateFPTrunc(pValue, Type::getHalfTy(m_Ctx));
       return m_pBuilder->CreateFPTrunc(pValue, Type::getHalfTy(m_Ctx));
-    default: __fallthrough;
+    default: LLVM_FALLTHROUGH;
     }
     }
     break;
     break;
 
 
-  default: __fallthrough;
+  default: LLVM_FALLTHROUGH;
   }
   }
 
 
   DXASSERT(false, "unsupported cast combination");
   DXASSERT(false, "unsupported cast combination");
@@ -7083,7 +7083,7 @@ CompType DxbcConverter::InferOperandType(const D3D10ShaderBinary::CInstruction &
       }
       }
     }
     }
 
 
-    default: __fallthrough;
+    default: LLVM_FALLTHROUGH;
     }
     }
   }
   }
 
 

+ 7 - 7
projects/dxilconv/lib/DxbcConverter/DxbcUtil.cpp

@@ -407,7 +407,7 @@ CompType GetCompTypeWithMinPrec(D3D_REGISTER_COMPONENT_TYPE BaseCompTy,
   case D3D_REGISTER_COMPONENT_FLOAT32:
   case D3D_REGISTER_COMPONENT_FLOAT32:
     switch (MinPrec) {
     switch (MinPrec) {
     case D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT:   return CompType::getF32();
     case D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT:   return CompType::getF32();
-    case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16:  __fallthrough;
+    case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16:  LLVM_FALLTHROUGH;
     case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8: return CompType::getF16();
     case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8: return CompType::getF16();
     }
     }
     break;
     break;
@@ -436,7 +436,7 @@ CompType GetCompTypeWithMinPrec(CompType BaseCompTy,
   case CompType::Kind::F32:
   case CompType::Kind::F32:
     switch (MinPrec) {
     switch (MinPrec) {
     case D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT:   return CompType::getF32();
     case D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT:   return CompType::getF32();
-    case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16:  __fallthrough;
+    case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16:  LLVM_FALLTHROUGH;
     case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8: return CompType::getF16();
     case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8: return CompType::getF16();
     }
     }
     break;
     break;
@@ -474,7 +474,7 @@ CompType GetCompTypeFromMinPrec(D3D11_SB_OPERAND_MIN_PRECISION MinPrec,
                                 CompType DefaultPrecCompType) {
                                 CompType DefaultPrecCompType) {
   switch (MinPrec) {
   switch (MinPrec) {
   case D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT:    return GetFullPrecCompType(DefaultPrecCompType);
   case D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT:    return GetFullPrecCompType(DefaultPrecCompType);
-  case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16:   __fallthrough;
+  case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16:   LLVM_FALLTHROUGH;
   case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8:  return CompType::getF16();
   case D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8:  return CompType::getF16();
   case D3D11_SB_OPERAND_MIN_PRECISION_SINT_16:    return CompType::getI16();
   case D3D11_SB_OPERAND_MIN_PRECISION_SINT_16:    return CompType::getI16();
   case D3D11_SB_OPERAND_MIN_PRECISION_UINT_16:    return CompType::getU16();
   case D3D11_SB_OPERAND_MIN_PRECISION_UINT_16:    return CompType::getU16();
@@ -821,10 +821,10 @@ DXIL::PrimitiveTopology GetPrimitiveTopology(D3D10_SB_PRIMITIVE_TOPOLOGY Topolog
   case D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP:           return DXIL::PrimitiveTopology::LineStrip;
   case D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP:           return DXIL::PrimitiveTopology::LineStrip;
   case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST:        return DXIL::PrimitiveTopology::TriangleList;
   case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST:        return DXIL::PrimitiveTopology::TriangleList;
   case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP:       return DXIL::PrimitiveTopology::TriangleStrip;
   case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP:       return DXIL::PrimitiveTopology::TriangleStrip;
-  case D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST_ADJ:        __fallthrough;  // The ADJ versions are redundant in DXBC and are ot used, probably put there by mistake.
-  case D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ:       __fallthrough;
-  case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ:    __fallthrough;
-  case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ:   __fallthrough;
+  case D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST_ADJ:        LLVM_FALLTHROUGH;  // The ADJ versions are redundant in DXBC and are ot used, probably put there by mistake.
+  case D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ:       LLVM_FALLTHROUGH;
+  case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ:    LLVM_FALLTHROUGH;
+  case D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ:   LLVM_FALLTHROUGH;
   }
   }
 
 
   IFTBOOL(false, DXC_E_INCORRECT_DXBC);
   IFTBOOL(false, DXC_E_INCORRECT_DXBC);

+ 1 - 0
tools/clang/lib/AST/ASTContext.cpp

@@ -5799,6 +5799,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
       S += "{objc_class=}";
       S += "{objc_class=}";
       return;
       return;
     }
     }
+    LLVM_FALLTHROUGH; // HLSL Change
   }
   }
   
   
   case Type::ObjCInterface: {
   case Type::ObjCInterface: {

+ 3 - 0
tools/clang/lib/AST/ASTContextHLSL.cpp

@@ -132,6 +132,7 @@ static HLSLScalarType FindScalarTypeByName(const char *typeName, const size_t ty
           return HLSLScalarType_int64;
           return HLSLScalarType_int64;
         }
         }
       }
       }
+      break;
     case 8: // min12int, min16int, uint64_t
     case 8: // min12int, min16int, uint64_t
       if (typeName[0] == 'm' && typeName[1] == 'i') {
       if (typeName[0] == 'm' && typeName[1] == 'i') {
         if (typeName[4] == '2') {
         if (typeName[4] == '2') {
@@ -210,6 +211,7 @@ static HLSLScalarType FindScalarTypeByName(const char *typeName, const size_t ty
           return HLSLScalarType_int32;
           return HLSLScalarType_int32;
         }
         }
       }
       }
+      break;
     case 8: // uint16_t, uint32_t
     case 8: // uint16_t, uint32_t
       if (!langOptions.UseMinPrecision) {
       if (!langOptions.UseMinPrecision) {
         if (typeName[0] == 'u' && typeName[1] == 'i') {
         if (typeName[0] == 'u' && typeName[1] == 'i') {
@@ -225,6 +227,7 @@ static HLSLScalarType FindScalarTypeByName(const char *typeName, const size_t ty
           break;
           break;
         return HLSLScalarType_uint32;
         return HLSLScalarType_uint32;
       }
       }
+      break;
     case 9: // float16_t, float32_t, float64_t
     case 9: // float16_t, float32_t, float64_t
       if (typeName[0] == 'f' && typeName[1] == 'l') {
       if (typeName[0] == 'f' && typeName[1] == 'l') {
         if (!langOptions.UseMinPrecision) {
         if (!langOptions.UseMinPrecision) {

+ 1 - 0
tools/clang/lib/AST/ASTDiagnostic.cpp

@@ -317,6 +317,7 @@ void clang::FormatASTNodeDiagnosticArgument(
       Modifier = StringRef();
       Modifier = StringRef();
       Argument = StringRef();
       Argument = StringRef();
       // Fall through
       // Fall through
+      LLVM_FALLTHROUGH; // HLSL Change
     }
     }
     case DiagnosticsEngine::ak_qualtype: {
     case DiagnosticsEngine::ak_qualtype: {
       assert(Modifier.empty() && Argument.empty() &&
       assert(Modifier.empty() && Argument.empty() &&

+ 1 - 1
tools/clang/lib/AST/ASTDumper.cpp

@@ -1394,7 +1394,7 @@ void ASTDumper::VisitTemplateDeclSpecialization(const SpecializationDecl *D,
     case TSK_ExplicitInstantiationDefinition:
     case TSK_ExplicitInstantiationDefinition:
       if (!DumpExplicitInst)
       if (!DumpExplicitInst)
         break;
         break;
-      // Fall through.
+      LLVM_FALLTHROUGH; // HLSL Change
     case TSK_Undeclared:
     case TSK_Undeclared:
     case TSK_ImplicitInstantiation:
     case TSK_ImplicitInstantiation:
       if (DumpRefOnly)
       if (DumpRefOnly)

+ 1 - 0
tools/clang/lib/AST/ASTImporter.cpp

@@ -612,6 +612,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
       return false;
       return false;
     
     
     // Fall through to check the bits common with FunctionNoProtoType.
     // Fall through to check the bits common with FunctionNoProtoType.
+    LLVM_FALLTHROUGH; // HLSL Change
   }
   }
       
       
   case Type::FunctionNoProto: {
   case Type::FunctionNoProto: {

+ 2 - 2
tools/clang/lib/AST/Decl.cpp

@@ -409,7 +409,7 @@ static bool hasDirectVisibilityAttribute(const NamedDecl *D,
   case LVForExplicitType:
   case LVForExplicitType:
     if (D->hasAttr<TypeVisibilityAttr>())
     if (D->hasAttr<TypeVisibilityAttr>())
       return true;
       return true;
-    // fallthrough
+    LLVM_FALLTHROUGH; // HLSL Change
   case LVForValue:
   case LVForValue:
   case LVForExplicitValue:
   case LVForExplicitValue:
     if (D->hasAttr<VisibilityAttr>())
     if (D->hasAttr<VisibilityAttr>())
@@ -3410,7 +3410,7 @@ SourceRange FieldDecl::getSourceRange() const {
   case ISK_InClassListInit:
   case ISK_InClassListInit:
     if (const Expr *E = static_cast<const Expr *>(InitStorage.getPointer()))
     if (const Expr *E = static_cast<const Expr *>(InitStorage.getPointer()))
       return SourceRange(getInnerLocStart(), E->getLocEnd());
       return SourceRange(getInnerLocStart(), E->getLocEnd());
-    // FALLTHROUGH
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   case ISK_CapturedVLAType:
   case ISK_CapturedVLAType:
     return DeclaratorDecl::getSourceRange();
     return DeclaratorDecl::getSourceRange();

+ 3 - 1
tools/clang/lib/AST/Expr.cpp

@@ -1517,6 +1517,7 @@ bool CastExpr::CastConsistency() const {
     assert(getSubExpr()->getType()->isPointerType());
     assert(getSubExpr()->getType()->isPointerType());
     assert(getType()->getPointeeType().getAddressSpace() !=
     assert(getType()->getPointeeType().getAddressSpace() !=
            getSubExpr()->getType()->getPointeeType().getAddressSpace());
            getSubExpr()->getType()->getPointeeType().getAddressSpace());
+    goto CheckNoBasePath;
   // These should not have an inheritance path.
   // These should not have an inheritance path.
   case CK_Dynamic:
   case CK_Dynamic:
   case CK_ToUnion:
   case CK_ToUnion:
@@ -2189,6 +2190,7 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
     }
     }
 
 
     // Fallthrough for generic call handling.
     // Fallthrough for generic call handling.
+    LLVM_FALLTHROUGH; // HLSL Change
   }
   }
   case CallExprClass:
   case CallExprClass:
   case CXXMemberCallExprClass:
   case CXXMemberCallExprClass:
@@ -3110,7 +3112,7 @@ bool Expr::HasSideEffects(const ASTContext &Ctx,
     if (DCE->getTypeAsWritten()->isReferenceType() &&
     if (DCE->getTypeAsWritten()->isReferenceType() &&
         DCE->getCastKind() == CK_Dynamic)
         DCE->getCastKind() == CK_Dynamic)
       return true;
       return true;
-  } // Fall through.
+  } LLVM_FALLTHROUGH; // HLSL Change.
   case ImplicitCastExprClass:
   case ImplicitCastExprClass:
   case CStyleCastExprClass:
   case CStyleCastExprClass:
   case CXXStaticCastExprClass:
   case CXXStaticCastExprClass:

+ 1 - 1
tools/clang/lib/AST/ExprCXX.cpp

@@ -901,7 +901,7 @@ LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit,
 
 
   case LCK_ByCopy:
   case LCK_ByCopy:
     Bits |= Capture_ByCopy;
     Bits |= Capture_ByCopy;
-    // Fall through 
+    LLVM_FALLTHROUGH; // HLSL Change
   case LCK_ByRef:
   case LCK_ByRef:
     assert(Var && "capture must have a variable!");
     assert(Var && "capture must have a variable!");
     break;
     break;

+ 1 - 1
tools/clang/lib/AST/ExprClassification.cpp

@@ -345,7 +345,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
     // C-style casts will be lvalue for shortened matrices and vectors;
     // C-style casts will be lvalue for shortened matrices and vectors;
     // perform regular processing otherwise, which is based purely on type.
     // perform regular processing otherwise, which is based purely on type.
     if (Lang.HLSL && E->getValueKind() == VK_LValue) return Cl::CL_LValue;
     if (Lang.HLSL && E->getValueKind() == VK_LValue) return Cl::CL_LValue;
-    __fallthrough;
+    LLVM_FALLTHROUGH;
     // HLSL Change Ends  
     // HLSL Change Ends  
   case Expr::CXXFunctionalCastExprClass:
   case Expr::CXXFunctionalCastExprClass:
   case Expr::CXXStaticCastExprClass:
   case Expr::CXXStaticCastExprClass:

+ 6 - 2
tools/clang/lib/AST/ExprConstant.cpp

@@ -641,6 +641,7 @@ namespace {
               break;
               break;
             // We've had side-effects; we want the diagnostic from them, not
             // We've had side-effects; we want the diagnostic from them, not
             // some later problem.
             // some later problem.
+            LLVM_FALLTHROUGH; // HLSL Change
           case EM_ConstantExpression:
           case EM_ConstantExpression:
           case EM_PotentialConstantExpression:
           case EM_PotentialConstantExpression:
           case EM_ConstantExpressionUnevaluated:
           case EM_ConstantExpressionUnevaluated:
@@ -6571,6 +6572,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) {
     case EvalInfo::EM_PotentialConstantExpressionUnevaluated:
     case EvalInfo::EM_PotentialConstantExpressionUnevaluated:
       return Success(-1ULL, E);
       return Success(-1ULL, E);
     }
     }
+    llvm_unreachable("Invalid EvalMode!");
   }
   }
 
 
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap16:
@@ -6710,7 +6712,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) {
         << /*isConstexpr*/0 << /*isConstructor*/0 << "'strlen'";
         << /*isConstexpr*/0 << /*isConstructor*/0 << "'strlen'";
     else
     else
       Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
       Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change.
   case Builtin::BI__builtin_strlen: {
   case Builtin::BI__builtin_strlen: {
     // As an extension, we support __builtin_strlen() as a constant expression,
     // As an extension, we support __builtin_strlen() as a constant expression,
     // and support folding strlen() to a constant.
     // and support folding strlen() to a constant.
@@ -9189,7 +9191,8 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
       return CheckICE(Exp->getSubExpr(), Ctx);
       return CheckICE(Exp->getSubExpr(), Ctx);
     }
     }
 
 
-    // OffsetOf falls through here.
+    return CheckEvalInICE(E, Ctx); // HLSL Change - avoid dead-code fallthrough
+
   }
   }
   case Expr::OffsetOfExprClass: {
   case Expr::OffsetOfExprClass: {
     // Note that per C99, offsetof must be an ICE. And AFAIK, using
     // Note that per C99, offsetof must be an ICE. And AFAIK, using
@@ -9292,6 +9295,7 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
       return Worst(LHSResult, RHSResult);
       return Worst(LHSResult, RHSResult);
     }
     }
     }
     }
+    llvm_unreachable("Invalid binary operator!");
   }
   }
   case Expr::ImplicitCastExprClass:
   case Expr::ImplicitCastExprClass:
   case Expr::CStyleCastExprClass:
   case Expr::CStyleCastExprClass:

+ 2 - 1
tools/clang/lib/AST/ItaniumMangle.cpp

@@ -1081,7 +1081,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
         if (!MD->isStatic())
         if (!MD->isStatic())
           Arity++;
           Arity++;
     }
     }
-  // FALLTHROUGH
+    LLVM_FALLTHROUGH; // HLSL Change
   case DeclarationName::CXXConversionFunctionName:
   case DeclarationName::CXXConversionFunctionName:
   case DeclarationName::CXXLiteralOperatorName:
   case DeclarationName::CXXLiteralOperatorName:
     mangleOperatorName(Name, Arity);
     mangleOperatorName(Name, Arity);
@@ -3177,6 +3177,7 @@ recurse:
     Out << "v1U" << Kind.size() << Kind;
     Out << "v1U" << Kind.size() << Kind;
   }
   }
   // Fall through to mangle the cast itself.
   // Fall through to mangle the cast itself.
+  LLVM_FALLTHROUGH; // HLSL Change
       
       
   case Expr::CStyleCastExprClass:
   case Expr::CStyleCastExprClass:
     mangleCastExpression(E, "cv");
     mangleCastExpression(E, "cv");

+ 1 - 0
tools/clang/lib/AST/NestedNameSpecifier.cpp

@@ -284,6 +284,7 @@ NestedNameSpecifier::print(raw_ostream &OS,
   case TypeSpecWithTemplate:
   case TypeSpecWithTemplate:
     OS << "template ";
     OS << "template ";
     // Fall through to print the type.
     // Fall through to print the type.
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   case TypeSpec: {
   case TypeSpec: {
     const Type *T = getAsType();
     const Type *T = getAsType();

+ 1 - 1
tools/clang/lib/AST/TypeLoc.cpp

@@ -181,7 +181,7 @@ SourceLocation TypeLoc::getBeginLoc() const {
         LeftMost = Cur;
         LeftMost = Cur;
         break;
         break;
       }
       }
-      /* Fall through */
+      LLVM_FALLTHROUGH; // HLSL Change
     case FunctionNoProto:
     case FunctionNoProto:
     case ConstantArray:
     case ConstantArray:
     case DependentSizedArray:
     case DependentSizedArray:

+ 1 - 1
tools/clang/lib/AST/TypePrinter.cpp

@@ -228,7 +228,7 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
     case Type::VariableArray:
     case Type::VariableArray:
     case Type::DependentSizedArray:
     case Type::DependentSizedArray:
       NeedARCStrongQualifier = true;
       NeedARCStrongQualifier = true;
-      // Fall through
+      LLVM_FALLTHROUGH; // HLSL Change
       
       
     case Type::Adjusted:
     case Type::Adjusted:
     case Type::Decayed:
     case Type::Decayed:

+ 1 - 1
tools/clang/lib/Analysis/PseudoConstantAnalysis.cpp

@@ -110,7 +110,7 @@ void PseudoConstantAnalysis::RunAnalysis() {
         if (LHSDecl == RHSDecl)
         if (LHSDecl == RHSDecl)
           // Do not visit the children
           // Do not visit the children
           continue;
           continue;
-
+        LLVM_FALLTHROUGH; // HLSL Change
       }
       }
       case BO_AddAssign:
       case BO_AddAssign:
       case BO_SubAssign:
       case BO_SubAssign:

+ 1 - 1
tools/clang/lib/Analysis/ReachableCode.cpp

@@ -188,7 +188,7 @@ static bool isConfigurationValue(const Stmt *S,
       return isConfigurationValue(cast<DeclRefExpr>(S)->getDecl(), PP);
       return isConfigurationValue(cast<DeclRefExpr>(S)->getDecl(), PP);
     case Stmt::ObjCBoolLiteralExprClass:
     case Stmt::ObjCBoolLiteralExprClass:
       IgnoreYES_NO = true;
       IgnoreYES_NO = true;
-      // Fallthrough.
+      LLVM_FALLTHROUGH; // HLSL Change
     case Stmt::CXXBoolLiteralExprClass:
     case Stmt::CXXBoolLiteralExprClass:
     case Stmt::IntegerLiteralClass: {
     case Stmt::IntegerLiteralClass: {
       const Expr *E = cast<Expr>(S);
       const Expr *E = cast<Expr>(S);

+ 2 - 0
tools/clang/lib/Basic/IdentifierTable.cpp

@@ -534,8 +534,10 @@ ObjCInstanceTypeFamily Selector::getInstTypeMethodFamily(Selector sel) {
     case 's':
     case 's':
       if (startsWithWord(name, "shared")) return OIT_ReturnsSelf;
       if (startsWithWord(name, "shared")) return OIT_ReturnsSelf;
       if (startsWithWord(name, "standard")) return OIT_Singleton;
       if (startsWithWord(name, "standard")) return OIT_Singleton;
+      break;
     case 'i':
     case 'i':
       if (startsWithWord(name, "init")) return OIT_Init;
       if (startsWithWord(name, "init")) return OIT_Init;
+      break; // HLSL Change
     default:
     default:
       break;
       break;
   }
   }

+ 1 - 0
tools/clang/lib/Basic/OpenMPKinds.cpp

@@ -159,6 +159,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
     return #Name;
     return #Name;
 #include "clang/Basic/OpenMPKinds.def"
 #include "clang/Basic/OpenMPKinds.def"
     }
     }
+    llvm_unreachable("Invalid OpenMP 'schedule' clause type");
   case OMPC_depend:
   case OMPC_depend:
     switch (Type) {
     switch (Type) {
     case OMPC_DEPEND_unknown:
     case OMPC_DEPEND_unknown:

+ 2 - 0
tools/clang/lib/Basic/TargetInfo.cpp

@@ -132,9 +132,11 @@ const char *TargetInfo::getTypeConstantSuffix(IntType T) const {
   case UnsignedChar:
   case UnsignedChar:
     if (getCharWidth() < getIntWidth())
     if (getCharWidth() < getIntWidth())
       return "";
       return "";
+    LLVM_FALLTHROUGH; // HLSL Change
   case UnsignedShort:
   case UnsignedShort:
     if (getShortWidth() < getIntWidth())
     if (getShortWidth() < getIntWidth())
       return "";
       return "";
+    LLVM_FALLTHROUGH; // HLSL Change
   case UnsignedInt:      return "U";
   case UnsignedInt:      return "U";
   case UnsignedLong:     return "UL";
   case UnsignedLong:     return "UL";
   case UnsignedLongLong: return "ULL";
   case UnsignedLongLong: return "ULL";

+ 7 - 7
tools/clang/lib/CodeGen/CGAtomic.cpp

@@ -573,7 +573,7 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
 
 
   case AtomicExpr::AO__atomic_add_fetch:
   case AtomicExpr::AO__atomic_add_fetch:
     PostOp = llvm::Instruction::Add;
     PostOp = llvm::Instruction::Add;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case AtomicExpr::AO__c11_atomic_fetch_add:
   case AtomicExpr::AO__c11_atomic_fetch_add:
   case AtomicExpr::AO__atomic_fetch_add:
   case AtomicExpr::AO__atomic_fetch_add:
     Op = llvm::AtomicRMWInst::Add;
     Op = llvm::AtomicRMWInst::Add;
@@ -581,7 +581,7 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
 
 
   case AtomicExpr::AO__atomic_sub_fetch:
   case AtomicExpr::AO__atomic_sub_fetch:
     PostOp = llvm::Instruction::Sub;
     PostOp = llvm::Instruction::Sub;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case AtomicExpr::AO__c11_atomic_fetch_sub:
   case AtomicExpr::AO__c11_atomic_fetch_sub:
   case AtomicExpr::AO__atomic_fetch_sub:
   case AtomicExpr::AO__atomic_fetch_sub:
     Op = llvm::AtomicRMWInst::Sub;
     Op = llvm::AtomicRMWInst::Sub;
@@ -589,7 +589,7 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
 
 
   case AtomicExpr::AO__atomic_and_fetch:
   case AtomicExpr::AO__atomic_and_fetch:
     PostOp = llvm::Instruction::And;
     PostOp = llvm::Instruction::And;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case AtomicExpr::AO__c11_atomic_fetch_and:
   case AtomicExpr::AO__c11_atomic_fetch_and:
   case AtomicExpr::AO__atomic_fetch_and:
   case AtomicExpr::AO__atomic_fetch_and:
     Op = llvm::AtomicRMWInst::And;
     Op = llvm::AtomicRMWInst::And;
@@ -597,7 +597,7 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
 
 
   case AtomicExpr::AO__atomic_or_fetch:
   case AtomicExpr::AO__atomic_or_fetch:
     PostOp = llvm::Instruction::Or;
     PostOp = llvm::Instruction::Or;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case AtomicExpr::AO__c11_atomic_fetch_or:
   case AtomicExpr::AO__c11_atomic_fetch_or:
   case AtomicExpr::AO__atomic_fetch_or:
   case AtomicExpr::AO__atomic_fetch_or:
     Op = llvm::AtomicRMWInst::Or;
     Op = llvm::AtomicRMWInst::Or;
@@ -605,7 +605,7 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
 
 
   case AtomicExpr::AO__atomic_xor_fetch:
   case AtomicExpr::AO__atomic_xor_fetch:
     PostOp = llvm::Instruction::Xor;
     PostOp = llvm::Instruction::Xor;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case AtomicExpr::AO__c11_atomic_fetch_xor:
   case AtomicExpr::AO__c11_atomic_fetch_xor:
   case AtomicExpr::AO__atomic_fetch_xor:
   case AtomicExpr::AO__atomic_fetch_xor:
     Op = llvm::AtomicRMWInst::Xor;
     Op = llvm::AtomicRMWInst::Xor;
@@ -613,7 +613,7 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
 
 
   case AtomicExpr::AO__atomic_nand_fetch:
   case AtomicExpr::AO__atomic_nand_fetch:
     PostOp = llvm::Instruction::And;
     PostOp = llvm::Instruction::And;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case AtomicExpr::AO__atomic_fetch_nand:
   case AtomicExpr::AO__atomic_fetch_nand:
     Op = llvm::AtomicRMWInst::Nand;
     Op = llvm::AtomicRMWInst::Nand;
     break;
     break;
@@ -748,7 +748,7 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) {
       EmitStoreOfScalar(Val1Scalar, MakeAddrLValue(Val1, Val1Ty));
       EmitStoreOfScalar(Val1Scalar, MakeAddrLValue(Val1, Val1Ty));
       break;
       break;
     }
     }
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case AtomicExpr::AO__atomic_fetch_add:
   case AtomicExpr::AO__atomic_fetch_add:
   case AtomicExpr::AO__atomic_fetch_sub:
   case AtomicExpr::AO__atomic_fetch_sub:
   case AtomicExpr::AO__atomic_add_fetch:
   case AtomicExpr::AO__atomic_add_fetch:

+ 2 - 2
tools/clang/lib/CodeGen/CGCall.cpp

@@ -1590,7 +1590,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
       RetAttrs.addAttribute(llvm::Attribute::SExt);
       RetAttrs.addAttribute(llvm::Attribute::SExt);
     else if (RetTy->hasUnsignedIntegerRepresentation())
     else if (RetTy->hasUnsignedIntegerRepresentation())
       RetAttrs.addAttribute(llvm::Attribute::ZExt);
       RetAttrs.addAttribute(llvm::Attribute::ZExt);
-    // FALL THROUGH
+    LLVM_FALLTHROUGH; // HLSL Change
   case ABIArgInfo::Direct:
   case ABIArgInfo::Direct:
     if (RetAI.getInReg())
     if (RetAI.getInReg())
       RetAttrs.addAttribute(llvm::Attribute::InReg);
       RetAttrs.addAttribute(llvm::Attribute::InReg);
@@ -1672,7 +1672,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
         else
         else
           Attrs.addAttribute(llvm::Attribute::ZExt);
           Attrs.addAttribute(llvm::Attribute::ZExt);
       }
       }
-      // FALL THROUGH
+      LLVM_FALLTHROUGH; // HLSL Change
     case ABIArgInfo::Direct:
     case ABIArgInfo::Direct:
       if (ArgNo == 0 && FI.isChainCall())
       if (ArgNo == 0 && FI.isChainCall())
         Attrs.addAttribute(llvm::Attribute::Nest);
         Attrs.addAttribute(llvm::Attribute::Nest);

+ 1 - 1
tools/clang/lib/CodeGen/CGClass.cpp

@@ -1461,7 +1461,7 @@ void CodeGenFunction::EmitDestructorBody(FunctionArgList &Args) {
     }
     }
 #endif // HLSL Change - no support for exception handling
 #endif // HLSL Change - no support for exception handling
     // Fallthrough: act like we're in the base variant.
     // Fallthrough: act like we're in the base variant.
-
+    LLVM_FALLTHROUGH;
   case Dtor_Base:
   case Dtor_Base:
     assert(Body);
     assert(Body);
 
 

+ 1 - 1
tools/clang/lib/CodeGen/CGExprAgg.cpp

@@ -697,7 +697,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
       return Visit(E->getSubExpr());
       return Visit(E->getSubExpr());
     }
     }
 
 
-    // fallthrough
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   case CK_NoOp:
   case CK_NoOp:
   case CK_UserDefinedConversion:
   case CK_UserDefinedConversion:

+ 1 - 1
tools/clang/lib/CodeGen/CGExprCXX.cpp

@@ -614,7 +614,7 @@ CodeGenFunction::EmitCXXConstructExpr(const CXXConstructExpr *E,
 
 
      case CXXConstructExpr::CK_VirtualBase:
      case CXXConstructExpr::CK_VirtualBase:
       ForVirtualBase = true;
       ForVirtualBase = true;
-      // fall-through
+      LLVM_FALLTHROUGH; // HLSL Change
 
 
      case CXXConstructExpr::CK_NonVirtualBase:
      case CXXConstructExpr::CK_NonVirtualBase:
       Type = Ctor_Base;
       Type = Ctor_Base;

+ 5 - 0
tools/clang/lib/CodeGen/CGExprConstant.cpp

@@ -874,6 +874,7 @@ public:
           return llvm::Constant::getNullValue(destType);
           return llvm::Constant::getNullValue(destType);
         }
         }
       }
       }
+      return nullptr;
     }
     }
 
 
     case CK_FlatConversion:
     case CK_FlatConversion:
@@ -918,6 +919,8 @@ public:
         llvm::Constant *destVal = llvm::Constant::getNullValue(destType);
         llvm::Constant *destVal = llvm::Constant::getNullValue(destType);
         return destVal;
         return destVal;
       }
       }
+      llvm_unreachable("Invalid cast target");
+      return nullptr;
     }
     }
     case CK_HLSLMatrixTruncationCast: {
     case CK_HLSLMatrixTruncationCast: {
       if (llvm::ConstantStruct *CS = dyn_cast<llvm::ConstantStruct>(C)) {
       if (llvm::ConstantStruct *CS = dyn_cast<llvm::ConstantStruct>(C)) {
@@ -942,6 +945,8 @@ public:
         llvm::Constant *destVal = llvm::Constant::getNullValue(destType);
         llvm::Constant *destVal = llvm::Constant::getNullValue(destType);
         return destVal;
         return destVal;
       }
       }
+      llvm_unreachable("Invalid cast target");
+      return nullptr;
     }
     }
     // HLSL Change Ends.
     // HLSL Change Ends.
     }
     }

+ 5 - 5
tools/clang/lib/CodeGen/CGExprScalar.cpp

@@ -504,7 +504,7 @@ public:
       case LangOptions::SOB_Undefined:
       case LangOptions::SOB_Undefined:
         if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
         if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
           return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
           return Builder.CreateNSWMul(Ops.LHS, Ops.RHS, "mul");
-        // Fall through.
+        LLVM_FALLTHROUGH; // HLSL Change
       case LangOptions::SOB_Trapping:
       case LangOptions::SOB_Trapping:
         return EmitOverflowCheckedBinOp(Ops);
         return EmitOverflowCheckedBinOp(Ops);
       }
       }
@@ -1783,7 +1783,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
     } else if (E->getType()->isScalarType()) {
     } else if (E->getType()->isScalarType()) {
       return Builder.CreateExtractElement(val, (uint64_t)0);
       return Builder.CreateExtractElement(val, (uint64_t)0);
     }
     }
-  }
+  } break;
   case CK_HLSLCC_FloatingToIntegral:
   case CK_HLSLCC_FloatingToIntegral:
   case CK_HLSLCC_FloatingCast: {
   case CK_HLSLCC_FloatingCast: {
     return EmitScalarConversion(Visit(E), E->getType(), DestTy);
     return EmitScalarConversion(Visit(E), E->getType(), DestTy);
@@ -1899,7 +1899,7 @@ llvm::Value *ScalarExprEmitter::EmitIncDecConsiderOverflowBehavior(
   case LangOptions::SOB_Undefined:
   case LangOptions::SOB_Undefined:
     if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
     if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
       return Builder.CreateNSWAdd(InVal, Amount, Name);
       return Builder.CreateNSWAdd(InVal, Amount, Name);
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case LangOptions::SOB_Trapping:
   case LangOptions::SOB_Trapping:
     return EmitOverflowCheckedBinOp(createBinOpInfoFromIncDec(E, InVal, IsInc));
     return EmitOverflowCheckedBinOp(createBinOpInfoFromIncDec(E, InVal, IsInc));
   }
   }
@@ -2908,7 +2908,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &op) {
     case LangOptions::SOB_Undefined:
     case LangOptions::SOB_Undefined:
       if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
       if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
         return Builder.CreateNSWAdd(op.LHS, op.RHS, "add");
         return Builder.CreateNSWAdd(op.LHS, op.RHS, "add");
-      // Fall through.
+      LLVM_FALLTHROUGH; // HLSL Change
     case LangOptions::SOB_Trapping:
     case LangOptions::SOB_Trapping:
       return EmitOverflowCheckedBinOp(op);
       return EmitOverflowCheckedBinOp(op);
     }
     }
@@ -2939,7 +2939,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) {
       case LangOptions::SOB_Undefined:
       case LangOptions::SOB_Undefined:
         if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
         if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow))
           return Builder.CreateNSWSub(op.LHS, op.RHS, "sub");
           return Builder.CreateNSWSub(op.LHS, op.RHS, "sub");
-        // Fall through.
+        LLVM_FALLTHROUGH; // HLSL Change
       case LangOptions::SOB_Trapping:
       case LangOptions::SOB_Trapping:
         return EmitOverflowCheckedBinOp(op);
         return EmitOverflowCheckedBinOp(op);
       }
       }

+ 4 - 1
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -2183,6 +2183,7 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
             << (funcProps->shaderKind == DXIL::ShaderKind::RayGeneration ?
             << (funcProps->shaderKind == DXIL::ShaderKind::RayGeneration ?
                 "raygeneration" : "intersection");
                 "raygeneration" : "intersection");
         rayShaderHaveErrors = true;
         rayShaderHaveErrors = true;
+        break;
       case DXIL::ShaderKind::AnyHit:
       case DXIL::ShaderKind::AnyHit:
       case DXIL::ShaderKind::ClosestHit:
       case DXIL::ShaderKind::ClosestHit:
         if (0 == ArgNo && dxilInputQ != DxilParamInputQual::Inout) {
         if (0 == ArgNo && dxilInputQ != DxilParamInputQual::Inout) {
@@ -2299,8 +2300,10 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
     case DXIL::ShaderKind::AnyHit:
     case DXIL::ShaderKind::AnyHit:
     case DXIL::ShaderKind::ClosestHit:
     case DXIL::ShaderKind::ClosestHit:
       bNeedsAttributes = true;
       bNeedsAttributes = true;
+      LLVM_FALLTHROUGH;
     case DXIL::ShaderKind::Miss:
     case DXIL::ShaderKind::Miss:
       bNeedsPayload = true;
       bNeedsPayload = true;
+      LLVM_FALLTHROUGH;
     case DXIL::ShaderKind::Callable:
     case DXIL::ShaderKind::Callable:
       if (0 == funcProps->ShaderProps.Ray.payloadSizeInBytes) {
       if (0 == funcProps->ShaderProps.Ray.payloadSizeInBytes) {
         unsigned DiagID = bNeedsPayload ?
         unsigned DiagID = bNeedsPayload ?
@@ -3048,7 +3051,7 @@ void CGMSHLSLRuntime::CreateSubobject(DXIL::SubobjectKind kind, const StringRef
     }
     }
     case DXIL::SubobjectKind::LocalRootSignature:
     case DXIL::SubobjectKind::LocalRootSignature:
       flags = DxilRootSignatureCompilationFlags::LocalRootSignature;
       flags = DxilRootSignatureCompilationFlags::LocalRootSignature;
-      __fallthrough;
+      LLVM_FALLTHROUGH;
     case DXIL::SubobjectKind::GlobalRootSignature: {
     case DXIL::SubobjectKind::GlobalRootSignature: {
       DXASSERT_NOMSG(argCount == 1);
       DXASSERT_NOMSG(argCount == 1);
       StringRef signature;
       StringRef signature;

+ 1 - 1
tools/clang/lib/CodeGen/CGStmt.cpp

@@ -708,7 +708,7 @@ void CodeGenFunction::EmitCondBrHints(llvm::LLVMContext &Context,
       }
       }
       // Vectorization/interleaving is disabled, set width/count to 1.
       // Vectorization/interleaving is disabled, set width/count to 1.
       ValueInt = 1;
       ValueInt = 1;
-      // Fallthrough.
+      LLVM_FALLTHROUGH; // HLSL Change
     case LoopHintAttr::VectorizeWidth:
     case LoopHintAttr::VectorizeWidth:
     case LoopHintAttr::InterleaveCount:
     case LoopHintAttr::InterleaveCount:
     case LoopHintAttr::UnrollCount:
     case LoopHintAttr::UnrollCount:

+ 1 - 0
tools/clang/lib/CodeGen/CodeGenModule.cpp

@@ -3390,6 +3390,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     // Skip variable templates
     // Skip variable templates
     if (cast<VarDecl>(D)->getDescribedVarTemplate())
     if (cast<VarDecl>(D)->getDescribedVarTemplate())
       return;
       return;
+    LLVM_FALLTHROUGH; // HLSL Change
   case Decl::VarTemplateSpecialization:
   case Decl::VarTemplateSpecialization:
     EmitGlobal(cast<VarDecl>(D));
     EmitGlobal(cast<VarDecl>(D));
     // HLSL Change Start - add resource or subobject for global variables
     // HLSL Change Start - add resource or subobject for global variables

+ 2 - 2
tools/clang/lib/CodeGen/ItaniumCXXABI.cpp

@@ -2603,7 +2603,7 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
     }
     }
 
 
     assert(isa<ObjCInterfaceType>(Ty));
     assert(isa<ObjCInterfaceType>(Ty));
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   case Type::ObjCInterface:
   case Type::ObjCInterface:
     if (cast<ObjCInterfaceType>(Ty)->getDecl()->getSuperClass()) {
     if (cast<ObjCInterfaceType>(Ty)->getDecl()->getSuperClass()) {
@@ -3480,7 +3480,7 @@ static void InitCatchParam(CodeGenFunction &CGF,
       switch (CatchType.getQualifiers().getObjCLifetime()) {
       switch (CatchType.getQualifiers().getObjCLifetime()) {
       case Qualifiers::OCL_Strong:
       case Qualifiers::OCL_Strong:
         CastExn = CGF.EmitARCRetainNonBlock(CastExn);
         CastExn = CGF.EmitARCRetainNonBlock(CastExn);
-        // fallthrough
+        LLVM_FALLTHROUGH; // HLSL Change
 
 
       case Qualifiers::OCL_None:
       case Qualifiers::OCL_None:
       case Qualifiers::OCL_ExplicitNone:
       case Qualifiers::OCL_ExplicitNone:

+ 1 - 1
tools/clang/lib/Frontend/CompilerInvocation.cpp

@@ -863,7 +863,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
       Opts.ProgramAction = frontend::EmitObj; break;
       Opts.ProgramAction = frontend::EmitObj; break;
     case OPT_fixit_EQ:
     case OPT_fixit_EQ:
       Opts.FixItSuffix = A->getValue();
       Opts.FixItSuffix = A->getValue();
-      // fall-through!
+      LLVM_FALLTHROUGH; // HLSL Change
     case OPT_fixit:
     case OPT_fixit:
       Opts.ProgramAction = frontend::FixIt; break;
       Opts.ProgramAction = frontend::FixIt; break;
     case OPT_emit_module:
     case OPT_emit_module:

+ 1 - 1
tools/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp

@@ -556,7 +556,7 @@ bool InclusionRewriter::Process(FileID FileId,
                               LocalEOL, Line, /*EnsureNewline=*/ true);
                               LocalEOL, Line, /*EnsureNewline=*/ true);
             WriteLineInfo(FileName, Line, FileType);
             WriteLineInfo(FileName, Line, FileType);
             RawLex.SetKeepWhitespaceMode(false);
             RawLex.SetKeepWhitespaceMode(false);
-          }
+          } break;
           default:
           default:
             break;
             break;
         }
         }

+ 1 - 0
tools/clang/lib/Frontend/SerializedDiagnosticReader.cpp

@@ -126,6 +126,7 @@ SerializedDiagnosticReader::readMetaBlock(llvm::BitstreamCursor &Stream) {
     case Cursor::BlockBegin:
     case Cursor::BlockBegin:
       if (Stream.SkipBlock())
       if (Stream.SkipBlock())
         return SDError::MalformedMetadataBlock;
         return SDError::MalformedMetadataBlock;
+      LLVM_FALLTHROUGH; // HLSL Change
     case Cursor::BlockEnd:
     case Cursor::BlockEnd:
       if (!VersionChecked)
       if (!VersionChecked)
         return SDError::MissingVersion;
         return SDError::MissingVersion;

+ 1 - 0
tools/clang/lib/Index/CommentToXML.cpp

@@ -732,6 +732,7 @@ void CommentASTToXMLConverter::visitBlockCommandComment(
   case CommandTraits::KCI_version:
   case CommandTraits::KCI_version:
   case CommandTraits::KCI_warning:
   case CommandTraits::KCI_warning:
     ParagraphKind = C->getCommandName(Traits);
     ParagraphKind = C->getCommandName(Traits);
+    break;
   default:
   default:
     break;
     break;
   }
   }

+ 1 - 1
tools/clang/lib/Index/USRGeneration.cpp

@@ -796,7 +796,7 @@ void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) {
 
 
   case TemplateArgument::TemplateExpansion:
   case TemplateArgument::TemplateExpansion:
     Out << 'P'; // pack expansion of...
     Out << 'P'; // pack expansion of...
-    // Fall through
+    LLVM_FALLTHROUGH; // HLSL Change
   case TemplateArgument::Template:
   case TemplateArgument::Template:
     VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
     VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
     break;
     break;

+ 2 - 1
tools/clang/lib/Lex/Lexer.cpp

@@ -2467,7 +2467,7 @@ void Lexer::ReadToEndOfLine(SmallVectorImpl<char> *Result) {
           Result->push_back(Char);
           Result->push_back(Char);
         break;
         break;
       }
       }
-      // FALL THROUGH.
+      LLVM_FALLTHROUGH; // HLSL Change
     case '\r':
     case '\r':
     case '\n':
     case '\n':
       // Okay, we found the end of the line. First, back up past the \0, \r, \n.
       // Okay, we found the end of the line. First, back up past the \0, \r, \n.
@@ -3179,6 +3179,7 @@ LexNextToken:
       return LexCharConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result),
       return LexCharConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result),
                              tok::wide_char_constant);
                              tok::wide_char_constant);
     // FALL THROUGH, treating L like the start of an identifier.
     // FALL THROUGH, treating L like the start of an identifier.
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   // C99 6.4.2: Identifiers.
   // C99 6.4.2: Identifiers.
   case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
   case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':

+ 4 - 1
tools/clang/lib/Lex/LiteralSupport.cpp

@@ -444,8 +444,11 @@ static void EncodeUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf,
   ResultBuf += bytesToWrite;
   ResultBuf += bytesToWrite;
   switch (bytesToWrite) { // note: everything falls through.
   switch (bytesToWrite) { // note: everything falls through.
   case 4: *--ResultBuf = (UTF8)((UcnVal | byteMark) & byteMask); UcnVal >>= 6;
   case 4: *--ResultBuf = (UTF8)((UcnVal | byteMark) & byteMask); UcnVal >>= 6;
+    LLVM_FALLTHROUGH; // HLSL Change
   case 3: *--ResultBuf = (UTF8)((UcnVal | byteMark) & byteMask); UcnVal >>= 6;
   case 3: *--ResultBuf = (UTF8)((UcnVal | byteMark) & byteMask); UcnVal >>= 6;
+    LLVM_FALLTHROUGH; // HLSL Change
   case 2: *--ResultBuf = (UTF8)((UcnVal | byteMark) & byteMask); UcnVal >>= 6;
   case 2: *--ResultBuf = (UTF8)((UcnVal | byteMark) & byteMask); UcnVal >>= 6;
+    LLVM_FALLTHROUGH; // HLSL Change
   case 1: *--ResultBuf = (UTF8) (UcnVal | firstByteMark[bytesToWrite]);
   case 1: *--ResultBuf = (UTF8) (UcnVal | firstByteMark[bytesToWrite]);
   }
   }
   // Update the buffer.
   // Update the buffer.
@@ -679,7 +682,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
       // "i", "if", and "il" are user-defined suffixes in C++1y.
       // "i", "if", and "il" are user-defined suffixes in C++1y.
       if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
       if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
         break;
         break;
-      // fall through.
+      LLVM_FALLTHROUGH; // HLSL Change
     case 'j':
     case 'j':
     case 'J':
     case 'J':
       if (isImaginary) break;   // Cannot be repeated.
       if (isImaginary) break;   // Cannot be repeated.

+ 14 - 12
tools/clang/lib/Parse/ParseCXXInlineMethods.cpp

@@ -761,7 +761,7 @@ bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
     case tok::semi:
     case tok::semi:
       if (StopAtSemi)
       if (StopAtSemi)
         return false;
         return false;
-      // FALL THROUGH.
+      LLVM_FALLTHROUGH; // HLSL CHANGE.
     default:
     default:
       // consume this token.
       // consume this token.
       Toks.push_back(Tok);
       Toks.push_back(Tok);
@@ -1109,17 +1109,19 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks,
       break;
       break;
 
 
     case tok::greatergreatergreater:
     case tok::greatergreatergreater:
-      if (!getLangOpts().CPlusPlus11)
-        goto consume_token;
-      if (AngleCount) --AngleCount;
-      if (KnownTemplateCount) --KnownTemplateCount;
-      // Fall through.
+      // HLSL Change - refactor to satisfy GCC and clang fallthrough detects
+      if (getLangOpts().CPlusPlus11) {
+        if (AngleCount) AngleCount -= 3;
+        if (KnownTemplateCount){ KnownTemplateCount -= 3;}
+      }
+      goto consume_token;
     case tok::greatergreater:
     case tok::greatergreater:
-      if (!getLangOpts().CPlusPlus11)
-        goto consume_token;
-      if (AngleCount) --AngleCount;
-      if (KnownTemplateCount) --KnownTemplateCount;
-      // Fall through.
+      if (getLangOpts().CPlusPlus11) {
+        if (AngleCount) AngleCount-= 2;
+        if (KnownTemplateCount){ KnownTemplateCount -= 2;}
+      }
+      goto consume_token;
+      // End HLSL Change
     case tok::greater:
     case tok::greater:
       if (AngleCount) --AngleCount;
       if (AngleCount) --AngleCount;
       if (KnownTemplateCount) --KnownTemplateCount;
       if (KnownTemplateCount) --KnownTemplateCount;
@@ -1224,7 +1226,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks,
     case tok::semi:
     case tok::semi:
       if (CIK == CIK_DefaultInitializer)
       if (CIK == CIK_DefaultInitializer)
         return true; // End of the default initializer.
         return true; // End of the default initializer.
-      // FALL THROUGH.
+      LLVM_FALLTHROUGH; // HLSL CHANGE.
     default:
     default:
     consume_token:
     consume_token:
       Toks.push_back(Tok);
       Toks.push_back(Tok);

+ 8 - 3
tools/clang/lib/Parse/ParseDecl.cpp

@@ -3020,7 +3020,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
           Tok.setIdentifierInfo(II);
           Tok.setIdentifierInfo(II);
         }
         }
       }
       }
-      // Fall through.
+      LLVM_FALLTHROUGH; // HLSL Change
     }
     }
     case tok::comma:
     case tok::comma:
     case tok::equal:
     case tok::equal:
@@ -4221,6 +4221,8 @@ HLSLReservedKeyword:
         isInvalid = true;
         isInvalid = true;
         break;
         break;
       };
       };
+      ParseOpenCLQualifiers(DS.getAttributes()); // HLSL Change -
+      break; // avoid dead-code fallthrough
     case tok::kw___private:
     case tok::kw___private:
     case tok::kw___global:
     case tok::kw___global:
     case tok::kw___local:
     case tok::kw___local:
@@ -5139,7 +5141,7 @@ bool Parser::isTypeSpecifierQualifier() {
   case tok::identifier:   // foo::bar
   case tok::identifier:   // foo::bar
     if (TryAltiVecVectorToken())
     if (TryAltiVecVectorToken())
       return true;
       return true;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change.
   case tok::kw_typename:  // typename T::type
   case tok::kw_typename:  // typename T::type
     // Annotate typenames and C++ scope specifiers.  If we get one, just
     // Annotate typenames and C++ scope specifiers.  If we get one, just
     // recurse to handle whatever we get.
     // recurse to handle whatever we get.
@@ -5268,7 +5270,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
       return false;
       return false;
     if (TryAltiVecVectorToken())
     if (TryAltiVecVectorToken())
       return true;
       return true;
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change.
   case tok::kw_decltype: // decltype(T())::type
   case tok::kw_decltype: // decltype(T())::type
   case tok::kw_typename: // typename T::type
   case tok::kw_typename: // typename T::type
     // Annotate typenames and C++ scope specifiers.  If we get one, just
     // Annotate typenames and C++ scope specifiers.  If we get one, just
@@ -5628,6 +5630,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, unsigned AttrReqs,
           continue; // do *not* consume the next token!
           continue; // do *not* consume the next token!
         }
         }
         // otherwise, FALL THROUGH!
         // otherwise, FALL THROUGH!
+        LLVM_FALLTHROUGH; // HLSL Change
       default:
       default:
         // If this is not a type-qualifier token, we're done reading type
         // If this is not a type-qualifier token, we're done reading type
         // qualifiers.  First verify that DeclSpec's are consistent.
         // qualifiers.  First verify that DeclSpec's are consistent.
@@ -5687,6 +5690,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, unsigned AttrReqs,
         if (TryKeywordIdentFallback(false))
         if (TryKeywordIdentFallback(false))
           continue;
           continue;
       }
       }
+    LLVM_FALLTHROUGH; // HLSL Change
     case tok::kw___sptr:
     case tok::kw___sptr:
     case tok::kw___w64:
     case tok::kw___w64:
     case tok::kw___ptr64:
     case tok::kw___ptr64:
@@ -5736,6 +5740,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, unsigned AttrReqs,
         continue; // do *not* consume the next token!
         continue; // do *not* consume the next token!
       }
       }
       // otherwise, FALL THROUGH!
       // otherwise, FALL THROUGH!
+      LLVM_FALLTHROUGH; // HLSL Change
     default:
     default:
       DoneWithTypeQuals:
       DoneWithTypeQuals:
       // If this is not a type-qualifier token, we're done reading type
       // If this is not a type-qualifier token, we're done reading type

+ 2 - 1
tools/clang/lib/Parse/ParseDeclCXX.cpp

@@ -361,7 +361,7 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) {
     case tok::r_brace:
     case tok::r_brace:
       if (!NestedModules)
       if (!NestedModules)
         break;
         break;
-      // Fall through.
+      LLVM_FALLTHROUGH; // HLSL Change.
     default:
     default:
       ParsedAttributesWithRange attrs(AttrFactory);
       ParsedAttributesWithRange attrs(AttrFactory);
       MaybeParseCXX11Attributes(attrs);
       MaybeParseCXX11Attributes(attrs);
@@ -4000,6 +4000,7 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration(DeclSpec::TST TagType,
     Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
     Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
       << Result.IsIfExists;
       << Result.IsIfExists;
     // Fall through to skip.
     // Fall through to skip.
+    LLVM_FALLTHROUGH; // HLSL Change
       
       
   case IEB_Skip:
   case IEB_Skip:
     Braces.skipToEnd();
     Braces.skipToEnd();

+ 7 - 5
tools/clang/lib/Parse/ParseExpr.cpp

@@ -804,7 +804,7 @@ HLSLReservedKeyword:
     // Similarly 'indices', 'vertices', 'primitives' and 'payload' are keywords when used
     // Similarly 'indices', 'vertices', 'primitives' and 'payload' are keywords when used
     // as a type qualifer in mesh shader, but may still be used as a variable name.
     // as a type qualifer in mesh shader, but may still be used as a variable name.
     Tok.setKind(tok::identifier);
     Tok.setKind(tok::identifier);
-    __fallthrough;
+    LLVM_FALLTHROUGH;
     // HLSL Change Ends
     // HLSL Change Ends
   case tok::identifier: {      // primary-expression: identifier
   case tok::identifier: {      // primary-expression: identifier
                                // unqualified-id: identifier
                                // unqualified-id: identifier
@@ -1134,7 +1134,7 @@ HLSLReservedKeyword:
   case tok::kw__Alignof:   // unary-expression: '_Alignof' '(' type-name ')'
   case tok::kw__Alignof:   // unary-expression: '_Alignof' '(' type-name ')'
     if (!getLangOpts().C11)
     if (!getLangOpts().C11)
       Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
       Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
-    // fallthrough
+    LLVM_FALLTHROUGH; // HLSL Change
   case tok::kw_alignof:    // unary-expression: 'alignof' '(' type-id ')'
   case tok::kw_alignof:    // unary-expression: 'alignof' '(' type-id ')'
   case tok::kw___alignof:  // unary-expression: '__alignof' unary-expression
   case tok::kw___alignof:  // unary-expression: '__alignof' unary-expression
                            // unary-expression: '__alignof' '(' type-name ')'
                            // unary-expression: '__alignof' '(' type-name ')'
@@ -1218,7 +1218,7 @@ HLSLReservedKeyword:
                                            Ty.get(), nullptr);
                                            Ty.get(), nullptr);
       break;
       break;
     }
     }
-    // Fall through
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   case tok::annot_decltype:
   case tok::annot_decltype:
   case tok::kw_char:
   case tok::kw_char:
@@ -1338,6 +1338,7 @@ HLSLReservedKeyword:
     }
     }
 
 
     // Fall through to treat the template-id as an id-expression.
     // Fall through to treat the template-id as an id-expression.
+    LLVM_FALLTHROUGH; // HLSL Change
   }
   }
 
 
   case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id
   case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id
@@ -1459,9 +1460,9 @@ HLSLReservedKeyword:
       Res = ParseObjCMessageExpression();
       Res = ParseObjCMessageExpression();
       break;
       break;
     }
     }
-    // FALL THROUGH.
-  tok_default_case: // HLSL Change - add to target cases dead-code'd by HLSL
+    LLVM_FALLTHROUGH; // HLSL Change
   default:
   default:
+  tok_default_case: // HLSL Change - add to target cases dead-code'd by HLSL
     NotCastExpr = true;
     NotCastExpr = true;
     return ExprError();
     return ExprError();
   }
   }
@@ -1517,6 +1518,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
       }
       }
         
         
       // Fall through; this isn't a message send.
       // Fall through; this isn't a message send.
+      LLVM_FALLTHROUGH; // HLSL Change
                 
                 
     default:  // Not a postfix-expression suffix.
     default:  // Not a postfix-expression suffix.
       return LHS;
       return LHS;

+ 1 - 0
tools/clang/lib/Parse/ParseInit.cpp

@@ -515,6 +515,7 @@ bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
     Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
     Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
       << Result.IsIfExists;
       << Result.IsIfExists;
     // Fall through to skip.
     // Fall through to skip.
+    LLVM_FALLTHROUGH; // HLSL Change
       
       
   case IEB_Skip:
   case IEB_Skip:
     Braces.skipToEnd();
     Braces.skipToEnd();

+ 2 - 0
tools/clang/lib/Parse/ParseOpenMP.cpp

@@ -193,6 +193,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed) {
       // pseudo-clause OMPFlushClause.
       // pseudo-clause OMPFlushClause.
       PP.EnterToken(Tok);
       PP.EnterToken(Tok);
     }
     }
+    LLVM_FALLTHROUGH; // HLSL Change
   case OMPD_taskyield:
   case OMPD_taskyield:
   case OMPD_barrier:
   case OMPD_barrier:
   case OMPD_taskwait:
   case OMPD_taskwait:
@@ -204,6 +205,7 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(bool StandAloneAllowed) {
     }
     }
     HasAssociatedStatement = false;
     HasAssociatedStatement = false;
     // Fall through for further analysis.
     // Fall through for further analysis.
+    LLVM_FALLTHROUGH; // HLSL Change
   case OMPD_parallel:
   case OMPD_parallel:
   case OMPD_simd:
   case OMPD_simd:
   case OMPD_for:
   case OMPD_for:

+ 3 - 3
tools/clang/lib/Parse/ParseStmt.cpp

@@ -191,7 +191,7 @@ Retry:
     // E.g., center = <RHS>.
     // E.g., center = <RHS>.
     if (tok::isPunctuator(NextToken().getKind())) {
     if (tok::isPunctuator(NextToken().getKind())) {
       Tok.setKind(tok::identifier);
       Tok.setKind(tok::identifier);
-      __fallthrough;
+      LLVM_FALLTHROUGH;
     } else {
     } else {
       goto tok_default_case;
       goto tok_default_case;
     }
     }
@@ -235,9 +235,9 @@ Retry:
 
 
     // Fall through
     // Fall through
   }
   }
-
-  tok_default_case: // HLSL Change - add to target cases dead-code'd by HLSL
+  LLVM_FALLTHROUGH; // HLSL Change
   default: {
   default: {
+  tok_default_case: // HLSL Change - add to target cases dead-code'd by HLSL
     if ((getLangOpts().CPlusPlus || !OnlyStatement) && isDeclarationStatement()) {
     if ((getLangOpts().CPlusPlus || !OnlyStatement) && isDeclarationStatement()) {
       SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
       SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
       DeclGroupPtrTy Decl = ParseDeclaration(Declarator::BlockContext,
       DeclGroupPtrTy Decl = ParseDeclaration(Declarator::BlockContext,

+ 5 - 3
tools/clang/lib/Parse/ParseTentative.cpp

@@ -151,7 +151,7 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() {
       ConsumeToken();
       ConsumeToken();
       break;
       break;
     }
     }
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case tok::kw_typeof:
   case tok::kw_typeof:
   case tok::kw___attribute:
   case tok::kw___attribute:
   case tok::kw___underlying_type: {
   case tok::kw___underlying_type: {
@@ -208,7 +208,7 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() {
 
 
   case tok::annot_cxxscope:
   case tok::annot_cxxscope:
     ConsumeToken();
     ConsumeToken();
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   default:
   default:
     ConsumeToken();
     ConsumeToken();
 
 
@@ -1203,7 +1203,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
                      tok::kw_delete))   // ::delete
                      tok::kw_delete))   // ::delete
       return TPResult::False;
       return TPResult::False;
   }
   }
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case tok::kw___super:
   case tok::kw___super:
   case tok::kw_decltype:
   case tok::kw_decltype:
     // Annotate typenames and C++ scope specifiers.  If we get one, just
     // Annotate typenames and C++ scope specifiers.  If we get one, just
@@ -1430,6 +1430,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
     //
     //
 
 
     // simple-type-specifier:
     // simple-type-specifier:
+    LLVM_FALLTHROUGH; // HLSL Change
 
 
   case tok::annot_typename:
   case tok::annot_typename:
   case_typename:
   case_typename:
@@ -1456,6 +1457,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
       
       
       return TPResult::True;
       return TPResult::True;
     }
     }
+    LLVM_FALLTHROUGH; // HLSL Change
       
       
   case tok::kw_char:
   case tok::kw_char:
   case tok::kw_wchar_t:
   case tok::kw_wchar_t:

+ 3 - 2
tools/clang/lib/Parse/Parser.cpp

@@ -354,7 +354,7 @@ bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, SkipUntilFlags Flags) {
     case tok::semi:
     case tok::semi:
       if (HasFlagsSet(Flags, StopAtSemi))
       if (HasFlagsSet(Flags, StopAtSemi))
         return false;
         return false;
-      // FALL THROUGH.
+      LLVM_FALLTHROUGH; // HLSL Change
     default:
     default:
       // Skip this token.
       // Skip this token.
       ConsumeToken();
       ConsumeToken();
@@ -1505,7 +1505,7 @@ Parser::TryAnnotateName(bool IsAddressOfOperand,
         AnnotateScopeToken(SS, !WasScopeAnnotation);
         AnnotateScopeToken(SS, !WasScopeAnnotation);
       return ANK_TemplateName;
       return ANK_TemplateName;
     }
     }
-    // Fall through.
+    LLVM_FALLTHROUGH; // HLSL Change
   case Sema::NC_VarTemplate:
   case Sema::NC_VarTemplate:
   case Sema::NC_FunctionTemplate: {
   case Sema::NC_FunctionTemplate: {
     // We have a type, variable or function template followed by '<'.
     // We have a type, variable or function template followed by '<'.
@@ -1831,6 +1831,7 @@ bool Parser::isTokenEqualOrEqualTypo() {
     Diag(Tok, diag::err_invalid_token_after_declarator_suggest_equal)
     Diag(Tok, diag::err_invalid_token_after_declarator_suggest_equal)
         << Kind
         << Kind
         << FixItHint::CreateReplacement(SourceRange(Tok.getLocation()), "=");
         << FixItHint::CreateReplacement(SourceRange(Tok.getLocation()), "=");
+    LLVM_FALLTHROUGH; // HLSL Change
   case tok::equal:
   case tok::equal:
     return true;
     return true;
   }
   }

+ 2 - 1
tools/clang/lib/Rewrite/HTMLRewrite.cpp

@@ -400,13 +400,14 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, const Preprocessor &PP) {
       ++TokOffs;
       ++TokOffs;
       --TokLen;
       --TokLen;
       // FALL THROUGH to chop the 8
       // FALL THROUGH to chop the 8
+      LLVM_FALLTHROUGH; // HLSL Change
     case tok::wide_string_literal:
     case tok::wide_string_literal:
     case tok::utf16_string_literal:
     case tok::utf16_string_literal:
     case tok::utf32_string_literal:
     case tok::utf32_string_literal:
       // Chop off the L, u, U or 8 prefix
       // Chop off the L, u, U or 8 prefix
       ++TokOffs;
       ++TokOffs;
       --TokLen;
       --TokLen;
-      // FALL THROUGH.
+      LLVM_FALLTHROUGH; // HLSL Change
     case tok::string_literal:
     case tok::string_literal:
       // FIXME: Exclude the optional ud-suffix from the highlighted range.
       // FIXME: Exclude the optional ud-suffix from the highlighted range.
       HighlightRange(RB, TokOffs, TokOffs+TokLen, BufferStart,
       HighlightRange(RB, TokOffs, TokOffs+TokLen, BufferStart,

+ 2 - 0
tools/clang/lib/SPIRV/CapabilityVisitor.cpp

@@ -559,6 +559,7 @@ bool CapabilityVisitor::visitInstruction(SpirvInstruction *instr) {
       addCapability(spv::Capability::RayTracingKHR);
       addCapability(spv::Capability::RayTracingKHR);
       addExtension(Extension::KHR_ray_tracing, "SPV_KHR_ray_tracing", {});
       addExtension(Extension::KHR_ray_tracing, "SPV_KHR_ray_tracing", {});
     }
     }
+    break;
   }
   }
 
 
   case spv::Op::OpSetMeshOutputsEXT:
   case spv::Op::OpSetMeshOutputsEXT:
@@ -725,6 +726,7 @@ bool CapabilityVisitor::visit(SpirvExtInst *instr) {
     case GLSLstd450::GLSLstd450InterpolateAtOffset:
     case GLSLstd450::GLSLstd450InterpolateAtOffset:
       addExtension(Extension::AMD_gpu_shader_half_float, "16-bit float",
       addExtension(Extension::AMD_gpu_shader_half_float, "16-bit float",
                    instr->getSourceLocation());
                    instr->getSourceLocation());
+      break;
     default:
     default:
       break;
       break;
     }
     }

+ 2 - 1
tools/clang/lib/SPIRV/DeclResultIdMapper.cpp

@@ -2578,7 +2578,7 @@ bool DeclResultIdMapper::createStageVars(
             break;
             break;
           }
           }
         }
         }
-        // fall through
+        LLVM_FALLTHROUGH;
       default:
       default:
         emitError("invalid usage of semantic '%0' in shader profile %1", loc)
         emitError("invalid usage of semantic '%0' in shader profile %1", loc)
             << semanticToUse->str
             << semanticToUse->str
@@ -3399,6 +3399,7 @@ SpirvVariable *DeclResultIdMapper::getBuiltinVar(spv::BuiltIn builtIn,
   case spv::BuiltIn::SubgroupSize:
   case spv::BuiltIn::SubgroupSize:
   case spv::BuiltIn::SubgroupLocalInvocationId:
   case spv::BuiltIn::SubgroupLocalInvocationId:
     needsLegalization = true;
     needsLegalization = true;
+    LLVM_FALLTHROUGH;
   case spv::BuiltIn::HitTNV:
   case spv::BuiltIn::HitTNV:
   case spv::BuiltIn::RayTmaxNV:
   case spv::BuiltIn::RayTmaxNV:
   case spv::BuiltIn::RayTminNV:
   case spv::BuiltIn::RayTminNV:

Деякі файли не було показано, через те що забагато файлів було змінено