Discussion:
vex: r3338 - in /branches/VEX_JIT_HACKS: priv/guest_generic_bb_to_IR.c priv/guest_x86_toIR.c priv/host_x86_isel.c priv/ir_defs.c priv/ir_inject.c priv/ir_opt.c pub/libvex_ir.h useful/test_main.c
(too old to reply)
s***@valgrind.org
2017-03-29 21:10:43 UTC
Permalink
Raw Message
Author: iraisr
Date: Wed Mar 29 22:10:43 2017
New Revision: 3338

Log:
Introduce new function ppIRTypeEnvDefd() which pretty prints IRTemp's
defined within an IRStmtVec using type information from IRTypeEnv.
Basically combines ppIRTypeEnv() and ppIRTempDefSet().

Modified:
branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c
branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c
branches/VEX_JIT_HACKS/priv/host_x86_isel.c
branches/VEX_JIT_HACKS/priv/ir_defs.c
branches/VEX_JIT_HACKS/priv/ir_inject.c
branches/VEX_JIT_HACKS/priv/ir_opt.c
branches/VEX_JIT_HACKS/pub/libvex_ir.h
branches/VEX_JIT_HACKS/useful/test_main.c

Modified: branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c (original)
+++ branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c Wed Mar 29 22:10:43 2017
@@ -394,7 +394,7 @@
/* Print the resulting IR, if needed. */
if (debug_print) {
for (i = first_stmt_idx; i < irsb->stmts->stmts_used; i++) {
- ppIRStmt_wrk(irsb->stmts->stmts[i], 3);
+ ppIRStmt(irsb->stmts->stmts[i], irsb->tyenv, 3);
vex_printf("\n");
}
}

Modified: branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c (original)
+++ branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c Wed Mar 29 22:10:43 2017
@@ -15475,7 +15475,7 @@
callback_opaque,
delta, archinfo, abiinfo, sigill_diag_IN );
for (i = x1; i < x2; i++) {
- ppIRStmt_wrk(irsb_IN->stmts->stmts[i], 4);
+ ppIRStmt(irsb_IN->stmts->stmts[i], irsb_IN->tyenv, 4);
vex_printf("\n");
}
/* Failure of this assertion is serious and denotes a bug in

Modified: branches/VEX_JIT_HACKS/priv/host_x86_isel.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/host_x86_isel.c (original)
+++ branches/VEX_JIT_HACKS/priv/host_x86_isel.c Wed Mar 29 22:10:43 2017
@@ -3864,7 +3864,7 @@
{
if (vex_traceflags & VEX_TRACE_VCODE) {
vex_printf("\n-- ");
- ppIRStmt(stmt);
+ ppIRStmt(stmt, env->type_env, 0);
vex_printf("\n");
}

@@ -4310,7 +4310,7 @@
default: break;
}
stmt_fail:
- ppIRStmt(stmt);
+ ppIRStmt(stmt, env->type_env, 0);
vpanic("iselStmt");
}


Modified: branches/VEX_JIT_HACKS/priv/ir_defs.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_defs.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_defs.c Wed Mar 29 22:10:43 2017
@@ -1585,7 +1585,7 @@
}
}

-static void ppIRPhiVec_wrk(const IRPhiVec* phis, UInt depth)
+void ppIRPhiVec(const IRPhiVec* phis, UInt depth)
{
for (UInt i = 0; i < phis->phis_used; i++) {
print_depth(depth);
@@ -1594,45 +1594,12 @@
}
}

-void ppIRPhiVec(const IRPhiVec* phis)
+void ppIRTempDefSet(const IRTempDefSet* defset, UInt depth)
{
- ppIRPhiVec_wrk(phis, 0);
+ ppIRTypeEnvDefd(NULL, defset, depth);
}

-static void ppIRTempDefSet_wrk(const IRTempDefSet* defd, UInt depth)
-{
- UInt tmps_printed = 0;
-
- for (UInt slot = 0; slot < defd->slots_used; slot++) {
- UChar slot_value = defd->set[slot];
- for (UInt bit = 0; bit < sizeof(UChar); bit++) {
- if (slot_value & (1 << bit)) {
- if (tmps_printed % 8 == 0)
- print_depth(depth);
-
- IRTemp tmp = slot * sizeof(UChar) + bit;
- ppIRTemp(tmp);
-
- if (tmps_printed % 8 == 7)
- vex_printf("\n");
- else
- vex_printf(" ");
-
- tmps_printed += 1;
- }
- }
- }
-
- if (tmps_printed > 0 && tmps_printed % 8 != 7)
- vex_printf("\n");
-}
-
-void ppIRTempDefSet(const IRTempDefSet* defd)
-{
- ppIRTempDefSet_wrk(defd, 0);
-}
-
-void ppIRStmt_wrk(const IRStmt* s, UInt depth)
+void ppIRStmt(const IRStmt* s, const IRTypeEnv* tyenv, UInt depth)
{
print_depth(depth);

@@ -1720,24 +1687,19 @@
vex_printf("if (");
ppIRExpr(s->Ist.IfThenElse.cond);
vex_printf(") then {\n");
- ppIRStmtVec_wrk(s->Ist.IfThenElse.then_leg, depth + 1);
+ ppIRStmtVec(s->Ist.IfThenElse.then_leg, tyenv, depth + 1);
print_depth(depth);
vex_printf("} else {\n");
- ppIRStmtVec_wrk(s->Ist.IfThenElse.else_leg, depth + 1);
+ ppIRStmtVec(s->Ist.IfThenElse.else_leg, tyenv, depth + 1);
print_depth(depth);
vex_printf("}\n");
- ppIRPhiVec_wrk(s->Ist.IfThenElse.phi_nodes, depth);
+ ppIRPhiVec(s->Ist.IfThenElse.phi_nodes, depth);
break;
default:
vpanic("ppIRStmt");
}
}

-void ppIRStmt(const IRStmt* s)
-{
- ppIRStmt_wrk(s, 0);
-}
-
void ppIRTypeEnv(const IRTypeEnv* env)
{
for (UInt i = 0; i < env->used; i++) {
@@ -1755,19 +1717,47 @@
vex_printf( "\n");
}

-void ppIRStmtVec_wrk(const IRStmtVec* stmts, UInt depth)
+void ppIRTypeEnvDefd(const IRTypeEnv* tyenv, const IRTempDefSet* defset,
+ UInt depth)
{
- ppIRTempDefSet_wrk(stmts->def_set, depth);
- vex_printf("\n");
- for (UInt i = 0; i < stmts->stmts_used; i++) {
- ppIRStmt_wrk(stmts->stmts[i], depth);
- vex_printf("\n");
+ UInt tmps_printed = 0;
+
+ for (UInt slot = 0; slot < defset->slots_used; slot++) {
+ UChar slot_value = defset->set[slot];
+ for (UInt bit = 0; bit < sizeof(UChar); bit++) {
+ if (slot_value & (1 << bit)) {
+ if (tmps_printed % 8 == 0)
+ print_depth(depth);
+
+ IRTemp tmp = slot * sizeof(UChar) + bit;
+ ppIRTemp(tmp);
+ if (tyenv != NULL) {
+ vex_printf("=");
+ ppIRType(tyenv->types[tmp]);
+ }
+
+ if (tmps_printed % 8 == 7)
+ vex_printf("\n");
+ else
+ vex_printf(" ");
+
+ tmps_printed += 1;
+ }
+ }
}
+
+ if (tmps_printed > 0 && tmps_printed % 8 != 7)
+ vex_printf("\n");
}

-void ppIRStmtVec(const IRStmtVec* stmts)
+void ppIRStmtVec(const IRStmtVec* stmts, const IRTypeEnv* tyenv, UInt depth)
{
- ppIRStmtVec_wrk(stmts, 0);
+ ppIRTypeEnvDefd(tyenv, stmts->defset, depth);
+ vex_printf("\n");
+ for (UInt i = 0; i < stmts->stmts_used; i++) {
+ ppIRStmt(stmts->stmts[i], tyenv, depth);
+ vex_printf("\n");
+ }
}

void ppIRSB ( const IRSB* bb )
@@ -1775,8 +1765,7 @@
UInt depth = 0;

vex_printf("IRSB {\n");
- ppIRTypeEnv(bb->tyenv);
- ppIRStmtVec_wrk(bb->stmts, depth + 1);
+ ppIRStmtVec(bb->stmts, bb->tyenv, depth + 1);
print_depth(depth + 1);
vex_printf("PUT(%d) = ", bb->offsIP);
ppIRExpr( bb->next );
@@ -2247,8 +2236,8 @@
IRTempDefSet* emptyIRTempDefSet(void)
{
IRTempDefSet* defset = LibVEX_Alloc_inline(sizeof(IRTempDefSet));
- defset->slots_used = 0;
- defset->slots_size = 8 / sizeof(UChar);
+ defset->slots_used = 0;
+ defset->slots_size = 8 / sizeof(UChar);
vassert(defset->slots_size >= 1);
defset->set = LibVEX_Alloc_inline(defset->slots_size * sizeof(UChar));
return defset;
@@ -2398,7 +2387,7 @@
stmts->stmts = LibVEX_Alloc_inline(stmts->stmts_size * sizeof(IRStmt*));
stmts->id = IRStmtVecID_INVALID;
stmts->parent = NULL;
- stmts->def_set = emptyIRTempDefSet();
+ stmts->defset = emptyIRTempDefSet();
return stmts;
}

@@ -2613,16 +2602,16 @@
return vec2;
}

-IRTempDefSet* deepCopyIRTempDefSet(const IRTempDefSet* def_set)
+IRTempDefSet* deepCopyIRTempDefSet(const IRTempDefSet* defset)
{
- IRTempDefSet* def_set2 = LibVEX_Alloc_inline(sizeof(IRTempDefSet));
- def_set2->slots_used = def_set2->slots_size = def_set->slots_used;
- UChar* set2 = LibVEX_Alloc_inline(def_set2->slots_used * sizeof(UChar));
- for (UInt i = 0; i < def_set2->slots_used; i++) {
- set2[i] = def_set->set[i];
+ IRTempDefSet* defset2 = LibVEX_Alloc_inline(sizeof(IRTempDefSet));
+ defset2->slots_used = defset2->slots_size = defset->slots_used;
+ UChar* set2 = LibVEX_Alloc_inline(defset2->slots_used * sizeof(UChar));
+ for (UInt i = 0; i < defset2->slots_used; i++) {
+ set2[i] = defset->set[i];
}
- def_set2->set = set2;
- return def_set2;
+ defset2->set = set2;
+ return defset2;
}

IRStmt* deepCopyIRStmt(const IRStmt* s, IRStmtVec* parent)
@@ -2697,7 +2686,7 @@
IRStmtVec* vec2 = LibVEX_Alloc_inline(sizeof(IRStmtVec));
vec2->id = src->id;
vec2->parent = parent;
- vec2->def_set = deepCopyIRTempDefSet(src->def_set);
+ vec2->defset = deepCopyIRTempDefSet(src->defset);
vec2->stmts_used = vec2->stmts_size = src->stmts_used;
IRStmt **stmts2 = LibVEX_Alloc_inline(vec2->stmts_used * sizeof(IRStmt*));
for (UInt i = 0; i < vec2->stmts_used; i++) {
@@ -3772,38 +3761,38 @@
/*--- Helper functions for the IR -- IR Temp Defined Set ---*/
/*---------------------------------------------------------------*/

-void setIRTempDefined(IRTempDefSet* def_set, IRTemp tmp)
+void setIRTempDefined(IRTempDefSet* defset, IRTemp tmp)
{
UInt slots_required = (tmp + sizeof(UChar)) / sizeof(UChar);

- if (slots_required >= def_set->slots_size) {
- UInt new_size = (slots_required > 2 * def_set->slots_size) ?
- slots_required : 2 * def_set->slots_size;
+ if (slots_required >= defset->slots_size) {
+ UInt new_size = (slots_required > 2 * defset->slots_size) ?
+ slots_required : 2 * defset->slots_size;
UChar* new_set = LibVEX_Alloc_inline(new_size * sizeof(UChar));
- for (UInt i = 0; i < def_set->slots_used; i++) {
- new_set[i] = def_set->set[i];
+ for (UInt i = 0; i < defset->slots_used; i++) {
+ new_set[i] = defset->set[i];
}
- def_set->set = new_set;
- def_set->slots_size = new_size;
+ defset->set = new_set;
+ defset->slots_size = new_size;
}

- if (slots_required > def_set->slots_used) {
- for (UInt i = def_set->slots_used; i < slots_required; i++) {
- def_set->set[i] = 0;
+ if (slots_required > defset->slots_used) {
+ for (UInt i = defset->slots_used; i < slots_required; i++) {
+ defset->set[i] = 0;
}
- def_set->slots_used = slots_required;
+ defset->slots_used = slots_required;
}

- vassert(!isIRTempDefined(def_set, tmp));
+ vassert(!isIRTempDefined(defset, tmp));

UInt mask = (1 << (tmp % sizeof(UChar)));
- def_set->set[tmp / sizeof(UChar)] |= mask;
+ defset->set[tmp / sizeof(UChar)] |= mask;
}

-void clearIRTempDefSet(IRTempDefSet* def_set)
+void clearIRTempDefSet(IRTempDefSet* defset)
{
- for (UInt i = 0; i < def_set->slots_used; i++) {
- def_set->set[i] = 0;
+ for (UInt i = 0; i < defset->slots_used; i++) {
+ defset->set[i] = 0;
}
}

@@ -3883,7 +3872,7 @@
env->used += 1;
env->types[tmp] = ty;
env->ids[tmp] = stmts->id;
- setIRTempDefined(stmts->def_set, tmp);
+ setIRTempDefined(stmts->defset, tmp);
return tmp;
}

@@ -4186,7 +4175,7 @@
ppIRSB(bb);
if (stmt) {
vex_printf("\nIN STATEMENT:\n\n");
- ppIRStmt_wrk(stmt, 1);
+ ppIRStmt(stmt, bb->tyenv, 1);
}
vex_printf("\n\nERROR = %s\n\n", what );
vpanic("sanityCheckFail: exiting due to bad IR");
@@ -4245,7 +4234,7 @@
IRStmtVecID id = tyenv->ids[tmp];
vassert(id != IRStmtVecID_INVALID);

- while (!(isIRTempDefined(stmts->def_set, tmp))) {
+ while (!(isIRTempDefined(stmts->defset, tmp))) {
stmts = stmts->parent;
if (stmts == NULL)
return False;

Modified: branches/VEX_JIT_HACKS/priv/ir_inject.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_inject.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_inject.c Wed Mar 29 22:10:43 2017
@@ -310,11 +310,14 @@
if (0) {
vex_printf("BEGIN inject\n");
if (iricb.t_result == Ity_I1 || sizeofIRType(iricb.t_result) <= 8) {
- ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 1]);
+ ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 1],
+ irsb->tyenv, 0);
} else if (sizeofIRType(iricb.t_result) == 16) {
- ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 2]);
+ ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 2],
+ irsb->tyenv, 0);
vex_printf("\n");
- ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 1]);
+ ppIRStmt(irsb->stmts->stmts[irsb->stmts->stmts_used - 1],
+ irsb->tyenv, 0);
}
vex_printf("\nEND inject\n");
}

Modified: branches/VEX_JIT_HACKS/priv/ir_opt.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_opt.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_opt.c Wed Mar 29 22:10:43 2017
@@ -520,7 +520,7 @@
break;
default:
vex_printf("\n");
- ppIRStmt(st);
+ ppIRStmt(st, tyenv, 0);
vex_printf("\n");
vpanic("flatten_Stmt");
}
@@ -532,7 +532,7 @@
IRStmtVec* out = emptyIRStmtVec();
out->parent = parent;
out->id = in->id;
- out->def_set = deepCopyIRTempDefSet(in->def_set);
+ out->defset = deepCopyIRTempDefSet(in->defset);
for (UInt i = 0; i < in->stmts_used; i++) {
flatten_Stmt(tyenv, out, in->stmts[i], out);
}
@@ -852,7 +852,7 @@

default:
vex_printf("\n");
- ppIRStmt(st);
+ ppIRStmt(st, NULL, 0);
vex_printf("\n");
vpanic("handle_gets_Stmt");
}
@@ -988,7 +988,7 @@
/* This Put is redundant because a later one will overwrite
it. So NULL (nop) it out. */
if (DEBUG_IROPT) {
- vex_printf("rPUT: "); ppIRStmt(st);
+ vex_printf("rPUT: "); ppIRStmt(st, tyenv, 0);
vex_printf("\n");
}
stmts->stmts[i] = IRStmt_NoOp();
@@ -1095,7 +1095,7 @@
IRStmtVec* stmts_out = emptyIRStmtVec();
stmts_out->id = stmts_in->id;
stmts_out->parent = (parent_env != NULL) ? parent_env->stmts : NULL;
- stmts_out->def_set = deepCopyIRTempDefSet(stmts_in->def_set);
+ stmts_out->defset = deepCopyIRTempDefSet(stmts_in->defset);

SubstEnv* env = LibVEX_Alloc_inline(sizeof(SubstEnv));
env->tyenv = tyenv;
@@ -2639,7 +2639,7 @@
{
# if 0
vex_printf("\nsubst and fold stmt\n");
- ppIRStmt(st);
+ ppIRStmt(st, env->tyenv, 0);
vex_printf("\n");
# endif

@@ -2862,7 +2862,7 @@
/* TODO-JIT: Pull the only remaining leg into the current IRStmtVec.
Here is what needs to be done:
1. Rewrite ID of all IRTemp's (in tyenv->ids) defined in the
- pulled leg. These are tracked in leg's def_set.
+ pulled leg. These are tracked in leg's defset.
2. Insert all statements from the leg in the env->stmts_out
at the current position. */
vpanic("IfThenElse leg lifting unimplemented");
@@ -2883,7 +2883,7 @@
}

default:
- vex_printf("\n"); ppIRStmt(st);
+ vex_printf("\n"); ppIRStmt(st, env->tyenv, 0);
vpanic("subst_and_fold_Stmt");
}
}
@@ -3208,7 +3208,7 @@
}
default:
vex_printf("\n");
- ppIRStmt(st);
+ ppIRStmt(st, NULL, 0);
vpanic("addUses_Stmt");
}
}
@@ -3262,7 +3262,7 @@
/* it's an IRTemp which never got used. Delete it. */
if (DEBUG_IROPT) {
vex_printf("DEAD: ");
- ppIRStmt(st);
+ ppIRStmt(st, NULL, 0);
vex_printf("\n");
}
stmts->stmts[i] = IRStmt_NoOp();
@@ -4298,7 +4298,7 @@
if (collapseChain(stmts, i - 1, var, &var2, &con2)) {
if (DEBUG_IROPT) {
vex_printf("replacing1 ");
- ppIRStmt(st);
+ ppIRStmt(st, NULL, 0);
vex_printf(" with ");
}
con2 += con;
@@ -4314,7 +4314,7 @@
IRExpr_Const(IRConst_U32(-con2)))
);
if (DEBUG_IROPT) {
- ppIRStmt(stmts->stmts[i]);
+ ppIRStmt(stmts->stmts[i], NULL, 0);
vex_printf("\n");
}
}
@@ -4331,7 +4331,7 @@
->Iex.RdTmp.tmp, &var2, &con2)) {
if (DEBUG_IROPT) {
vex_printf("replacing3 ");
- ppIRStmt(st);
+ ppIRStmt(st, NULL, 0);
vex_printf(" with ");
}
con2 += st->Ist.WrTmp.data->Iex.GetI.bias;
@@ -4342,7 +4342,7 @@
IRExpr_RdTmp(var2),
con2));
if (DEBUG_IROPT) {
- ppIRStmt(stmts->stmts[i]);
+ ppIRStmt(stmts->stmts[i], NULL, 0);
vex_printf("\n");
}
continue;
@@ -4356,7 +4356,7 @@
&var2, &con2)) {
if (DEBUG_IROPT) {
vex_printf("replacing2 ");
- ppIRStmt(st);
+ ppIRStmt(st, NULL, 0);
vex_printf(" with ");
}
con2 += puti->bias;
@@ -4366,7 +4366,7 @@
con2,
puti->data));
if (DEBUG_IROPT) {
- ppIRStmt(stmts->stmts[i]);
+ ppIRStmt(stmts->stmts[i], NULL, 0);
vex_printf("\n");
}
continue;
@@ -4600,7 +4600,7 @@
return False;

default:
- vex_printf("\n"); ppIRStmt(s2); vex_printf("\n");
+ vex_printf("\n"); ppIRStmt(s2, tyenv, 0); vex_printf("\n");
vpanic("guestAccessWhichMightOverlapPutI");
}

@@ -4714,7 +4714,7 @@
if (delete) {
if (DEBUG_IROPT) {
vex_printf("rPI: ");
- ppIRStmt(st);
+ ppIRStmt(st, tyenv, 0);
vex_printf("\n");
}
stmts->stmts[i] = IRStmt_NoOp();
@@ -4784,9 +4784,9 @@
{
*tmp += delta;

- /* Adjust IRTemp's ID and also def_set of the current IRStmtVec. */
+ /* Adjust IRTemp's ID and also defset of the current IRStmtVec. */
tyenv->ids[*tmp] = stmts->id;
- setIRTempDefined(stmts->def_set, *tmp);
+ setIRTempDefined(stmts->defset, *tmp);
}

static void deltaIRStmtVec(IRTypeEnv* tyenv, IRStmtVec* stmts,
@@ -4889,7 +4889,7 @@
break;
}
default:
- vex_printf("\n"); ppIRStmt(st); vex_printf("\n");
+ vex_printf("\n"); ppIRStmt(st, tyenv, 0); vex_printf("\n");
vpanic("deltaIRStmt");
}
}
@@ -4898,9 +4898,9 @@
static void deltaIRStmtVec(IRTypeEnv* tyenv, IRStmtVec* stmts,
UInt delta_tmp, UInt delta_id, IRStmtVec* parent)
{
- /* Clear the def_set now. It still points to original IRTemp's however
+ /* Clear the defset now. It still points to original IRTemp's however
we are now moving to another set of IRTemp's shifted by 'delta'. */
- clearIRTempDefSet(stmts->def_set);
+ clearIRTempDefSet(stmts->defset);
stmts->id += delta_id;
stmts->parent = parent;

@@ -5118,7 +5118,7 @@
nested IRStmtVec's. This can be achieved here. But we also need to keep
track in which IRStmtVec each IRTemp is defined and that can be set
only during traversal. So we do only types here and deal with IDs and
- def_set during statement traversal. */
+ defset during statement traversal. */
ensureSpaceInIRTypeEnv(bb1->tyenv, bb1->tyenv->used + n_vars);
for (i = 0; i < n_vars; i++) {
bb1->tyenv->types[n_vars + i] = bb2->tyenv->types[i];
@@ -5466,7 +5466,7 @@
return;
}
default:
- vex_printf("\n"); ppIRStmt(st); vex_printf("\n");
+ vex_printf("\n"); ppIRStmt(st, NULL, 0); vex_printf("\n");
vpanic("aoccCount_Stmt");
}
}
@@ -5852,7 +5852,7 @@
vpanic("TODO-JIT: what to do?");
break;
default:
- vex_printf("\n"); ppIRStmt(st); vex_printf("\n");
+ vex_printf("\n"); ppIRStmt(st, NULL, 0); vex_printf("\n");
vpanic("atbSubst_Stmt");
}
}
@@ -6640,7 +6640,7 @@
st->Ist.IfThenElse.else_leg);
break;
default:
- vex_printf("\n"); ppIRStmt(st);
+ vex_printf("\n"); ppIRStmt(st, tyenv, 0);
vpanic("do_XOR_TRANSFORMS_IRStmtVec");
}
}
@@ -6684,7 +6684,7 @@
/*--- iropt main ---*/
/*---------------------------------------------------------------*/

-static Bool iropt_verbose = False; /* True; */
+static Bool iropt_verbose = True; /* True; */


/* Do a simple cleanup pass on bb. This is: redundant Get removal,
@@ -6856,9 +6856,10 @@
tyenv, st->Ist.IfThenElse.then_leg);
considerExpensives_IRStmtVec(hasGetIorPutI, hasVorFtemps,
tyenv, st->Ist.IfThenElse.else_leg);
+ break;
default:
bad:
- ppIRStmt(st);
+ ppIRStmt(st, tyenv, 0);
vpanic("considerExpensives_IRStmtVec");
}
}

Modified: branches/VEX_JIT_HACKS/pub/libvex_ir.h
==============================================================================
--- branches/VEX_JIT_HACKS/pub/libvex_ir.h (original)
+++ branches/VEX_JIT_HACKS/pub/libvex_ir.h Wed Mar 29 22:10:43 2017
@@ -2728,7 +2728,7 @@
extern void ppIRPhi(const IRPhi*);
extern IRPhi* mkIRPhi(IRTemp dst, IRTemp srcThen, IRTemp srcElse);
extern IRPhi* deepCopyIRPhi(const IRPhi*);
-extern void ppIRPhiVec(const IRPhiVec*);
+extern void ppIRPhiVec(const IRPhiVec*, UInt depth);
extern IRPhiVec* emptyIRPhiVec(void);
extern IRPhiVec* deepCopyIRPhiVec(const IRPhiVec*);

@@ -2762,20 +2762,20 @@
}
IRTempDefSet;

-static inline Bool isIRTempDefined(const IRTempDefSet* def_set, IRTemp tmp)
+static inline Bool isIRTempDefined(const IRTempDefSet* defset, IRTemp tmp)
{
- if (tmp / sizeof(UChar) < def_set->slots_size) {
+ if (tmp / sizeof(UChar) < defset->slots_size) {
UInt mask = (1 << (tmp % sizeof(UChar)));
- return toBool(def_set->set[tmp / sizeof(UChar)] & mask);
+ return toBool(defset->set[tmp / sizeof(UChar)] & mask);
}
return False;
}

-extern void setIRTempDefined(IRTempDefSet* def_set, IRTemp tmp);
-extern void clearIRTempDefSet(IRTempDefSet* def_set);
-extern void ppIRTempDefSet(const IRTempDefSet* def_set);
+extern void setIRTempDefined(IRTempDefSet* defset, IRTemp tmp);
+extern void clearIRTempDefSet(IRTempDefSet* defset);
+extern void ppIRTempDefSet(const IRTempDefSet* defset, UInt depth);
extern IRTempDefSet* emptyIRTempDefSet(void);
-extern IRTempDefSet* deepCopyIRTempDefSet(const IRTempDefSet* def_set);
+extern IRTempDefSet* deepCopyIRTempDefSet(const IRTempDefSet* defset);

/* ------------------ Statements ------------------ */

@@ -2784,6 +2784,10 @@
struct _IRStmt
IRStmt;

+typedef
+ struct _IRTypeEnv
+ IRTypeEnv;
+
/* Uniquely identifies IRStmtVec in an IRSB, no matter how deeply nested. */
typedef UShort IRStmtVecID;

@@ -2804,12 +2808,14 @@
UInt stmts_used;
IRStmtVecID id;
struct _IRStmtVec* parent;
- IRTempDefSet* def_set;
+ IRTempDefSet* defset;
}
IRStmtVec;

-extern void ppIRStmtVec(const IRStmtVec*);
-extern void ppIRStmtVec_wrk(const IRStmtVec*, UInt depth);
+/* Pretty-prints a vector of statements. If 'tyenv' is not NULL, pretty-prints
+ IRStmtVec's defset using nicer ppIRTypeEnvDefd(). */
+extern void ppIRStmtVec(const IRStmtVec* stmts, const IRTypeEnv* tyenv,
+ UInt depth);

/* Allocates an empty IRStmtVec with an invalid IRStmtVecID.
Such an IRStmtVec needs to have a valid IRStmtVecID - get it from
@@ -3142,9 +3148,9 @@
Parent is required for "if-then-else" statements. */
extern IRStmt* deepCopyIRStmt(const IRStmt* src, IRStmtVec* parent);

-/* Pretty-print an IRStmt. */
-extern void ppIRStmt ( const IRStmt* );
-extern void ppIRStmt_wrk(const IRStmt*, UInt depth);
+/* Pretty-prints an IRStmt. 'tyenv' is eventually used for pretty-printing
+ nested IRStmtVec's and can be NULL. */
+extern void ppIRStmt(const IRStmt* stmt, const IRTypeEnv* tyenv, UInt depth);


/* ------------------ Basic Blocks ------------------ */
@@ -3156,26 +3162,30 @@
- 'types' which gives IRTemp's type
- 'ids' which gives ID of the defining IRStmtVec
*/
-
-typedef
- struct {
- IRType* types;
- IRStmtVecID* ids;
- UInt size;
- UInt used;
- }
- IRTypeEnv;
+struct _IRTypeEnv {
+ IRType* types;
+ IRStmtVecID* ids;
+ UInt size;
+ UInt used;
+};

/* Obtain a new IRTemp. New IRTemp is allocated from 'tyenv' and is marked
- as defined in 'stmts'->def_set. */
+ as defined in 'stmts'->defset. */
extern IRTemp newIRTemp(IRTypeEnv* tyenv, IRStmtVec* stmts, IRType);

/* Deep-copy a type environment */
extern IRTypeEnv* deepCopyIRTypeEnv ( const IRTypeEnv* );

-/* Pretty-print a type environment */
+/* Pretty-print a type environment. Use ppIRTypeEnvDefd() if possible which
+ combines also information from an IRTempDefSet to print only IRTemp's which
+ are defined in a given IRStmtVec. */
extern void ppIRTypeEnv ( const IRTypeEnv* );

+/* Much like ppIRTypeEnv() but prints only IRTemp's which are defined in a given
+ IRStmtVec. */
+extern void ppIRTypeEnvDefd(const IRTypeEnv* tyenv, const IRTempDefSet* defset,
+ UInt depth);
+
/* Ensures that this IRTypeEnv can hold at least new_size types and ids.
Useful for certain bulk transformations. */
extern void ensureSpaceInIRTypeEnv(IRTypeEnv*, UInt new_size);

Modified: branches/VEX_JIT_HACKS/useful/test_main.c
==============================================================================
--- branches/VEX_JIT_HACKS/useful/test_main.c (original)
+++ branches/VEX_JIT_HACKS/useful/test_main.c Wed Mar 29 22:10:43 2017
@@ -2605,7 +2605,7 @@
return isBogusAtom(st->Ist.Exit.guard);
default:
unhandled:
- ppIRStmt(st);
+ ppIRStmt(st, NULL, 0);
VG_(tool_panic)("hasBogusLiterals");
}
}
@@ -2659,7 +2659,7 @@
UInt first_stmt = bb->stmts->stmts_used;

if (verboze) {
- ppIRStmt(st);
+ ppIRStmt(st, bb->tyenv, 0);
VG_(printf)("\n\n");
}

@@ -2706,7 +2706,7 @@

default:
VG_(printf)("\n");
- ppIRStmt(st);
+ ppIRStmt(st, bb->tyenv, 0);
VG_(printf)("\n");
VG_(tool_panic)("memcheck: unhandled IRStmt");

@@ -2715,7 +2715,7 @@
if (verboze) {
for (UInt j = first_stmt; j < bb->stmts->stmts_used; j++) {
VG_(printf)(" ");
- ppIRStmt(bb->stmts->stmts[j]);
+ ppIRStmt(bb->stmts->stmts[j], bb->tyenv, 0);
VG_(printf)("\n");
}
VG_(printf)("\n");
@@ -2739,7 +2739,7 @@
if (verboze) {
for (UInt j = first_stmt; j < bb->stmts->stmts_used; j++) {
VG_(printf)(" ");
- ppIRStmt(bb->stmts->stmts[j]);
+ ppIRStmt(bb->stmts->stmts[j], bb->tyenv, 0);
VG_(printf)("\n");
}
VG_(printf)("\n");

Loading...