[tint][ice] Make the InternalCompilerErrors abort

ICEs are no longer tied to the diagnostic system, and it was assumed that once you ICE the application will terminate. This assumption was not guaranteed and the callers of an ICE would attempt to continue execution despite the compiler being in a broken state.
Attempting to continue execution after an ICE is UB and should be treated as a security issue.

Instead, print the error message and abort().
This will crash the GPU process in Chrome, but that is likely to happen anyway.

Add [[noreturn]] to the InternalCompilerError destructor, and remove all unreachable statements following a TINT_ICE(), TINT_UNREACHABLE(), TINT_UNIMPLEMENTED().
This reduces the stripped tint executable on Linux by ~130KB (1.5%)

Remove TINT_ASSERT_OR_RETURN() and TINT_ASSERT_OR_RETURN_VALUE().
Replace both with TINT_ASSERT() as the return is now unreachable.

Replace the use of EXPECT_FATAL_FAILURE() with EXPECT_DEATH().

Change-Id: Iacbd16c12484610d72aee9850e93742c6bae1bf3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/186623
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
index 35a7140..28a5f6f 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/hlsl/writer/ast_printer/ast_printer.cc
@@ -302,7 +302,6 @@
                     break;
                 default:
                     TINT_ICE() << "missing texel format for pixel local storage attachment";
-                    return SanitizedResult();
             }
             cfg.pls_member_to_rov_format.Add(it.first, format);
         }
@@ -501,7 +500,6 @@
                     break;
                 default:
                     TINT_UNREACHABLE() << "invalid vector size " << vec->Width();
-                    break;
             }
         }
         Line(&helpers_) << "}";
@@ -645,7 +643,6 @@
                                                     ->UnwrapPtrOrRef()
                                                     ->As<core::type::Vector>();
                                     TINT_UNREACHABLE() << "invalid vector size " << vec->Width();
-                                    break;
                                 }
                             }
                         }
@@ -904,7 +901,6 @@
                 TINT_ICE() << "lhs of index accessor should not be a pointer. These should have "
                               "been removed by transforms such as SimplifyPointers, "
                               "DecomposeMemoryAccess, and DirectVariableAccess";
-                return false;
             }
             return true;
         };
@@ -1036,7 +1032,6 @@
         case core::BinaryOp::kLogicalOr: {
             // These are both handled above.
             TINT_UNREACHABLE();
-            return false;
         }
         case core::BinaryOp::kEqual:
             out << "==";
@@ -1175,7 +1170,6 @@
             default:
                 TINT_UNREACHABLE() << "unsupported DecomposeMemoryAccess::Intrinsic address space:"
                                    << intrinsic->address_space;
-                return false;
         }
     }
 
@@ -1342,7 +1336,6 @@
         if (!ctor->Parameters()[0]->Type()->UnwrapRef()->is_float_matrix()) {
             TINT_UNREACHABLE()
                 << "found a single-parameter matrix initializer that is not identity initializer";
-            return false;
         }
     }
 
@@ -1663,14 +1656,12 @@
             }
             TINT_UNREACHABLE() << "unsupported DecomposeMemoryAccess::Intrinsic::DataType: "
                                << static_cast<int>(intrinsic->type);
-            return false;
         }
         default:
             break;
     }
     TINT_UNREACHABLE() << "unsupported DecomposeMemoryAccess::Intrinsic::Op: "
                        << static_cast<int>(intrinsic->op);
-    return false;
 }
 
 bool ASTPrinter::EmitStorageBufferAccess(StringStream& out,
@@ -1748,7 +1739,6 @@
             }
             TINT_UNREACHABLE() << "unsupported DecomposeMemoryAccess::Intrinsic::DataType: "
                                << static_cast<int>(intrinsic->type);
-            return false;
         }
 
         case Op::kStore: {
@@ -1819,7 +1809,6 @@
             }
             TINT_UNREACHABLE() << "unsupported DecomposeMemoryAccess::Intrinsic::DataType: "
                                << static_cast<int>(intrinsic->type);
-            return false;
         }
         default:
             // Break out to error case below
@@ -1829,7 +1818,6 @@
 
     TINT_UNREACHABLE() << "unsupported DecomposeMemoryAccess::Intrinsic::Op: "
                        << static_cast<int>(intrinsic->op);
-    return false;
 }
 
 bool ASTPrinter::EmitStorageAtomicIntrinsic(const ast::Function* func,
@@ -2035,7 +2023,6 @@
 
     TINT_UNREACHABLE() << "unsupported atomic DecomposeMemoryAccess::Intrinsic::Op: "
                        << static_cast<int>(intrinsic->op);
-    return false;
 }
 
 bool ASTPrinter::EmitWorkgroupAtomicCall(StringStream& out,
@@ -2233,7 +2220,6 @@
     }
 
     TINT_UNREACHABLE() << "unsupported atomic builtin: " << builtin->Fn();
-    return false;
 }
 
 bool ASTPrinter::EmitSelectCall(StringStream& out, const ast::CallExpression* expr) {
@@ -2458,7 +2444,6 @@
                 }
                 default:
                     TINT_ICE() << " unhandled data packing builtin";
-                    return false;
             }
 
             return true;
@@ -2524,7 +2509,6 @@
                     break;
                 default:
                     TINT_ICE() << "unhandled data packing builtin";
-                    return false;
             }
 
             return true;
@@ -2581,7 +2565,6 @@
         case wgsl::BuiltinFn::kPack4XU8Clamp:
         default:
             TINT_UNIMPLEMENTED() << builtin->Fn();
-            return false;
     }
 
     return CallBuiltinHelper(out, expr, builtin,
@@ -2598,7 +2581,6 @@
                                          break;
                                      default:
                                          TINT_ICE() << "Internal error: unhandled DP4a builtin";
-                                         return false;
                                  }
                                  Line(b) << "return " << functionName << "(" << params[0] << ", "
                                          << params[1] << ", accumulator);";
@@ -2618,7 +2600,6 @@
         out << "DeviceMemoryBarrierWithGroupSync()";
     } else {
         TINT_UNREACHABLE() << "unexpected barrier builtin type " << builtin->Fn();
-        return false;
     }
     return true;
 }
@@ -2631,7 +2612,6 @@
     } else {
         // subgroupBroadcast is already handled in the regular builtin flow.
         TINT_UNREACHABLE() << "unexpected subgroup builtin type " << builtin->Fn();
-        return false;
     }
     return true;
 }
@@ -2685,7 +2665,6 @@
     auto* texture = arg(Usage::kTexture);
     if (TINT_UNLIKELY(!texture)) {
         TINT_ICE() << "missing texture argument";
-        return false;
     }
 
     auto* texture_type = TypeOf(texture)->UnwrapRef()->As<core::type::Texture>();
@@ -2706,7 +2685,6 @@
                     switch (texture_type->dim()) {
                         case core::type::TextureDimension::kNone:
                             TINT_ICE() << "texture dimension is kNone";
-                            return false;
                         case core::type::TextureDimension::k1d:
                             num_dimensions = 1;
                             break;
@@ -2734,7 +2712,6 @@
                     switch (texture_type->dim()) {
                         default:
                             TINT_ICE() << "texture dimension is not arrayed";
-                            return false;
                         case core::type::TextureDimension::k2dArray:
                             num_dimensions = is_ms ? 4 : 3;
                             swizzle = ".z";
@@ -2749,7 +2726,6 @@
                     switch (texture_type->dim()) {
                         default:
                             TINT_ICE() << "texture dimension does not support mips";
-                            return false;
                         case core::type::TextureDimension::k1d:
                             num_dimensions = 2;
                             swizzle = ".y";
@@ -2771,7 +2747,6 @@
                     switch (texture_type->dim()) {
                         default:
                             TINT_ICE() << "texture dimension does not support multisampling";
-                            return false;
                         case core::type::TextureDimension::k2d:
                             num_dimensions = 3;
                             swizzle = ".z";
@@ -2784,7 +2759,6 @@
                     break;
                 default:
                     TINT_ICE() << "unexpected builtin";
-                    return false;
             }
 
             auto* level_arg = arg(Usage::kLevel);
@@ -2807,7 +2781,6 @@
             if (TINT_UNLIKELY(num_dimensions > 4)) {
                 TINT_ICE() << "Texture query builtin temporary vector has " << num_dimensions
                            << " dimensions";
-                return false;
             }
 
             // Declare a variable to hold the queried texture info
@@ -2840,7 +2813,6 @@
                     static constexpr char xyzw[] = {'x', 'y', 'z', 'w'};
                     if (TINT_UNLIKELY(num_dimensions < 0 || num_dimensions > 4)) {
                         TINT_ICE() << "vector dimensions are " << num_dimensions;
-                        return false;
                     }
                     for (int i = 0; i < num_dimensions; i++) {
                         if (i > 0) {
@@ -2937,7 +2909,6 @@
             break;
         default:
             TINT_ICE() << "Unhandled texture builtin '" << builtin << "'";
-            return false;
     }
 
     if (auto* sampler = arg(Usage::kSampler)) {
@@ -2950,7 +2921,6 @@
     auto* param_coords = arg(Usage::kCoords);
     if (TINT_UNLIKELY(!param_coords)) {
         TINT_ICE() << "missing coords argument";
-        return false;
     }
 
     auto emit_vector_appended_with_i32_zero = [&](const ast::Expression* vector) {
@@ -3038,7 +3008,6 @@
             TINT_ICE() << "WGSL return width (" << wgsl_ret_width
                        << ") is wider than HLSL return width (" << hlsl_ret_width << ") for "
                        << builtin->Fn();
-            return false;
         }
     }
 
@@ -3398,7 +3367,6 @@
                     return false;
                 default: {
                     TINT_ICE() << "unhandled address space " << sem->AddressSpace();
-                    return false;
                 }
             }
         },
@@ -3462,14 +3430,12 @@
         auto* storage = type->As<core::type::StorageTexture>();
         if (!storage) {
             TINT_ICE() << "Rasterizer Ordered View type isn't storage texture";
-            return false;
         }
         out << "RasterizerOrderedTexture2D";
         auto* component = ImageFormatToRWtextureType(storage->texel_format());
         if (TINT_UNLIKELY(!component)) {
             TINT_ICE() << "Unsupported StorageTexture TexelFormat: "
                        << static_cast<int>(storage->texel_format());
-            return false;
         }
         out << "<" << component << "> " << name;
     } else if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), name)) {
@@ -4341,7 +4307,6 @@
                     TINT_ICE()
                         << "runtime arrays may only exist in storage buffers, which should have "
                            "been transformed into a ByteAddressBuffer";
-                    return false;
                 }
                 const auto count = arr->ConstantCount();
                 if (!count) {
@@ -4405,10 +4370,9 @@
             out << mat->columns() << "x" << mat->rows();
             return true;
         },
-        [&](const core::type::Pointer*) {
-            TINT_ICE() << "Attempting to emit pointer type. These should have "
-                          "been removed with the SimplifyPointers transform";
-            return false;
+        [&](const core::type::Pointer*) -> bool {
+            TINT_ICE() << "Attempting to emit pointer type. These should have been removed with "
+                          "the SimplifyPointers transform";
         },
         [&](const core::type::Sampler* sampler) {
             out << "Sampler";
@@ -4425,7 +4389,6 @@
         [&](const core::type::Texture* tex) {
             if (TINT_UNLIKELY(tex->Is<core::type::ExternalTexture>())) {
                 TINT_ICE() << "Multiplanar external texture transform was not run.";
-                return false;
             }
 
             auto* storage = tex->As<core::type::StorageTexture>();
@@ -4459,7 +4422,6 @@
                     break;
                 default:
                     TINT_UNREACHABLE() << "unexpected TextureDimension " << tex->dim();
-                    return false;
             }
 
             if (storage) {
@@ -4467,7 +4429,6 @@
                 if (TINT_UNLIKELY(!component)) {
                     TINT_ICE() << "Unsupported StorageTexture TexelFormat: "
                                << static_cast<int>(storage->texel_format());
-                    return false;
                 }
                 out << "<" << component << ">";
             } else if (depth_ms) {
@@ -4483,7 +4444,6 @@
                     out << "uint4";
                 } else {
                     TINT_ICE() << "Unsupported multisampled texture type";
-                    return false;
                 }
                 out << ">";
             }