Discussion:
vex: r3326 - in /branches/VEX_JIT_HACKS/priv: ir_defs.c ir_opt.c
(too old to reply)
s***@valgrind.org
2017-03-23 09:16:25 UTC
Permalink
Raw Message
Author: iraisr
Date: Thu Mar 23 09:16:25 2017
New Revision: 3326

Log:
Add new function addEmptyIfThenElse().
Make phi_nodes non-optional for IfThenElse.

Modified:
branches/VEX_JIT_HACKS/priv/ir_defs.c
branches/VEX_JIT_HACKS/priv/ir_opt.c

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 Thu Mar 23 09:16:25 2017
@@ -1693,10 +1693,7 @@
ppIRStmtVec_wrk(s->Ist.IfThenElse.else_leg, depth + 1);
print_depth(depth);
vex_printf("}\n");
- IRPhiVec* phi_nodes = s->Ist.IfThenElse.phi_nodes;
- if (phi_nodes != NULL) {
- ppIRPhiVec_wrk(phi_nodes, depth);
- }
+ ppIRPhiVec_wrk(s->Ist.IfThenElse.phi_nodes, depth);
break;
default:
vpanic("ppIRStmt");
@@ -3747,6 +3744,20 @@
addStmtToIRStmtVec(bb->stmts, st);
}

+IRStmt *addEmptyIfThenElse(IRSB* bb, IRStmtVec* parent, IRExpr* cond)
+{
+ IRStmtVec* then_leg = emptyIRStmtVec();
+ then_leg->tyenv->id = nextIRTyEnvID(bb);
+ then_leg->parent = parent;
+
+ IRStmtVec* else_leg = emptyIRStmtVec();
+ else_leg->tyenv->id = nextIRTyEnvID(bb);
+ else_leg->parent = parent;
+
+ IRStmt* st = IRStmt_IfThenElse(cond, then_leg, else_leg, emptyIRPhiVec());
+ addStmtToIRStmtVec(parent, st);
+ return st;
+}

/*---------------------------------------------------------------*/
/*--- Helper functions for the IR -- IR Type Environments ---*/
@@ -5062,10 +5073,8 @@
n_stmt_vecs, id_counts, gWordTy);
sanityCheckIRStmtVec(bb, else_leg, require_flat, def_counts,
n_stmt_vecs, id_counts, gWordTy);
- if (stmt->Ist.IfThenElse.phi_nodes != NULL) {
- sanityCheckIRPhiNodes(bb, stmts, stmt,
- stmt->Ist.IfThenElse.phi_nodes, def_counts);
- }
+ sanityCheckIRPhiNodes(bb, stmts, stmt,
+ stmt->Ist.IfThenElse.phi_nodes, def_counts);
}
}
}

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 Thu Mar 23 09:16:25 2017
@@ -3166,12 +3166,10 @@
Bool* else_set = new_deadcode_set(st->Ist.IfThenElse.then_leg->tyenv);

IRPhiVec* phi_nodes = st->Ist.IfThenElse.phi_nodes;
- if (phi_nodes != NULL) {
- for (UInt i = 0; i < phi_nodes->phis_used; i++) {
- const IRPhi* phi = phi_nodes->phis[i];
- addUses_Temp(then_set, phi->srcThen);
- addUses_Temp(else_set, phi->srcElse);
- }
+ for (UInt i = 0; i < phi_nodes->phis_used; i++) {
+ const IRPhi* phi = phi_nodes->phis[i];
+ addUses_Temp(then_set, phi->srcThen);
+ addUses_Temp(else_set, phi->srcElse);
}

Int i_unconditional_exit; // TODO-JIT: unused at the moment
@@ -4852,10 +4850,8 @@
deltaIRStmtVec(st->Ist.IfThenElse.else_leg, delta, id);

IRPhiVec* phi_nodes = st->Ist.IfThenElse.phi_nodes;
- if (phi_nodes != NULL) {
- for (UInt i = 0; i < phi_nodes->phis_used; i++) {
- deltaIRTemp(&phi_nodes->phis[i]->dst, delta, id);
- }
+ for (UInt i = 0; i < phi_nodes->phis_used; i++) {
+ deltaIRTemp(&phi_nodes->phis[i]->dst, delta, id);
}
break;
}
@@ -5409,10 +5405,8 @@
case Ist_IfThenElse: {
aoccCount_Expr(uses, st->Ist.IfThenElse.cond);
IRPhiVec* phi_nodes = st->Ist.IfThenElse.phi_nodes;
- if (phi_nodes != NULL) {
- for (UInt i = 0; i < phi_nodes->phis_used; i++) {
- uses[phi_nodes->phis[i]->dst.index]++;
- }
+ for (UInt i = 0; i < phi_nodes->phis_used; i++) {
+ uses[phi_nodes->phis[i]->dst.index]++;
}
return;
}
@@ -6177,14 +6171,12 @@
IRStmtVec* then_leg = st->Ist.IfThenElse.then_leg;
IRStmtVec* else_leg = st->Ist.IfThenElse.else_leg;
IRPhiVec* phi_nodes = st->Ist.IfThenElse.phi_nodes;
- if (phi_nodes != NULL) {
- for (UInt j = 0; j < phi_nodes->phis_used; j++) {
- IRPhi* phi = phi_nodes->phis[j];
- addStmtToIRStmtVec(then_leg, IRStmt_WrTmp(phi->dst,
- IRExpr_RdTmp(phi->srcThen)));
- addStmtToIRStmtVec(else_leg, IRStmt_WrTmp(phi->dst,
- IRExpr_RdTmp(phi->srcElse)));
- }
+ for (UInt j = 0; j < phi_nodes->phis_used; j++) {
+ IRPhi* phi = phi_nodes->phis[j];
+ addStmtToIRStmtVec(then_leg, IRStmt_WrTmp(phi->dst,
+ IRExpr_RdTmp(phi->srcThen)));
+ addStmtToIRStmtVec(else_leg, IRStmt_WrTmp(phi->dst,
+ IRExpr_RdTmp(phi->srcElse)));
}

deconstruct_phi_nodes_IRStmtVec(then_leg);

Loading...