From: Julian Seward Date: Tue, 26 Sep 2017 15:40:05 +0000 (+0200) Subject: Minor debug printing fixes to do with IfThenElse. No functional change. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6afda3321a14cc1db49f9510841049ffee9c501a;p=thirdparty%2Fvalgrind.git Minor debug printing fixes to do with IfThenElse. No functional change. --- diff --git a/VEX/priv/host_generic_regs.c b/VEX/priv/host_generic_regs.c index 4d55c5b94d..f21255b0f1 100644 --- a/VEX/priv/host_generic_regs.c +++ b/VEX/priv/host_generic_regs.c @@ -374,9 +374,9 @@ static void ppHInstrVec(const HInstrVec* code, const HInstrIfThenElse* hite = isIfThenElse(instr); if (UNLIKELY(hite != NULL)) { print_depth(depth); - vex_printf(" if (!"); + vex_printf(" goto OOL on cc \""); ppCondCode(hite->ccOOL); - vex_printf(") then fall-through {\n"); + vex_printf("\", otherwise fall-through {\n"); ppHInstrVec(hite->fallThrough, isIfThenElse, ppInstr, ppCondCode, mode64, depth + 1, insn_num); print_depth(depth); diff --git a/VEX/priv/host_x86_isel.c b/VEX/priv/host_x86_isel.c index b98a196198..5c1b01a8c1 100644 --- a/VEX/priv/host_x86_isel.c +++ b/VEX/priv/host_x86_isel.c @@ -3960,7 +3960,7 @@ static void iselStmtVec(ISelEnv* env, IRStmtVec* stmts) iselStmtVec(env, likely_leg); if (vex_traceflags & VEX_TRACE_VCODE) { print_IRStmt_prefix(env->depth - 1); - vex_printf("} else {\n"); + vex_printf("} else OOL {\n"); } env->code = hite->outOfLine; iselStmtVec(env, unlikely_leg); diff --git a/VEX/priv/ir_defs.c b/VEX/priv/ir_defs.c index ee2fa7f831..66be24845b 100644 --- a/VEX/priv/ir_defs.c +++ b/VEX/priv/ir_defs.c @@ -1608,8 +1608,8 @@ void ppIRTempDefSet(const IRTempDefSet* defset, UInt depth) void ppIRIfThenElse_Hint(IRIfThenElse_Hint hint) { switch (hint) { - case IfThenElse_ThenLikely: vex_printf("IfThenElse_ThenLikely"); break; - case IfThenElse_ElseLikely: vex_printf("IfThenElse_ElseLikely"); break; + case IfThenElse_ThenLikely: vex_printf("ThenLikely"); break; + case IfThenElse_ElseLikely: vex_printf("ElseLikely"); break; default: vpanic("ppIRIfThenElse_Hint"); } } @@ -1625,17 +1625,37 @@ void ppIRIfThenElseCondHint(const IRIfThenElse* ite) void ppIRIfThenElse(const IRIfThenElse* ite, const IRTypeEnv* tyenv, UInt depth) { - ppIRIfThenElseCondHint(ite); - vex_printf(" then {\n"); + // A likely story! + const HChar* tLIKELY = "LIKELY"; + const HChar* tUNLIKELY = "UNLIKELY"; + const HChar* thenHint = "???"; + const HChar* elseHint = "???"; + switch (ite->hint) { + case IfThenElse_ThenLikely: + thenHint = tLIKELY; elseHint = tUNLIKELY; break; + case IfThenElse_ElseLikely: + thenHint = tUNLIKELY; elseHint = tLIKELY; break; + default: + break; // Something is b0rked! + } + + vex_printf("if ("); + ppIRExpr(ite->cond); + vex_printf(") then %s {\n", thenHint); ppIRStmtVec(ite->then_leg, tyenv, depth + 1); print_depth(depth); - vex_printf("} else {\n"); + vex_printf("} else %s {\n", elseHint); ppIRStmtVec(ite->else_leg, tyenv, depth + 1); print_depth(depth); - vex_printf("}\n"); + vex_printf("}"); + if (ite->phi_nodes->phis_used > 0) { + vex_printf("\n"); // because there are phi nodes, so we need a new line + } // else there are no phi nodes; this is the last line, so skip the \n ppIRPhiVec(ite->phi_nodes, depth); } +// Print an IRStmt, but not the final \n. That is a bit complex +// for the multi-line IfThenElse case. void ppIRStmt(const IRStmt* s, const IRTypeEnv* tyenv, UInt depth) { print_depth(depth); @@ -1782,7 +1802,8 @@ void ppIRTypeEnvDefd(const IRTypeEnv* tyenv, const IRTempDefSet* defset, void ppIRStmtVec(const IRStmtVec* stmts, const IRTypeEnv* tyenv, UInt depth) { ppIRTypeEnvDefd(tyenv, stmts->defset, depth); - vex_printf("\n"); + if (depth == 0) + vex_printf("\n"); for (UInt i = 0; i < stmts->stmts_used; i++) { ppIRStmt(stmts->stmts[i], tyenv, depth); vex_printf("\n");