]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Minor debug printing fixes to do with IfThenElse. No functional change.
authorJulian Seward <jseward@acm.org>
Tue, 26 Sep 2017 15:40:05 +0000 (17:40 +0200)
committerJulian Seward <jseward@acm.org>
Tue, 26 Sep 2017 15:40:05 +0000 (17:40 +0200)
VEX/priv/host_generic_regs.c
VEX/priv/host_x86_isel.c
VEX/priv/ir_defs.c

index 4d55c5b94db2a99408a816a3162a5302a897a582..f21255b0f176afd9ff33694f6293e84d2bac4ba0 100644 (file)
@@ -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);
index b98a196198be978f948ffd73c3c594b69b727c38..5c1b01a8c1f9dc4128de5140fb09f926f56f9999 100644 (file)
@@ -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);
index ee2fa7f83146b5e0ba47b2c8a40342768e7676b4..66be24845b3bb789a9f6d6d6bc7abe04433e6d53 100644 (file)
@@ -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");