[Mesa-dev] [PATCH v2] glsl: Prefer unreachable("condition") over assert(!"condition")
Carl Worth
cworth at cworth.org
Thu Dec 11 11:50:44 PST 2014
The unreachable macro has the advantage (for modern compilers) of
hinting to the compiler that this code is actually unreachable. This
allows us to drop things like return statements or assignments that
existed only to quiet compiler warnings.
Also, this version is a bit easier to type correctly and understand
when reading without that seemingly out-of-place logical negation.
---
Thanks for the review, Ian. This second revision of this patch adopts all of
your recommendations: dropping unreachable return and assignments; and putting
two of the unreachable() calls back into assert().
I didn't change any of the strings being passed to unreachable(). If someone
really wants more descriptive strings there, then someone more familiar with
the code than I am should come up with something. But the current strings are
all the same as what was there before, so that shouldn't block this patch I
think.
-Carl
src/glsl/ast_function.cpp | 5 +-
src/glsl/ast_to_hir.cpp | 8 +--
src/glsl/glcpp/glcpp-parse.y | 2 +-
src/glsl/glsl_parser_extras.cpp | 5 +-
src/glsl/glsl_symbol_table.cpp | 6 +--
src/glsl/glsl_types.cpp | 19 +++----
src/glsl/ir.cpp | 66 +++++++-----------------
src/glsl/ir.h | 2 +-
src/glsl/ir_clone.cpp | 2 +-
src/glsl/ir_constant_expression.cpp | 8 +--
src/glsl/ir_equals.cpp | 2 +-
src/glsl/ir_validate.cpp | 2 +-
src/glsl/ir_visitor.h | 2 +-
src/glsl/link_interface_blocks.cpp | 2 +-
src/glsl/link_uniform_block_active_visitor.cpp | 3 +-
src/glsl/link_uniform_blocks.cpp | 2 +-
src/glsl/link_uniform_initializers.cpp | 4 +-
src/glsl/link_uniforms.cpp | 2 +-
src/glsl/link_varyings.cpp | 3 +-
src/glsl/loop_analysis.cpp | 2 +-
src/glsl/loop_controls.cpp | 3 +-
src/glsl/lower_packed_varyings.cpp | 4 +-
src/glsl/lower_packing_builtins.cpp | 2 +-
src/glsl/lower_ubo_reference.cpp | 8 ++-
src/glsl/lower_variable_index_to_cond_assign.cpp | 3 +-
src/glsl/lower_vector.cpp | 2 +-
src/glsl/opt_constant_propagation.cpp | 4 +-
src/glsl/opt_minmax.cpp | 2 +-
28 files changed, 65 insertions(+), 110 deletions(-)
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index cbff9d8..8c80a0d 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -661,8 +661,7 @@ dereference_component(ir_rvalue *src, unsigned component)
return dereference_component(col, r);
}
- assert(!"Should not get here.");
- return NULL;
+ unreachable("Should not get here.");
}
@@ -1016,7 +1015,7 @@ emit_inline_vector_constructor(const glsl_type *type,
data.b[i + base_component] = c->get_bool_component(i);
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 811a955..ae68142 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1193,7 +1193,7 @@ ast_expression::do_hir(exec_list *instructions,
switch (this->oper) {
case ast_aggregate:
- assert(!"ast_aggregate: Should never get here.");
+ unreachable("ast_aggregate: Should never get here.");
break;
case ast_assign: {
@@ -2314,7 +2314,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
: (qual->location + VARYING_SLOT_VAR0);
break;
case MESA_SHADER_COMPUTE:
- assert(!"Unexpected shader type");
+ unreachable("Unexpected shader type");
break;
}
} else {
@@ -5412,7 +5412,7 @@ ast_interface_block::hir(exec_list *instructions,
} else {
var_mode = ir_var_auto;
iface_type_name = "UNKNOWN";
- assert(!"interface block layout qualifier not found!");
+ unreachable("interface block layout qualifier not found!");
}
enum glsl_matrix_layout matrix_layout = GLSL_MATRIX_LAYOUT_INHERITED;
@@ -6008,7 +6008,7 @@ remove_per_vertex_blocks(exec_list *instructions,
}
break;
default:
- assert(!"Unexpected mode");
+ unreachable("Unexpected mode");
break;
}
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index f1119eb..f1c006e 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -1169,7 +1169,7 @@ _token_print (char **out, size_t *len, token_t *token)
/* Nothing to print. */
break;
default:
- assert(!"Error: Don't know how to print token.");
+ unreachable("Error: Don't know how to print token.");
break;
}
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 6893c7b..7bfc39e 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -348,7 +348,7 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
break;
case API_OPENGLES:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
/* FALLTHROUGH */
case API_OPENGLES2:
@@ -372,8 +372,7 @@ _mesa_shader_stage_to_string(unsigned stage)
case MESA_SHADER_GEOMETRY: return "geometry";
}
- assert(!"Should not get here.");
- return "unknown";
+ unreachable("Should not get here.");
}
/* This helper function will append the given message to the shader's
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index 2294dda..72e6c45 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -43,8 +43,7 @@ public:
dest = &ibo;
break;
default:
- assert(!"Unsupported interface variable mode!");
- return false;
+ unreachable("Unsupported interface variable mode!");
}
if (*dest != NULL) {
@@ -65,8 +64,7 @@ public:
case ir_var_shader_out:
return ibo;
default:
- assert(!"Unsupported interface variable mode!");
- return NULL;
+ unreachable("Unsupported interface variable mode!");
}
}
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 2d106a2..d76bdb6 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -239,8 +239,7 @@ glsl_type::sampler_index() const
case GLSL_SAMPLER_DIM_MS:
return (t->sampler_array) ? TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX : TEXTURE_2D_MULTISAMPLE_INDEX;
default:
- assert(!"Should not get here.");
- return TEXTURE_BUFFER_INDEX;
+ unreachable("Should not get here.");
}
}
@@ -471,8 +470,7 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns)
}
}
- assert(!"Should not get here.");
- return error_type;
+ unreachable("Should not get here.");
}
const glsl_type *
@@ -1012,8 +1010,7 @@ glsl_type::std140_base_alignment(bool row_major) const
return base_alignment;
}
- assert(!"not reached");
- return -1;
+ unreachable("not reached");
}
unsigned
@@ -1139,8 +1136,7 @@ glsl_type::std140_size(bool row_major) const
return size;
}
- assert(!"not reached");
- return -1;
+ unreachable("not reached");
}
@@ -1195,9 +1191,7 @@ glsl_type::count_attribute_slots() const
break;
}
- assert(!"Unexpected type in count_attribute_slots()");
-
- return 0;
+ unreachable("Unexpected type in count_attribute_slots()");
}
int
@@ -1221,8 +1215,7 @@ glsl_type::coordinate_components() const
size = 3;
break;
default:
- assert(!"Should not get here.");
- size = 1;
+ unreachable("Should not get here.");
break;
}
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index fe5601a..7fd59f3 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -61,7 +61,7 @@ update_rhs_swizzle(ir_swizzle_mask &m, unsigned from, unsigned to)
case 1: m.y = from; break;
case 2: m.z = from; break;
case 3: m.w = from; break;
- default: assert(!"Should not get here.");
+ default: unreachable("Should not get here.");
}
m.num_components = MAX2(m.num_components, (to + 1));
@@ -90,7 +90,7 @@ ir_assignment::set_lhs(ir_rvalue *lhs)
case 1: c = swiz->mask.y; break;
case 2: c = swiz->mask.z; break;
case 3: c = swiz->mask.w; break;
- default: assert(!"Should not get here.");
+ default: unreachable("Should not get here.");
}
write_mask |= (((this->write_mask >> i) & 1) << c);
@@ -317,8 +317,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
break;
default:
- assert(!"not reached: missing automatic type setup for ir_expression");
- this->type = op0->type;
+ unreachable("not reached: missing automatic type setup for ir_expression");
break;
}
}
@@ -414,8 +413,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
break;
default:
- assert(!"not reached: missing automatic type setup for ir_expression");
- this->type = glsl_type::float_type;
+ unreachable("not reached: missing automatic type setup for ir_expression");
}
}
@@ -445,7 +443,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1,
break;
default:
- assert(!"not reached: missing automatic type setup for ir_expression");
+ unreachable("not reached: missing automatic type setup for ir_expression");
this->type = glsl_type::float_type;
}
}
@@ -695,7 +693,7 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i)
case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break;
case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break;
case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
}
@@ -766,7 +764,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
this->value.b[i] = value->value.b[0];
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
@@ -869,13 +867,8 @@ ir_constant::get_bool_component(unsigned i) const
case GLSL_TYPE_INT: return this->value.i[i] != 0;
case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0;
case GLSL_TYPE_BOOL: return this->value.b[i];
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
-
- /* Must return something to make the compiler happy. This is clearly an
- * error case.
- */
- return false;
}
float
@@ -886,13 +879,8 @@ ir_constant::get_float_component(unsigned i) const
case GLSL_TYPE_INT: return (float) this->value.i[i];
case GLSL_TYPE_FLOAT: return this->value.f[i];
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0f : 0.0f;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
-
- /* Must return something to make the compiler happy. This is clearly an
- * error case.
- */
- return 0.0;
}
int
@@ -903,13 +891,8 @@ ir_constant::get_int_component(unsigned i) const
case GLSL_TYPE_INT: return this->value.i[i];
case GLSL_TYPE_FLOAT: return (int) this->value.f[i];
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
-
- /* Must return something to make the compiler happy. This is clearly an
- * error case.
- */
- return 0;
}
unsigned
@@ -920,13 +903,8 @@ ir_constant::get_uint_component(unsigned i) const
case GLSL_TYPE_INT: return this->value.i[i];
case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i];
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
-
- /* Must return something to make the compiler happy. This is clearly an
- * error case.
- */
- return 0;
}
ir_constant *
@@ -1026,7 +1004,7 @@ ir_constant::copy_offset(ir_constant *src, int offset)
}
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
@@ -1058,7 +1036,7 @@ ir_constant::copy_masked_offset(ir_constant *src, int offset, unsigned int mask)
value.b[i+offset] = src->get_bool_component(id++);
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
return;
}
}
@@ -1118,8 +1096,7 @@ ir_constant::has_value(const ir_constant *c) const
return false;
break;
default:
- assert(!"Should not get here.");
- return false;
+ unreachable("Should not get here.");
}
}
@@ -1159,8 +1136,7 @@ ir_constant::is_value(float f, int i) const
* Samplers cannot be constants, and the others should have been
* filtered out above.
*/
- assert(!"Should not get here.");
- return false;
+ unreachable("Should not get here.");
}
}
@@ -1576,8 +1552,7 @@ interpolation_string(unsigned interpolation)
case INTERP_QUALIFIER_NOPERSPECTIVE: return "noperspective";
}
- assert(!"Should not get here.");
- return "";
+ unreachable("Should not get here.");
}
@@ -1611,8 +1586,7 @@ ir_variable::enable_extension_warning(const char *extension)
}
}
- assert(!"Should not get here.");
- this->data.warn_extension_index = 0;
+ unreachable("Should not get here.");
}
const char *
@@ -1856,8 +1830,7 @@ vertices_per_prim(GLenum prim)
case GL_TRIANGLES_ADJACENCY:
return 6;
default:
- assert(!"Bad primitive");
- return 3;
+ unreachable("Bad primitive");
}
}
@@ -1900,6 +1873,5 @@ mode_string(const ir_variable *var)
break;
}
- assert(!"Should not get here.");
- return "invalid variable";
+ unreachable("Should not get here.");
}
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index a0f48b2..169a1c2 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -190,7 +190,7 @@ protected:
private:
ir_instruction()
{
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
}
};
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index dffa578..fc46cdd 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -362,7 +362,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
case GLSL_TYPE_INTERFACE:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 1e8b3a3..89f306a 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -473,7 +473,7 @@ constant_referenced(const ir_dereference *deref,
}
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
@@ -1580,7 +1580,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
data.b[idx] = op[1]->value.b[0];
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
break;
@@ -1666,7 +1666,7 @@ ir_swizzle::constant_expression_value(struct hash_table *variable_context)
case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break;
case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break;
case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
}
@@ -1741,7 +1741,7 @@ ir_dereference_array::constant_expression_value(struct hash_table *variable_cont
break;
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
diff --git a/src/glsl/ir_equals.cpp b/src/glsl/ir_equals.cpp
index 65376cd..cb51cdf 100644
--- a/src/glsl/ir_equals.cpp
+++ b/src/glsl/ir_equals.cpp
@@ -172,7 +172,7 @@ ir_texture::equals(ir_instruction *ir, enum ir_node_type ignore)
return false;
break;
default:
- assert(!"Unrecognized texture op");
+ unreachable("Unrecognized texture op");
}
return true;
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 5a6f8bb..2f0de77 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -621,7 +621,7 @@ ir_validate::visit_leave(ir_expression *ir)
/* The is_vector assertion above should prevent execution from ever
* getting here.
*/
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
diff --git a/src/glsl/ir_visitor.h b/src/glsl/ir_visitor.h
index 40f96ff..a1011fa 100644
--- a/src/glsl/ir_visitor.h
+++ b/src/glsl/ir_visitor.h
@@ -45,7 +45,7 @@ public:
* the hierarchy should not have \c visit methods.
*/
/*@{*/
- virtual void visit(class ir_rvalue *) { assert(!"unhandled error_type"); }
+ virtual void visit(class ir_rvalue *) { unreachable("unhandled error_type"); }
virtual void visit(class ir_variable *) = 0;
virtual void visit(class ir_function_signature *) = 0;
virtual void visit(class ir_function *) = 0;
diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp
index 0ce502d..99637f4 100644
--- a/src/glsl/link_interface_blocks.cpp
+++ b/src/glsl/link_interface_blocks.cpp
@@ -284,7 +284,7 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
/* Only in, out, and uniform interfaces are legal, so we should
* never get here.
*/
- assert(!"illegal interface type");
+ unreachable("illegal interface type");
continue;
}
diff --git a/src/glsl/link_uniform_block_active_visitor.cpp b/src/glsl/link_uniform_block_active_visitor.cpp
index 9da6a4b..6000fc3 100644
--- a/src/glsl/link_uniform_block_active_visitor.cpp
+++ b/src/glsl/link_uniform_block_active_visitor.cpp
@@ -68,8 +68,7 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
return b;
}
- assert(!"Should not get here.");
- return NULL;
+ unreachable("Should not get here.");
}
ir_visitor_status
diff --git a/src/glsl/link_uniform_blocks.cpp b/src/glsl/link_uniform_blocks.cpp
index 536fcd4..03e1de4 100644
--- a/src/glsl/link_uniform_blocks.cpp
+++ b/src/glsl/link_uniform_blocks.cpp
@@ -64,7 +64,7 @@ private:
(void) type;
(void) name;
(void) row_major;
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
}
virtual void visit_field(const glsl_type *type, const char *name,
diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp
index f6a60bc..431ad99 100644
--- a/src/glsl/link_uniform_initializers.cpp
+++ b/src/glsl/link_uniform_initializers.cpp
@@ -88,7 +88,7 @@ copy_constant_to_storage(union gl_constant_value *storage,
/* All other types should have already been filtered by other
* paths in the caller.
*/
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
@@ -301,7 +301,7 @@ link_set_uniform_initializers(struct gl_shader_program *prog,
} else if (type->contains_atomic()) {
/* we don't actually need to do anything. */
} else {
- assert(!"Explicit binding not on a sampler, UBO or atomic.");
+ unreachable("Explicit binding not on a sampler, UBO or atomic.");
}
} else if (var->constant_value) {
linker::set_uniform_initializer(mem_ctx, prog, var->name,
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index de2f6c9..6d716d5 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -523,7 +523,7 @@ private:
(void) type;
(void) name;
(void) row_major;
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
}
virtual void visit_field(const glsl_type *type, const char *name,
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 43da2c6..176fe90 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -993,8 +993,7 @@ varying_matches::compute_packing_order(const ir_variable *var)
case 3: return PACKING_ORDER_VEC3;
case 0: return PACKING_ORDER_VEC4;
default:
- assert(!"Unexpected value of vector_elements");
- return PACKING_ORDER_VEC4;
+ unreachable("Unexpected value of vector_elements");
}
}
diff --git a/src/glsl/loop_analysis.cpp b/src/glsl/loop_analysis.cpp
index 21d46eb..741e804 100644
--- a/src/glsl/loop_analysis.cpp
+++ b/src/glsl/loop_analysis.cpp
@@ -425,7 +425,7 @@ loop_analysis::visit_leave(ir_loop *ir)
case ir_binop_greater: cmp = ir_binop_less; break;
case ir_binop_lequal: cmp = ir_binop_gequal; break;
case ir_binop_gequal: cmp = ir_binop_lequal; break;
- default: assert(!"Should not get here.");
+ default: unreachable("Should not get here.");
}
}
diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
index 1c1d34f..9749d29 100644
--- a/src/glsl/loop_controls.cpp
+++ b/src/glsl/loop_controls.cpp
@@ -59,8 +59,7 @@ find_initial_value(ir_loop *loop, ir_variable *var)
case ir_type_function:
case ir_type_function_signature:
- assert(!"Should not get here.");
- return NULL;
+ unreachable("Should not get here.");
case ir_type_assignment: {
ir_assignment *assign = ir->as_assignment();
diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp
index 5e844c7..85a0c49 100644
--- a/src/glsl/lower_packed_varyings.cpp
+++ b/src/glsl/lower_packed_varyings.cpp
@@ -301,7 +301,7 @@ lower_packed_varyings_visitor::bitwise_assign_pack(ir_rvalue *lhs,
ir_expression(ir_unop_bitcast_f2i, lhs->type, rhs);
break;
default:
- assert(!"Unexpected type conversion while lowering varyings");
+ unreachable("Unexpected type conversion while lowering varyings");
break;
}
}
@@ -335,7 +335,7 @@ lower_packed_varyings_visitor::bitwise_assign_unpack(ir_rvalue *lhs,
ir_expression(ir_unop_bitcast_i2f, lhs->type, rhs);
break;
default:
- assert(!"Unexpected type conversion while lowering varyings");
+ unreachable("Unexpected type conversion while lowering varyings");
break;
}
}
diff --git a/src/glsl/lower_packing_builtins.cpp b/src/glsl/lower_packing_builtins.cpp
index db73c7b..d4da769 100644
--- a/src/glsl/lower_packing_builtins.cpp
+++ b/src/glsl/lower_packing_builtins.cpp
@@ -118,7 +118,7 @@ public:
*rvalue = split_unpack_half_2x16(op0);
break;
case LOWER_PACK_UNPACK_NONE:
- assert(!"not reached");
+ unreachable("not reached");
break;
}
diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 43dd067..eaaff76 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -207,13 +207,12 @@ interface_field_name(void *mem_ctx, char *base_name, ir_dereference *d,
}
default:
- assert(!"Should not get here.");
+ unreachable("Should not get here.");
break;
}
}
- assert(!"Should not get here.");
- return NULL;
+ unreachable("Should not get here.");
}
void
@@ -383,8 +382,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
break;
}
default:
- assert(!"not reached");
- deref = NULL;
+ unreachable("not reached");
break;
}
}
diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp
index d878cb0..fe52d35 100644
--- a/src/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/glsl/lower_variable_index_to_cond_assign.cpp
@@ -384,8 +384,7 @@ public:
return this->lower_temps;
}
- assert(!"Should not get here.");
- return false;
+ unreachable("Should not get here.");
}
bool needs_lowering(ir_dereference_array *deref) const
diff --git a/src/glsl/lower_vector.cpp b/src/glsl/lower_vector.cpp
index a658410..3a89b80 100644
--- a/src/glsl/lower_vector.cpp
+++ b/src/glsl/lower_vector.cpp
@@ -173,7 +173,7 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
case GLSL_TYPE_INT: d.i[assigned] = c->value.i[0]; break;
case GLSL_TYPE_FLOAT: d.f[assigned] = c->value.f[0]; break;
case GLSL_TYPE_BOOL: d.b[assigned] = c->value.b[0]; break;
- default: assert(!"Should not get here."); break;
+ default: unreachable("Should not get here."); break;
}
write_mask |= (1U << i);
diff --git a/src/glsl/opt_constant_propagation.cpp b/src/glsl/opt_constant_propagation.cpp
index c334e12..7f12a13 100644
--- a/src/glsl/opt_constant_propagation.cpp
+++ b/src/glsl/opt_constant_propagation.cpp
@@ -166,7 +166,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
case 1: channel = swiz->mask.y; break;
case 2: channel = swiz->mask.z; break;
case 3: channel = swiz->mask.w; break;
- default: assert(!"shouldn't be reached"); channel = 0; break;
+ default: unreachable("shouldn't be reached"); channel = 0; break;
}
} else {
channel = i;
@@ -204,7 +204,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
data.b[i] = found->constant->value.b[rhs_channel];
break;
default:
- assert(!"not reached");
+ unreachable("not reached");
break;
}
}
diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 32fb2d7..4a758a6 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -179,7 +179,7 @@ combine_constant(bool ismin, ir_constant *a, ir_constant *b)
c->value.f[i] = b->value.f[i];
break;
default:
- assert(!"not reached");
+ unreachable("not reached");
}
}
return c;
--
2.1.1
More information about the mesa-dev
mailing list