From b4c7d3a08e2071f55d0cd8b9f47de15bf63fbf76 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 29 Jul 2025 13:55:45 +0200 Subject: [PATCH] build: stop calling unreachable() without arguments The unreachable(str) macro defined in src/util/macros.h is defined to accept a literal string as an argument. However the way it checks that the argument is a string literal, by prepending an empty string where the argument is used, i.e.: #define unreachabel(str) assert(!"" str) still allows users to call the macro with no arguments. This is confusing, so pass an empty string to all invocations of unreachable() for consistency. This is done with the following command: git grep -l '[^_]unreachable();' -- "src/**" | sort | uniq | \ while read file; \ do \ sed -e 's/\([^_]\)unreachable();/\1unreachable("");/g' -i "$file"; done This should not change the behaviour of the callers of unreachable() in a meaningful way, but there will be some cosmetic consequence. The changed invocations will now print: Assertion `!"" ""' failed. instead of Assertion `!""' failed. But this is also what happens for the invocations that do pass an argument, for instance `unreachable("Invalid type")` currently prints: Assertion `!"" "Invalid type"' failed. So all invocations now also have the same output style. Reviewed-by: Erik Faye-Lund Part-of: --- src/compiler/nir/nir_opt_intrinsics.c | 2 +- src/gallium/drivers/freedreno/a4xx/fd4_emit.c | 2 +- .../drivers/r300/compiler/r3xx_vertprog.c | 2 +- .../r300/compiler/radeon_program_alu.c | 10 ++++---- src/gallium/drivers/r300/r300_tgsi_to_rc.c | 2 +- src/gallium/drivers/r300/r300_vs.c | 2 +- src/imagination/pco/pco_builder.h | 10 ++++---- src/imagination/pco/pco_common.h.py | 2 +- src/imagination/pco/pco_group_instrs.c | 4 ++-- src/imagination/pco/pco_internal.h | 24 +++++++++---------- src/imagination/pco/pco_isa.h.py | 4 ++-- src/imagination/pco/pco_map.h.py | 24 +++++++++---------- src/imagination/pco/pco_nir.c | 2 +- src/imagination/pco/pco_nir_pvfio.c | 2 +- src/imagination/pco/pco_nir_vk.c | 2 +- src/imagination/pco/pco_opt.c | 4 ++-- src/imagination/pco/pco_print.c | 18 +++++++------- src/imagination/pco/pco_trans_nir.c | 16 ++++++------- src/imagination/pco/pco_validate.c | 4 ++-- src/imagination/vulkan/pvr_descriptor_set.c | 4 ++-- src/imagination/vulkan/pvr_pipeline.c | 6 ++--- src/vulkan/runtime/vk_meta.h | 4 ++-- 22 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/compiler/nir/nir_opt_intrinsics.c b/src/compiler/nir/nir_opt_intrinsics.c index e1927c6ae45..6b97c47e17c 100644 --- a/src/compiler/nir/nir_opt_intrinsics.c +++ b/src/compiler/nir/nir_opt_intrinsics.c @@ -214,7 +214,7 @@ try_opt_quad_vote(nir_builder *b, nir_alu_instr *alu, bool block_has_discard) lane = (nir_intrinsic_swizzle_mask(quad_broadcasts[i]) >> (j * 2)) & 0x3; break; default: - unreachable(); + unreachable(""); } lanes_read |= (1 << lane) << (j * 4); } diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index 2afc1895fcd..d53124258e7 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -303,7 +303,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, break; default: - unreachable(); + unreachable(""); } texconst0 = diff --git a/src/gallium/drivers/r300/compiler/r3xx_vertprog.c b/src/gallium/drivers/r300/compiler/r3xx_vertprog.c index ff954b4e815..d817278aa59 100644 --- a/src/gallium/drivers/r300/compiler/r3xx_vertprog.c +++ b/src/gallium/drivers/r300/compiler/r3xx_vertprog.c @@ -212,7 +212,7 @@ ei_math1_select(struct r300_vertex_program_code *vp, case RC_MATH_DX: hw_opcode = hw_opcode_dx; break; case RC_MATH_FF: hw_opcode = hw_opcode_ff; break; default: - unreachable(); + unreachable(""); } ei_math1(vp, hw_opcode, vpi, inst); } diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c index 2ce2acf9161..8ffa9f526b3 100644 --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.c +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.c @@ -156,10 +156,10 @@ radeonTransformALU(struct radeon_compiler *c, struct rc_instruction *inst, void case RC_OPCODE_DP2: transform_DP2(c, inst); return 1; case RC_OPCODE_KILP: transform_KILP(c, inst); return 1; case RC_OPCODE_RSQ: transform_RSQ(c, inst); return 1; - case RC_OPCODE_SEQ: unreachable(); - case RC_OPCODE_SGE: unreachable(); - case RC_OPCODE_SLT: unreachable(); - case RC_OPCODE_SNE: unreachable(); + case RC_OPCODE_SEQ: unreachable(""); + case RC_OPCODE_SGE: unreachable(""); + case RC_OPCODE_SLT: unreachable(""); + case RC_OPCODE_SNE: unreachable(""); default: return 0; } } @@ -172,7 +172,7 @@ transform_r300_vertex_CMP(struct radeon_compiler *c, struct rc_instruction *inst if (c->is_r500 && !rc_inst_has_three_diff_temp_srcs(inst)) return; - unreachable(); + unreachable(""); } static void diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c index 76930d4588a..ef3e5378cb2 100644 --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c @@ -166,7 +166,7 @@ static void transform_texture(struct rc_instruction * dst, struct tgsi_instructi dst->U.I.TexSrcTarget = RC_TEXTURE_2D_ARRAY; break; default: - unreachable(); + unreachable(""); break; } dst->U.I.TexSwizzle = RC_SWIZZLE_XYZW; diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index 4c0d8adda62..4c0e18d7a71 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -70,7 +70,7 @@ static void r300_shader_read_vs_outputs( assert(index == 0); /* Draw does clip vertex for us. */ if (r300->screen->caps.has_tcl) { - unreachable(); + unreachable(""); } break; diff --git a/src/imagination/pco/pco_builder.h b/src/imagination/pco/pco_builder.h index 84764b07464..f27b4406faf 100644 --- a/src/imagination/pco/pco_builder.h +++ b/src/imagination/pco/pco_builder.h @@ -210,7 +210,7 @@ static inline pco_func *pco_cursor_func(pco_cursor cursor) break; } - unreachable(); + unreachable(""); } /** @@ -238,7 +238,7 @@ static inline pco_cf_node *pco_cursor_cf_node(pco_cursor cursor) break; } - unreachable(); + unreachable(""); } /** @@ -274,7 +274,7 @@ static inline pco_block *pco_cursor_block(pco_cursor cursor) break; } - unreachable(); + unreachable(""); } /** @@ -312,7 +312,7 @@ static inline pco_instr *pco_cursor_instr(pco_cursor cursor) break; } - unreachable(); + unreachable(""); } /** @@ -355,7 +355,7 @@ static inline pco_igrp *pco_cursor_igrp(pco_cursor cursor) break; } - unreachable(); + unreachable(""); } /* Builder functions. */ diff --git a/src/imagination/pco/pco_common.h.py b/src/imagination/pco/pco_common.h.py index f97a718efa6..684f7cec0fb 100644 --- a/src/imagination/pco/pco_common.h.py +++ b/src/imagination/pco/pco_common.h.py @@ -49,7 +49,7 @@ const char *${enum.name}_str(uint64_t val) { break; } - unreachable(); + unreachable(""); } % endfor diff --git a/src/imagination/pco/pco_group_instrs.c b/src/imagination/pco/pco_group_instrs.c index 4ff575afeaa..190fa29fc83 100644 --- a/src/imagination/pco/pco_group_instrs.c +++ b/src/imagination/pco/pco_group_instrs.c @@ -48,7 +48,7 @@ static inline unsigned calc_da(pco_igrp *igrp) break; default: - unreachable(); + unreachable(""); } return da; @@ -102,7 +102,7 @@ static inline void calc_lengths(pco_igrp *igrp, unsigned *offset_bytes) break; default: - unreachable(); + unreachable(""); } total_length += igrp->enc.len.instrs[phase]; diff --git a/src/imagination/pco/pco_internal.h b/src/imagination/pco/pco_internal.h index 6bbe48ba70b..7a5cedac75d 100644 --- a/src/imagination/pco/pco_internal.h +++ b/src/imagination/pco/pco_internal.h @@ -667,7 +667,7 @@ static inline unsigned pco_igrp_variant(const pco_igrp *igrp, break; } - unreachable(); + unreachable(""); } /* Motions. */ @@ -808,7 +808,7 @@ static inline pco_block *pco_cf_node_first_block(pco_cf_node *cf_node) break; } - unreachable(); + unreachable(""); } /** @@ -836,7 +836,7 @@ static inline pco_block *pco_cf_node_last_block(pco_cf_node *cf_node) break; } - unreachable(); + unreachable(""); } static inline struct list_head *pco_parent_cf_node_body(pco_cf_node *cf_node) @@ -859,7 +859,7 @@ static inline struct list_head *pco_parent_cf_node_body(pco_cf_node *cf_node) break; } - unreachable(); + unreachable(""); } /** @@ -903,7 +903,7 @@ static inline pco_block *pco_next_block(pco_block *block) break; } - unreachable(); + unreachable(""); } /** @@ -948,7 +948,7 @@ static inline pco_block *pco_prev_block(pco_block *block) break; } - unreachable(); + unreachable(""); } /** @@ -1087,7 +1087,7 @@ static inline pco_instr *pco_igrp_first_instr(pco_igrp *igrp) if (igrp->instrs[p]) return igrp->instrs[p]; - unreachable(); + unreachable(""); } /** @@ -1102,7 +1102,7 @@ static inline pco_instr *pco_igrp_last_instr(pco_igrp *igrp) if (igrp->instrs[p]) return igrp->instrs[p]; - unreachable(); + unreachable(""); } /** @@ -1259,7 +1259,7 @@ static inline enum pco_bits pco_bits(unsigned bits) break; } - unreachable(); + unreachable(""); } /* PCO ref checkers. */ @@ -1430,7 +1430,7 @@ static inline unsigned pco_ref_get_bits(pco_ref ref) break; } - unreachable(); + unreachable(""); } /** @@ -1461,7 +1461,7 @@ static inline uint64_t pco_ref_get_imm(pco_ref ref) break; } - unreachable(); + unreachable(""); } /** @@ -1578,7 +1578,7 @@ static inline enum pco_movw01 pco_ref_get_movw01(pco_ref ref) break; } - unreachable(); + unreachable(""); } /** diff --git a/src/imagination/pco/pco_isa.h.py b/src/imagination/pco/pco_isa.h.py index c5d74813405..bf00b528406 100644 --- a/src/imagination/pco/pco_isa.h.py +++ b/src/imagination/pco/pco_isa.h.py @@ -42,7 +42,7 @@ static unsigned ${bit_set.name}_bytes(enum ${bit_set.name}_variant variant) default: break; } - unreachable(); + unreachable(""); } static unsigned ${bit_set.name}_encode_field(uint8_t *bin, enum ${bit_set.name}_field field, uint64_t val) @@ -71,7 +71,7 @@ static unsigned ${bit_set.name}_encode_field(uint8_t *bin, enum ${bit_set.name}_ break; } - unreachable(); + unreachable(""); } % for bit_struct in bit_set.bit_structs.values(): diff --git a/src/imagination/pco/pco_map.h.py b/src/imagination/pco/pco_map.h.py index b607ab43d4e..1edf29934fa 100644 --- a/src/imagination/pco/pco_map.h.py +++ b/src/imagination/pco/pco_map.h.py @@ -50,7 +50,7 @@ ${enum_map.type_to} ${enum_map.name}(${enum_map.type_from} val) % endfor default: - unreachable(); + unreachable(""); } } % else: @@ -62,7 +62,7 @@ ${enum_map.type_to} ${enum_map.name}(${enum_map.type_from} val) % endfor default: - unreachable(); + unreachable(""); } % endif @@ -124,7 +124,7 @@ static inline unsigned pco_map_reg_index(pco_ref ref) return pco_map_idx_bank(ref) | (ref.idx_reg.offset << 3); } - unreachable(); + unreachable(""); } static inline unsigned pco_map_reg_index_bits(pco_ref ref) @@ -134,7 +134,7 @@ static inline unsigned pco_map_reg_index_bits(pco_ref ref) else if (pco_ref_is_idx_reg(ref)) return 11; - unreachable(); + unreachable(""); } static inline @@ -195,7 +195,7 @@ enum pco_src_variant pco_igrp_src_variant(const pco_igrp *igrp, } % endfor - unreachable(); + unreachable(""); } static inline @@ -248,7 +248,7 @@ enum pco_dst_variant pco_igrp_dest_variant(pco_igrp *igrp) } % endfor - unreachable(); + unreachable(""); } % for encode_map in encode_maps.values(): @@ -303,7 +303,7 @@ void pco_map_igrp(pco_igrp *igrp, pco_instr *instr) info->type == PCO_OP_TYPE_PSEUDO ? "pseudo" : "hardware", info->str); - unreachable(); + unreachable(""); } static inline unsigned pco_igrp_hdr_map_encode(uint8_t *bin, pco_igrp *igrp) @@ -360,7 +360,7 @@ static inline unsigned pco_igrp_hdr_map_encode(uint8_t *bin, pco_igrp *igrp) break; } - unreachable(); + unreachable(""); } % for encode_map in encode_maps.values(): @@ -378,7 +378,7 @@ unsigned ${encode_map.name}_map_encode(uint8_t *bin, pco_instr *instr, unsigned break; } - unreachable(); + unreachable(""); } % else: unsigned ${encode_map.name}_map_encode(uint8_t *bin, pco_instr *instr) @@ -406,7 +406,7 @@ unsigned pco_instr_map_encode(uint8_t *bin, pco_igrp *igrp, enum pco_op_phase ph break; } - unreachable(); + unreachable(""); } static inline @@ -462,7 +462,7 @@ unsigned pco_srcs_map_encode(uint8_t *bin, pco_igrp *igrp, bool is_upper) break; } - unreachable(); + unreachable(""); } static inline @@ -536,7 +536,7 @@ unsigned pco_dests_map_encode(uint8_t *bin, pco_igrp *igrp) break; } - unreachable(); + unreachable(""); } #endif /* PCO_MAP_H */""" diff --git a/src/imagination/pco/pco_nir.c b/src/imagination/pco/pco_nir.c index 1d8558206b1..45735592bc9 100644 --- a/src/imagination/pco/pco_nir.c +++ b/src/imagination/pco/pco_nir.c @@ -390,7 +390,7 @@ static void gather_data(nir_shader *nir, pco_data *data) break; default: - unreachable(); + unreachable(""); } } diff --git a/src/imagination/pco/pco_nir_pvfio.c b/src/imagination/pco/pco_nir_pvfio.c index 8aafb8a600f..c1f3a956842 100644 --- a/src/imagination/pco/pco_nir_pvfio.c +++ b/src/imagination/pco/pco_nir_pvfio.c @@ -162,7 +162,7 @@ static bool lower_pfo(nir_builder *b, nir_instr *instr, void *cb_data) .io_xfb2 = nir_intrinsic_io_xfb2(intr)); util_dynarray_append(&state->stores, nir_intrinsic_instr *, store); } else { - unreachable(); + unreachable(""); } /* Remove the old store. */ diff --git a/src/imagination/pco/pco_nir_vk.c b/src/imagination/pco/pco_nir_vk.c index 8b61d75da7e..18b88a68d6c 100644 --- a/src/imagination/pco/pco_nir_vk.c +++ b/src/imagination/pco/pco_nir_vk.c @@ -83,7 +83,7 @@ static nir_def *lower_vk(nir_builder *b, nir_instr *instr, void *cb_data) break; } - unreachable(); + unreachable(""); } /** diff --git a/src/imagination/pco/pco_opt.c b/src/imagination/pco/pco_opt.c index 71a4a3cfb69..24ca5d83884 100644 --- a/src/imagination/pco/pco_opt.c +++ b/src/imagination/pco/pco_opt.c @@ -105,7 +105,7 @@ static inline bool pco_opt_prep_mods(pco_shader *shader, break; default: - unreachable(); + unreachable(""); } /* Source can already have the mod set. */ @@ -140,7 +140,7 @@ static inline bool pco_opt_prep_mods(pco_shader *shader, break; default: - unreachable(); + unreachable(""); } pco_builder b = pco_builder_create(func, pco_cursor_before_instr(mod)); diff --git a/src/imagination/pco/pco_print.c b/src/imagination/pco/pco_print.c index 3dc5005ac1f..27a342a2c45 100644 --- a/src/imagination/pco/pco_print.c +++ b/src/imagination/pco/pco_print.c @@ -236,7 +236,7 @@ static void pco_print_ref_color(pco_print_state *state, pco_ref ref) break; } - unreachable(); + unreachable(""); } /** @@ -288,7 +288,7 @@ static void _pco_print_ref(pco_print_state *state, pco_ref ref) break; default: - unreachable(); + unreachable(""); } pco_printf(state, "%s", pco_dtype_str(ref.dtype)); break; @@ -309,7 +309,7 @@ static void _pco_print_ref(pco_print_state *state, pco_ref ref) break; default: - unreachable(); + unreachable(""); } unsigned chans = pco_ref_get_chans(ref); @@ -410,7 +410,7 @@ static void pco_print_instr_mods(pco_print_state *state, break; default: - unreachable(); + unreachable(""); } } } @@ -474,7 +474,7 @@ static void _pco_print_instr(pco_print_state *state, pco_instr *instr) } default: - unreachable(); + unreachable(""); } printed = true; } else if (!list_is_empty(&instr->phi_srcs)) { @@ -548,7 +548,7 @@ static void _pco_print_phase(pco_print_state *state, default: break; } - unreachable(); + unreachable(""); } /** @@ -977,7 +977,7 @@ pco_print_func_sig(pco_print_state *state, pco_func *func, bool call) break; default: - unreachable(); + unreachable(""); } } @@ -1046,7 +1046,7 @@ static void _pco_print_cf_node(pco_print_state *state, pco_cf_node *cf_node) break; } - unreachable(); + unreachable(""); } /** @@ -1214,7 +1214,7 @@ void pco_print_cf_node_name(pco_shader *shader, pco_cf_node *cf_node) break; } - unreachable(); + unreachable(""); } /** diff --git a/src/imagination/pco/pco_trans_nir.c b/src/imagination/pco/pco_trans_nir.c index 11950bda4ad..d8f2c45a6dd 100644 --- a/src/imagination/pco/pco_trans_nir.c +++ b/src/imagination/pco/pco_trans_nir.c @@ -310,7 +310,7 @@ trans_load_input_fs(trans_ctx *tctx, nir_intrinsic_instr *intr, pco_ref dest) break; default: - unreachable(); + unreachable(""); } } @@ -380,7 +380,7 @@ trans_load_input_fs(trans_ctx *tctx, nir_intrinsic_instr *intr, pco_ref dest) default: /* Should have been previously lowered. */ - unreachable(); + unreachable(""); } } @@ -556,7 +556,7 @@ static pco_instr *trans_intr(trans_ctx *tctx, nir_intrinsic_instr *intr) printf("Unsupported intrinsic: \""); nir_print_instr(&intr->instr, stdout); printf("\"\n"); - unreachable(); + unreachable(""); break; } @@ -741,7 +741,7 @@ trans_scmp(trans_ctx *tctx, nir_op op, pco_ref dest, pco_ref src0, pco_ref src1) break; default: - unreachable(); + unreachable(""); } return pco_scmp(&tctx->b, dest, src0, src1, .tst_op_main = tst_op_main); @@ -789,7 +789,7 @@ static pco_instr *trans_logical(trans_ctx *tctx, break; default: - unreachable(); + unreachable(""); } return pco_logical(&tctx->b, dest, src0, src1, .logiop = logiop); @@ -1000,7 +1000,7 @@ static pco_instr *trans_alu(trans_ctx *tctx, nir_alu_instr *alu) printf("Unsupported alu instruction: \""); nir_print_instr(&alu->instr, stdout); printf("\"\n"); - unreachable(); + unreachable(""); } if (!pco_ref_is_scalar(dest)) @@ -1077,7 +1077,7 @@ static pco_instr *trans_instr(trans_ctx *tctx, nir_instr *ninstr) break; } - unreachable(); + unreachable(""); } /** @@ -1213,7 +1213,7 @@ static pco_block *trans_cf_nodes(trans_ctx *tctx, } default: - unreachable(); + unreachable(""); } cf_node->parent = parent_cf_node; diff --git a/src/imagination/pco/pco_validate.c b/src/imagination/pco/pco_validate.c index 16aaec044fd..2d7fbbd6d7c 100644 --- a/src/imagination/pco/pco_validate.c +++ b/src/imagination/pco/pco_validate.c @@ -97,7 +97,7 @@ static void pco_assert(struct val_state *state, break; default: - unreachable(); + unreachable(""); } printf(" ("); @@ -344,7 +344,7 @@ static inline bool ref_is_in_map(pco_ref ref, enum pco_ref_map ref_maps) break; default: - unreachable(); + unreachable(""); } } diff --git a/src/imagination/vulkan/pvr_descriptor_set.c b/src/imagination/vulkan/pvr_descriptor_set.c index 64530231220..ec38c8eac55 100644 --- a/src/imagination/vulkan/pvr_descriptor_set.c +++ b/src/imagination/vulkan/pvr_descriptor_set.c @@ -81,7 +81,7 @@ static unsigned pvr_descriptor_size(VkDescriptorType type) default: mesa_loge("Unsupported descriptor type %s.\n", vk_DescriptorType_to_str(type)); - unreachable(); + unreachable(""); } } @@ -510,7 +510,7 @@ void pvr_UpdateDescriptorSets(VkDevice _device, break; default: - unreachable(); + unreachable(""); } } diff --git a/src/imagination/vulkan/pvr_pipeline.c b/src/imagination/vulkan/pvr_pipeline.c index b159b96fce2..c0d14385c61 100644 --- a/src/imagination/vulkan/pvr_pipeline.c +++ b/src/imagination/vulkan/pvr_pipeline.c @@ -1739,7 +1739,7 @@ static void pvr_alloc_vs_varyings(pco_data *data, nir_shader *nir) break; default: - unreachable(); + unreachable(""); } } @@ -2019,7 +2019,7 @@ pvr_preprocess_shader_data(pco_data *data, } default: - unreachable(); + unreachable(""); } pvr_init_descriptors(data, nir, layout); @@ -2061,7 +2061,7 @@ pvr_postprocess_shader_data(pco_data *data, } default: - unreachable(); + unreachable(""); } pvr_setup_descriptors(data, nir, layout); diff --git a/src/vulkan/runtime/vk_meta.h b/src/vulkan/runtime/vk_meta.h index 7f3c068e8a2..76f97d1dac7 100644 --- a/src/vulkan/runtime/vk_meta.h +++ b/src/vulkan/runtime/vk_meta.h @@ -430,7 +430,7 @@ vk_image_view_type_to_sampler_dim(VkImageViewType view_type) return GLSL_SAMPLER_DIM_3D; default: - unreachable(); + unreachable(""); } } @@ -450,7 +450,7 @@ vk_image_view_type_is_array(VkImageViewType view_type) return false; default: - unreachable(); + unreachable(""); } }