diff --git a/src/mono/mono/mini/alias-analysis.c b/src/mono/mono/mini/alias-analysis.c index 2e0d4507b9efb..abbdedb430747 100644 --- a/src/mono/mono/mini/alias-analysis.c +++ b/src/mono/mono/mini/alias-analysis.c @@ -53,10 +53,11 @@ lower_load (MonoCompile *cfg, MonoInst *load, MonoInst *ldaddr) } if (replaced_op != load->opcode) { - if (cfg->verbose_level > 2) - printf ("Incompatible load type: expected %s but got %s\n", + if (cfg->verbose_level > 2) { + printf ("Incompatible load type: expected " M_PRI_INST " but got " M_PRI_INST "\n", mono_inst_name (replaced_op), mono_inst_name (load->opcode)); + } return FALSE; } else { if (cfg->verbose_level > 2) { printf ("mem2reg replacing: "); mono_print_ins (load); } @@ -84,10 +85,11 @@ lower_store (MonoCompile *cfg, MonoInst *store, MonoInst *ldaddr) if (replaced_op != store->opcode) { - if (cfg->verbose_level > 2) - printf ("Incompatible store_reg type: expected %s but got %s\n", + if (cfg->verbose_level > 2) { + printf ("Incompatible store_reg type: expected " M_PRI_INST " but got " M_PRI_INST "\n", mono_inst_name (replaced_op), mono_inst_name (store->opcode)); + } return FALSE; } else { if (cfg->verbose_level > 2) { printf ("mem2reg replacing: "); mono_print_ins (store); } diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index 9d903fdbc24a5..e3860045d244c 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -76,20 +76,17 @@ static const gint16 opidx [] = { #endif //#define ARCH_PREFIX "powerpc64-linux-gnu-" +#ifndef DISABLE_LOGGING const char* mono_inst_name (int op) { -#ifndef DISABLE_LOGGING if (op >= OP_LOAD && op <= OP_LAST) return (const char*)&opstr + opidx [op - OP_LOAD]; if (op < OP_LOAD) return mono_opcode_name (op); g_error ("unknown opcode name for %d", op); return NULL; -#else - g_error ("unknown opcode name for %d", op); - g_assert_not_reached (); -#endif } +#endif void mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint idom) diff --git a/src/mono/mono/mini/mini-amd64.c b/src/mono/mono/mini/mini-amd64.c index d424577821ba2..f019d35e38758 100644 --- a/src/mono/mono/mini/mini-amd64.c +++ b/src/mono/mono/mini/mini-amd64.c @@ -7770,12 +7770,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) amd64_mov_membase_reg (code, ins->sreg1, MONO_STRUCT_OFFSET (MonoContext, gregs) + i * sizeof (target_mgreg_t), i, sizeof (target_mgreg_t)); break; default: - g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); + g_warning ("unknown opcode " M_PRI_INST " in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); g_assert_not_reached (); } g_assertf ((code - cfg->native_code - offset) <= max_len, - "wrong maximal instruction length of instruction %s (expected %d, got %d)", + "wrong maximal instruction length of instruction " M_PRI_INST " (expected %d, got %d)", mono_inst_name (ins->opcode), max_len, (int)(code - cfg->native_code - offset)); } diff --git a/src/mono/mono/mini/mini-arm.c b/src/mono/mono/mini/mini-arm.c index a6e6328e814af..9cab61db1cbc3 100644 --- a/src/mono/mono/mini/mini-arm.c +++ b/src/mono/mono/mini/mini-arm.c @@ -3439,7 +3439,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; if (opcode2 == -1) - g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode)); + g_error ("mono_op_imm_to_op failed for " M_PRI_INST "\n", mono_inst_name (ins->opcode)); ins->opcode = GUINT32_TO_OPCODE (opcode2); } if (ins->opcode == OP_SBB || ins->opcode == OP_ISBB || ins->opcode == OP_SUBCC) @@ -3497,7 +3497,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; if (opcode2 == -1) - g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode)); + g_error ("mono_op_imm_to_op failed for " M_PRI_INST "\n", mono_inst_name (ins->opcode)); ins->opcode = GINT32_TO_UINT16 (opcode2); break; } @@ -5957,12 +5957,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ARM_STR_IMM (code, i, ins->sreg1, MONO_STRUCT_OFFSET (MonoContext, regs) + i * sizeof (target_mgreg_t)); break; default: - g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); + g_warning ("unknown opcode " M_PRI_INST " in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); g_assert_not_reached (); } if ((cfg->opt & MONO_OPT_BRANCH) && ((code - cfg->native_code - offset) > max_len)) { - g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %d)", + g_warning ("wrong maximal instruction length of instruction " M_PRI_INST " (expected %d, got %d)", mono_inst_name (ins->opcode), max_len, code - cfg->native_code - offset); g_assert_not_reached (); } diff --git a/src/mono/mono/mini/mini-arm64.c b/src/mono/mono/mini/mini-arm64.c index 657aac2c79d8a..7e95fc7a818ce 100644 --- a/src/mono/mono/mini/mini-arm64.c +++ b/src/mono/mono/mini/mini-arm64.c @@ -3704,7 +3704,7 @@ opcode_to_armcond (int opcode) case OP_COND_EXC_INO: return ARMCOND_VC; default: - printf ("%s\n", mono_inst_name (opcode)); + printf ("" M_PRI_INST "\n", mono_inst_name (opcode)); g_assert_not_reached (); return -1; } @@ -5801,13 +5801,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; default: - g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); + g_warning ("unknown opcode " M_PRI_INST " in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); g_assert_not_reached (); } after_instruction_emit: if ((cfg->opt & MONO_OPT_BRANCH) && ((code - cfg->native_code - offset) > max_len)) { - g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %d)", + g_warning ("wrong maximal instruction length of instruction " M_PRI_INST " (expected %d, got %d)", mono_inst_name (ins->opcode), max_len, code - cfg->native_code - offset); g_assert_not_reached (); diff --git a/src/mono/mono/mini/mini-codegen.c b/src/mono/mono/mini/mini-codegen.c index 21b03a98ee7e0..210c1619f629b 100644 --- a/src/mono/mono/mini/mini-codegen.c +++ b/src/mono/mono/mini/mini-codegen.c @@ -439,9 +439,9 @@ mono_print_ins_index_strbuf (int i, MonoInst *ins) char spec_dest = (char)0, spec_src1 = (char)0, spec_src2 = (char)0, spec_src3 = (char)0; if (i != -1) - g_string_append_printf (sbuf, "\t%-2d %s", i, mono_inst_name (ins->opcode)); + g_string_append_printf (sbuf, "\t%-2d " M_PRI_INST "", i, mono_inst_name (ins->opcode)); else - g_string_append_printf (sbuf, " %s", mono_inst_name (ins->opcode)); + g_string_append_printf (sbuf, " " M_PRI_INST "", mono_inst_name (ins->opcode)); if (spec == (gpointer)MONO_ARCH_CPU_SPEC) { /* This is a lowered opcode */ if (ins->dreg != -1) { @@ -1160,11 +1160,11 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) ispec = INS_INFO (i); if ((spec [MONO_INST_DEST] && (ispec [MONO_INST_DEST] == ' '))) - g_error ("Instruction metadata for %s inconsistent.\n", mono_inst_name (i)); + g_error ("Instruction metadata for " M_PRI_INST " inconsistent.\n", mono_inst_name (i)); if ((spec [MONO_INST_SRC1] && (ispec [MONO_INST_SRC1] == ' '))) - g_error ("Instruction metadata for %s inconsistent.\n", mono_inst_name (i)); + g_error ("Instruction metadata for " M_PRI_INST " inconsistent.\n", mono_inst_name (i)); if ((spec [MONO_INST_SRC2] && (ispec [MONO_INST_SRC2] == ' '))) - g_error ("Instruction metadata for %s inconsistent.\n", mono_inst_name (i)); + g_error ("Instruction metadata for " M_PRI_INST " inconsistent.\n", mono_inst_name (i)); } #endif } @@ -1249,7 +1249,7 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) spec_dest = spec [MONO_INST_DEST]; if (G_UNLIKELY (spec == (gpointer)/*FIXME*/MONO_ARCH_CPU_SPEC)) { - g_error ("Opcode '%s' missing from machine description file.", mono_inst_name (ins->opcode)); + g_error ("Opcode '" M_PRI_INST "' missing from machine description file.", mono_inst_name (ins->opcode)); } DEBUG (mono_print_ins_index (i, ins)); @@ -2303,7 +2303,7 @@ mono_opcode_to_cond (int opcode) CompRelation rel = mono_opcode_to_cond_unchecked (opcode); if (rel == (CompRelation)-1) { - printf ("%s\n", mono_inst_name (opcode)); + printf ("" M_PRI_INST "\n", mono_inst_name (opcode)); g_assert_not_reached (); return (CompRelation)0; } @@ -2367,7 +2367,7 @@ mono_opcode_to_type (int opcode, int cmp_opcode) return CMP_TYPE_L; } } else { - g_error ("Unknown opcode '%s' in opcode_to_type", mono_inst_name (opcode)); + g_error ("Unknown opcode '" M_PRI_INST "' in opcode_to_type", mono_inst_name (opcode)); return (CompType)0; } } diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index f7e59ef5acbbf..c8481b41bf975 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -1028,7 +1028,7 @@ op_to_llvm_type (int opcode) case OP_LMUL_OVF_UN: return LLVMInt64Type (); default: - printf ("%s\n", mono_inst_name (opcode)); + printf ("" M_PRI_INST "\n", mono_inst_name (opcode)); g_assert_not_reached (); return NULL; } @@ -12445,12 +12445,12 @@ MONO_RESTORE_WARNING case OP_LOAD_GOTADDR: { char reason [128]; - sprintf (reason, "opcode %s", mono_inst_name (ins->opcode)); + sprintf (reason, "opcode " M_PRI_INST "", mono_inst_name (ins->opcode)); set_failure (ctx, reason); break; } default: - g_error ("opcode %d %s", ins->opcode, mono_inst_name (ins->opcode)); + g_error ("opcode %d " M_PRI_INST "", ins->opcode, mono_inst_name (ins->opcode)); break; } diff --git a/src/mono/mono/mini/mini-ppc.c b/src/mono/mono/mini/mini-ppc.c index b3514123b7e94..a5c1fbb2f9865 100644 --- a/src/mono/mono/mini/mini-ppc.c +++ b/src/mono/mono/mini/mini-ppc.c @@ -2420,7 +2420,7 @@ map_to_reg_reg_op (int op) return OP_STOREI8_MEMBASE_REG; } if (mono_op_imm_to_op (op) == -1) - g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (op)); + g_error ("mono_op_imm_to_op failed for " M_PRI_INST "\n", mono_inst_name (op)); return mono_op_imm_to_op (op); } @@ -4734,12 +4734,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; } default: - g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); + g_warning ("unknown opcode " M_PRI_INST " in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); g_assert_not_reached (); } if ((cfg->opt & MONO_OPT_BRANCH) && ((code - cfg->native_code - offset) > max_len)) { - g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %ld)", + g_warning ("wrong maximal instruction length of instruction " M_PRI_INST " (expected %d, got %ld)", mono_inst_name (ins->opcode), max_len, (glong)(code - cfg->native_code - offset)); g_assert_not_reached (); } diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 4f25347b37e67..4214f701ed2fe 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2155,7 +2155,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) NULLIFY_INS (ins); break; default: - g_print ("Can't decompose the OP %s\n", mono_inst_name (ins->opcode)); + g_print ("Can't decompose the OP " M_PRI_INST "\n", mono_inst_name (ins->opcode)); NOT_IMPLEMENTED; } } @@ -2801,7 +2801,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->sreg2 = RISCV_ZERO; } else { if (cfg->verbose_level > 1) { - g_print ("Unhandaled op %s following after OP_RCOMPARE\n", mono_inst_name (next_ins->opcode)); + g_print ("Unhandaled op " M_PRI_INST " following after OP_RCOMPARE\n", mono_inst_name (next_ins->opcode)); } NULLIFY_INS (ins); } @@ -2885,7 +2885,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->sreg2 = RISCV_ZERO; } else { if (cfg->verbose_level > 1) { - g_print ("Unhandaled op %s following after OP_FCOMPARE\n", mono_inst_name (next_ins->opcode)); + g_print ("Unhandaled op " M_PRI_INST " following after OP_FCOMPARE\n", mono_inst_name (next_ins->opcode)); } NULLIFY_INS (ins); } @@ -3302,7 +3302,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) * what should I do? */ if (cfg->verbose_level > 1) { - g_print ("Unhandaled op %s following after OP_{I|L}COMPARE{|_IMM}\n", + g_print ("Unhandaled op " M_PRI_INST " following after OP_{I|L}COMPARE{|_IMM}\n", mono_inst_name (next_ins->opcode)); } NULLIFY_INS (ins); @@ -5632,7 +5632,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } g_assertf ((code - cfg->native_code - offset) <= max_len, - "wrong maximal instruction length of instruction %s (expected %d, got %d)", + "wrong maximal instruction length of instruction " M_PRI_INST " (expected %d, got %d)", mono_inst_name (ins->opcode), max_len, (int)(code - cfg->native_code - offset)); } set_code_cursor (cfg, code); diff --git a/src/mono/mono/mini/mini-s390x.c b/src/mono/mono/mini/mini-s390x.c index a5f228ea20f1f..c87ec5573bc5e 100644 --- a/src/mono/mono/mini/mini-s390x.c +++ b/src/mono/mono/mini/mini-s390x.c @@ -5436,12 +5436,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; #endif default: - g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); + g_warning ("unknown opcode " M_PRI_INST " in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); g_assert_not_reached (); } if ((cfg->opt & MONO_OPT_BRANCH) && ((code - cfg->native_code - offset) > max_len)) { - g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %ld)", + g_warning ("wrong maximal instruction length of instruction " M_PRI_INST " (expected %d, got %ld)", mono_inst_name (ins->opcode), max_len, code - cfg->native_code - offset); g_assert_not_reached (); } diff --git a/src/mono/mono/mini/mini-x86.c b/src/mono/mono/mini/mini-x86.c index 80116fb5497f3..10a2d2f0255f7 100644 --- a/src/mono/mono/mini/mini-x86.c +++ b/src/mono/mono/mini/mini-x86.c @@ -4912,12 +4912,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) code = emit_get_last_error (code, ins->dreg); break; default: - g_warning ("unknown opcode %s\n", mono_inst_name (ins->opcode)); + g_warning ("unknown opcode " M_PRI_INST "\n", mono_inst_name (ins->opcode)); g_assert_not_reached (); } if (G_UNLIKELY ((code - cfg->native_code - offset) > GINT_TO_UINT(max_len))) { - g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %d)", + g_warning ("wrong maximal instruction length of instruction " M_PRI_INST " (expected %d, got %d)", mono_inst_name (ins->opcode), max_len, code - cfg->native_code - offset); g_assert_not_reached (); } diff --git a/src/mono/mono/mini/mini.c b/src/mono/mono/mini/mini.c index 92bf21887c59f..b467c2d446620 100644 --- a/src/mono/mono/mini/mini.c +++ b/src/mono/mono/mini/mini.c @@ -602,7 +602,7 @@ mono_decompose_op_imm (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins) mono_bblock_insert_before_ins (bb, ins, temp); if (opcode2 == -1) - g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode)); + g_error ("mono_op_imm_to_op failed for " M_PRI_INST "\n", mono_inst_name (ins->opcode)); ins->opcode = GINT_TO_OPCODE (opcode2); if (ins->opcode == OP_LOCALLOC) diff --git a/src/mono/mono/mini/mini.h b/src/mono/mono/mini/mini.h index 781cb54b0492c..8a8c3dde3c360 100644 --- a/src/mono/mono/mini/mini.h +++ b/src/mono/mono/mini/mini.h @@ -2183,7 +2183,17 @@ GString *mono_print_ins_index_strbuf (int i, MonoInst *ins); void mono_print_ins (MonoInst *ins); void mono_print_bb (MonoBasicBlock *bb, const char *msg); void mono_print_code (MonoCompile *cfg, const char *msg); -const char* mono_inst_name (int op); +#ifndef DISABLE_LOGGING +#define M_PRI_INST "%s" +const char * mono_inst_name(int opcode); +#else +#define M_PRI_INST "%d" +static inline int +mono_inst_name(int opcode) +{ + return opcode; +} +#endif int mono_op_to_op_imm (int opcode); int mono_op_imm_to_op (int opcode); int mono_load_membase_to_load_mem (int opcode);