Discussion:
vex: r3327 - in /branches/VEX_JIT_HACKS: priv/ir_defs.c pub/libvex_ir.h
(too old to reply)
s***@valgrind.org
2017-03-23 17:12:09 UTC
Permalink
Raw Message
Author: iraisr
Date: Thu Mar 23 17:12:09 2017
New Revision: 3327

Log:
Use iteration rather than recursion for accessing parent stuff.

Modified:
branches/VEX_JIT_HACKS/priv/ir_defs.c
branches/VEX_JIT_HACKS/pub/libvex_ir.h

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 17:12:09 2017
@@ -3798,15 +3798,16 @@
IRType typeOfIRTemp(const IRStmtVec* stmts, IRTemp tmp)
{
const IRTypeEnv* tyenv = stmts->tyenv;
- if (tyenv->id == tmp.id) {
- vassert(tmp.index >= 0);
- vassert(tmp.index < tyenv->types_used);
- return tyenv->types[tmp.index];
- } else if (stmts->parent != NULL) {
- return typeOfIRTemp(stmts->parent, tmp);
- } else {
- vpanic("typeOfIRTemp");
+ while (tyenv->id != tmp.id) {
+ stmts = stmts->parent;
+ vassert(stmts != NULL);
+ tyenv = stmts->tyenv;
}
+
+ vassert(tyenv->id == tmp.id);
+ vassert(tmp.index >= 0);
+ vassert(tmp.index < tyenv->types_used);
+ return tyenv->types[tmp.index];
}

IRType typeOfIRConst ( const IRConst* con )
@@ -4154,13 +4155,16 @@
{
vassert(tmp.id != IRTyEnvID_INVALID);

- if (stmts->tyenv->id == tmp.id) {
- return True;
- }
- if (stmts->parent != NULL) {
- return inScopeIRTemp(stmts->parent, tmp);
+ const IRTypeEnv* tyenv = stmts->tyenv;
+ while (tyenv->id != tmp.id) {
+ stmts = stmts->parent;
+ if (stmts == NULL)
+ return False;
+ tyenv = stmts->tyenv;
}
- return False;
+
+ vassert(tyenv->id == tmp.id);
+ return True;
}

static

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 Thu Mar 23 17:12:09 2017
@@ -2828,7 +2828,9 @@
Such an IRStmtVec needs to have a valid IRTyEnvId - get it from
nextIRTyEnvID(). Only after this is done, then such an IRStmtVec is ready
for newIRTemp() to give out new temporaries.
- Nested IRStmtVec also needs to have correctly set its parent. */
+ Nested IRStmtVec also needs to have correctly set its parent.
+
+ Function addEmptyIfThenElse() can be used conveniently instead. */
extern IRStmtVec* emptyIRStmtVec(void);

extern IRStmtVec* deepCopyIRStmtVec(const IRStmtVec* src, IRStmtVec* parent);
@@ -3206,6 +3208,11 @@

extern IRTyEnvID nextIRTyEnvID(IRSB*);

+/* Allocates an empty IfThenElse, assigns it a valid IRTyEnvID
+ and sets the parent for both then and else legs.
+ The returned IRStmt is added to the parent IRStmtVec and ready to be used. */
+extern IRStmt *addEmptyIfThenElse(IRSB* bb, IRStmtVec* parent, IRExpr* cond);
+
/*---------------------------------------------------------------*/
/*--- Helper functions for the IR ---*/
/*---------------------------------------------------------------*/
Loading...