From f45965024a57725aa26b06cd3007d300cd093517 Mon Sep 17 00:00:00 2001 From: sayeedkhannabil Date: Wed, 23 Aug 2023 20:19:56 -0500 Subject: [PATCH 1/7] Wraping both declaration and definition in #ifndef DISABLE_LOGGING. Fixes #83545 --- src/mono/mono/mini/helpers.c | 2 ++ src/mono/mono/mini/mini.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index 130210cf21be9..832737d66a2de 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -76,6 +76,7 @@ static const gint16 opidx [] = { #endif //#define ARCH_PREFIX "powerpc64-linux-gnu-" +#ifndef DISABLE_LOGGING const char* mono_inst_name (int op) { #ifndef DISABLE_LOGGING @@ -90,6 +91,7 @@ mono_inst_name (int 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.h b/src/mono/mono/mini/mini.h index eee8fd39bd5a5..5f7331486af89 100644 --- a/src/mono/mono/mini/mini.h +++ b/src/mono/mono/mini/mini.h @@ -2186,7 +2186,9 @@ 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); +#ifndef DISABLE_LOGGING const char* mono_inst_name (int op); +#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); From 0c381e148a8154b515ac91d7f7c474bf987c440b Mon Sep 17 00:00:00 2001 From: sayeedkhannabil Date: Mon, 28 Aug 2023 16:07:48 -0500 Subject: [PATCH 2/7] Removed repeated #ifndef DISABLE_LOGIN from `helpers.c`. fixes #83545 --- src/mono/mono/mini/helpers.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index 832737d66a2de..009b500fdff57 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -79,17 +79,12 @@ static const gint16 opidx [] = { #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 From aca933e5ad4344ad51106fd6f564f8709721f124 Mon Sep 17 00:00:00 2001 From: sayeedkhannabil Date: Tue, 12 Sep 2023 17:43:58 -0500 Subject: [PATCH 3/7] Adding DISABLE_LOGGING for testing --- src/mono/mono/mini/alias-analysis.c | 10 ++++++++-- src/mono/mono/mini/mini-codegen.c | 31 ++++++++++++++++++++++++----- src/mono/mono/mini/mini.c | 2 ++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/mono/mono/mini/alias-analysis.c b/src/mono/mono/mini/alias-analysis.c index 2e0d4507b9efb..d577c8c640d89 100644 --- a/src/mono/mono/mini/alias-analysis.c +++ b/src/mono/mono/mini/alias-analysis.c @@ -53,10 +53,13 @@ lower_load (MonoCompile *cfg, MonoInst *load, MonoInst *ldaddr) } if (replaced_op != load->opcode) { - if (cfg->verbose_level > 2) + if (cfg->verbose_level > 2) { + #ifndef DISABLE_LOGGING printf ("Incompatible load type: expected %s but got %s\n", mono_inst_name (replaced_op), mono_inst_name (load->opcode)); + #endif + } return FALSE; } else { if (cfg->verbose_level > 2) { printf ("mem2reg replacing: "); mono_print_ins (load); } @@ -84,10 +87,13 @@ lower_store (MonoCompile *cfg, MonoInst *store, MonoInst *ldaddr) if (replaced_op != store->opcode) { - if (cfg->verbose_level > 2) + if (cfg->verbose_level > 2) { + #ifndef DISABLE_LOGGING printf ("Incompatible store_reg type: expected %s but got %s\n", mono_inst_name (replaced_op), mono_inst_name (store->opcode)); + #endif + } return FALSE; } else { if (cfg->verbose_level > 2) { printf ("mem2reg replacing: "); mono_print_ins (store); } diff --git a/src/mono/mono/mini/mini-codegen.c b/src/mono/mono/mini/mini-codegen.c index 3ac049f9c4fde..b0fd0d949b5b8 100644 --- a/src/mono/mono/mini/mini-codegen.c +++ b/src/mono/mono/mini/mini-codegen.c @@ -438,10 +438,16 @@ mono_print_ins_index_strbuf (int i, MonoInst *ins) int sregs [MONO_MAX_SRC_REGS]; char spec_dest = (char)0, spec_src1 = (char)0, spec_src2 = (char)0, spec_src3 = (char)0; - if (i != -1) + if (i != -1) { + #ifndef DISABLE_LOGGING g_string_append_printf (sbuf, "\t%-2d %s", i, mono_inst_name (ins->opcode)); - else + #endif + } + else { + #ifndef DISABLE_LOGGING g_string_append_printf (sbuf, " %s", mono_inst_name (ins->opcode)); + #endif + } if (spec == (gpointer)MONO_ARCH_CPU_SPEC) { /* This is a lowered opcode */ if (ins->dreg != -1) { @@ -1153,12 +1159,21 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) spec = ins_get_spec (i); ispec = INS_INFO (i); - if ((spec [MONO_INST_DEST] && (ispec [MONO_INST_DEST] == ' '))) + if ((spec [MONO_INST_DEST] && (ispec [MONO_INST_DEST] == ' '))) { + #ifndef DISABLE_LOGGING g_error ("Instruction metadata for %s inconsistent.\n", mono_inst_name (i)); - if ((spec [MONO_INST_SRC1] && (ispec [MONO_INST_SRC1] == ' '))) + #endif + } + if ((spec [MONO_INST_SRC1] && (ispec [MONO_INST_SRC1] == ' '))) { + #ifndef DISABLE_LOGGING g_error ("Instruction metadata for %s inconsistent.\n", mono_inst_name (i)); - if ((spec [MONO_INST_SRC2] && (ispec [MONO_INST_SRC2] == ' '))) + #endif + } + if ((spec [MONO_INST_SRC2] && (ispec [MONO_INST_SRC2] == ' '))) { + #ifndef DISABLE_LOGGING g_error ("Instruction metadata for %s inconsistent.\n", mono_inst_name (i)); + #endif + } } #endif } @@ -1243,7 +1258,9 @@ mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) spec_dest = spec [MONO_INST_DEST]; if (G_UNLIKELY (spec == (gpointer)/*FIXME*/MONO_ARCH_CPU_SPEC)) { + #ifndef DISABLE_LOGGING g_error ("Opcode '%s' missing from machine description file.", mono_inst_name (ins->opcode)); + #endif } DEBUG (mono_print_ins_index (i, ins)); @@ -2286,7 +2303,9 @@ mono_opcode_to_cond (int opcode) case OP_CMOV_LGT_UN: return CMP_GT_UN; default: + #ifndef DISABLE_LOGGING printf ("%s\n", mono_inst_name (opcode)); + #endif g_assert_not_reached (); return (CompRelation)0; } @@ -2349,7 +2368,9 @@ mono_opcode_to_type (int opcode, int cmp_opcode) return CMP_TYPE_L; } } else { + #ifndef DISABLE_LOGGING g_error ("Unknown opcode '%s' in opcode_to_type", mono_inst_name (opcode)); + #endif return (CompType)0; } } diff --git a/src/mono/mono/mini/mini.c b/src/mono/mono/mini/mini.c index f96f13e32cc7c..c95eb298a3982 100644 --- a/src/mono/mono/mini/mini.c +++ b/src/mono/mono/mini/mini.c @@ -602,7 +602,9 @@ mono_decompose_op_imm (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins) mono_bblock_insert_before_ins (bb, ins, temp); if (opcode2 == -1) + #ifndef DISABLE_LOGGING g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode)); + #endif ins->opcode = GINT_TO_OPCODE (opcode2); if (ins->opcode == OP_LOCALLOC) From 3bbbe7560608c39f85033ab8f98bcb824bfd530c Mon Sep 17 00:00:00 2001 From: sayeedkhannabil Date: Tue, 12 Sep 2023 18:46:13 -0500 Subject: [PATCH 4/7] Added DISABLE_LOOGING wrapper on all instances of mono_inst_name. --- src/mono/mono/mini/mini-amd64.c | 6 +++++- src/mono/mono/mini/mini-arm64.c | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-amd64.c b/src/mono/mono/mini/mini-amd64.c index 1a2f9fff59d34..371ac1e703269 100644 --- a/src/mono/mono/mini/mini-amd64.c +++ b/src/mono/mono/mini/mini-amd64.c @@ -7600,13 +7600,17 @@ 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: + #ifndef DISABLE_LOGGING g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); + #endif g_assert_not_reached (); } - + + #ifndef DISABLE_LOGGING g_assertf ((code - cfg->native_code - offset) <= max_len, "wrong maximal instruction length of instruction %s (expected %d, got %d)", mono_inst_name (ins->opcode), max_len, (int)(code - cfg->native_code - offset)); + #endif } set_code_cursor (cfg, code); diff --git a/src/mono/mono/mini/mini-arm64.c b/src/mono/mono/mini/mini-arm64.c index 3ce2c9101f1a2..e0054069e047a 100644 --- a/src/mono/mono/mini/mini-arm64.c +++ b/src/mono/mono/mini/mini-arm64.c @@ -3493,7 +3493,9 @@ opcode_to_armcond (int opcode) case OP_COND_EXC_INO: return ARMCOND_VC; default: + #ifndef DISABLE_LOGGING printf ("%s\n", mono_inst_name (opcode)); + #endif g_assert_not_reached (); return -1; } @@ -5533,14 +5535,18 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; default: + #ifndef DISABLE_LOGGING g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); + #endif g_assert_not_reached (); } after_instruction_emit: if ((cfg->opt & MONO_OPT_BRANCH) && ((code - cfg->native_code - offset) > max_len)) { + #ifndef DISABLE_LOGGING g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %d)", mono_inst_name (ins->opcode), max_len, code - cfg->native_code - offset); + #endif g_assert_not_reached (); } From b0c438f9222bdd264308013a8be5415eea238c44 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 1 Apr 2024 15:06:59 -0400 Subject: [PATCH 5/7] Adjust based on feedback --- src/mono/mono/mini/helpers.c | 7 ++----- src/mono/mono/mini/mini-amd64.c | 4 ++-- src/mono/mono/mini/mini-arm.c | 8 ++++---- src/mono/mono/mini/mini-arm64.c | 6 +++--- src/mono/mono/mini/mini-codegen.c | 16 ++++++++-------- src/mono/mono/mini/mini-llvm.c | 6 +++--- src/mono/mono/mini/mini-ppc.c | 4 ++-- src/mono/mono/mini/mini-riscv.c | 10 +++++----- src/mono/mono/mini/mini-s390x.c | 2 +- src/mono/mono/mini/mini-x86.c | 4 ++-- src/mono/mono/mini/mini.c | 2 +- src/mono/mono/mini/mini.h | 12 +++++++++++- 12 files changed, 44 insertions(+), 37 deletions(-) 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..99d340e43c4c8 100644 --- a/src/mono/mono/mini/mini-ppc.c +++ b/src/mono/mono/mini/mini-ppc.c @@ -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..1dc41db791a95 100644 --- a/src/mono/mono/mini/mini-s390x.c +++ b/src/mono/mono/mini/mini-s390x.c @@ -5441,7 +5441,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } 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); From 8c96e927a45ec45d7310c63314ddb634a561bfdd Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 1 Apr 2024 15:25:41 -0400 Subject: [PATCH 6/7] Fix bad merge --- src/mono/mono/mini/alias-analysis.c | 4 +--- src/mono/mono/mini/mini-arm64.c | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mono/mono/mini/alias-analysis.c b/src/mono/mono/mini/alias-analysis.c index d577c8c640d89..9cc22258abe45 100644 --- a/src/mono/mono/mini/alias-analysis.c +++ b/src/mono/mono/mini/alias-analysis.c @@ -54,11 +54,9 @@ lower_load (MonoCompile *cfg, MonoInst *load, MonoInst *ldaddr) if (replaced_op != load->opcode) { if (cfg->verbose_level > 2) { - #ifndef DISABLE_LOGGING - printf ("Incompatible load type: expected %s but got %s\n", + printf ("Incompatible load type: expected " M_PRI_INST " but got %s\n", mono_inst_name (replaced_op), mono_inst_name (load->opcode)); - #endif } return FALSE; } else { diff --git a/src/mono/mono/mini/mini-arm64.c b/src/mono/mono/mini/mini-arm64.c index b14f2da407df3..7e95fc7a818ce 100644 --- a/src/mono/mono/mini/mini-arm64.c +++ b/src/mono/mono/mini/mini-arm64.c @@ -5809,7 +5809,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) if ((cfg->opt & MONO_OPT_BRANCH) && ((code - cfg->native_code - offset) > max_len)) { 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); - #endif g_assert_not_reached (); } From a09dc9812ba23ef7e5cb89cc891f1842f9b8ee38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 8 Apr 2024 16:19:08 +0200 Subject: [PATCH 7/7] Fix more usages of mono_inst_name without M_PRI_INST --- src/mono/mono/mini/alias-analysis.c | 6 ++---- src/mono/mono/mini/mini-amd64.c | 4 +--- src/mono/mono/mini/mini-ppc.c | 2 +- src/mono/mono/mini/mini-s390x.c | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/mono/mono/mini/alias-analysis.c b/src/mono/mono/mini/alias-analysis.c index 9cc22258abe45..abbdedb430747 100644 --- a/src/mono/mono/mini/alias-analysis.c +++ b/src/mono/mono/mini/alias-analysis.c @@ -54,7 +54,7 @@ lower_load (MonoCompile *cfg, MonoInst *load, MonoInst *ldaddr) if (replaced_op != load->opcode) { if (cfg->verbose_level > 2) { - printf ("Incompatible load type: expected " M_PRI_INST " but got %s\n", + printf ("Incompatible load type: expected " M_PRI_INST " but got " M_PRI_INST "\n", mono_inst_name (replaced_op), mono_inst_name (load->opcode)); } @@ -86,11 +86,9 @@ lower_store (MonoCompile *cfg, MonoInst *store, MonoInst *ldaddr) if (replaced_op != store->opcode) { if (cfg->verbose_level > 2) { - #ifndef DISABLE_LOGGING - printf ("Incompatible store_reg type: expected %s but got %s\n", + 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)); - #endif } return FALSE; } else { diff --git a/src/mono/mono/mini/mini-amd64.c b/src/mono/mono/mini/mini-amd64.c index 2a28e32801281..f019d35e38758 100644 --- a/src/mono/mono/mini/mini-amd64.c +++ b/src/mono/mono/mini/mini-amd64.c @@ -7773,12 +7773,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) g_warning ("unknown opcode " M_PRI_INST " in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__); g_assert_not_reached (); } - - #ifndef DISABLE_LOGGING + g_assertf ((code - cfg->native_code - offset) <= max_len, "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)); - #endif } set_code_cursor (cfg, code); diff --git a/src/mono/mono/mini/mini-ppc.c b/src/mono/mono/mini/mini-ppc.c index 99d340e43c4c8..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); } diff --git a/src/mono/mono/mini/mini-s390x.c b/src/mono/mono/mini/mini-s390x.c index 1dc41db791a95..c87ec5573bc5e 100644 --- a/src/mono/mono/mini/mini-s390x.c +++ b/src/mono/mono/mini/mini-s390x.c @@ -5436,7 +5436,7 @@ 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 (); }