fix for ZAM printing of instructions that modify slots other than slot 1

This commit is contained in:
Vern Paxson 2024-03-02 14:18:18 -08:00 committed by Arne Welzel
parent 54877e9dec
commit ce6d77e2ce
2 changed files with 57 additions and 56 deletions

View file

@ -165,11 +165,12 @@ string ZInst::VName(int n, zeek_uint_t inst_num, const FrameReMap* mappings) con
unsigned int i;
for ( i = 0; i < map.id_start.size(); ++i ) {
// If the slot is right at the boundary between two
// identifiers, then it matters whether this is slot 1
// (starts right here) vs. slot > 1 (ignore change right
// at the boundary and stick with older value).
if ( (n == 1 && map.id_start[i] > inst_num) || (n > 1 && map.id_start[i] >= inst_num) )
// If the slot is right at the boundary between two identifiers, then
// it matters whether this is an assigned slot (starts right here) vs.
// not assigned (ignore change right at the boundary and stick with
// older value).
auto target_inst = AssignsToSlot(n) ? inst_num + 1 : inst_num;
if ( map.id_start[i] >= target_inst )
// Went too far.
break;
}
@ -231,6 +232,49 @@ bool ZInst::IsLoopIterationAdvancement() const {
}
}
bool ZInst::AssignsToSlot1() const {
switch ( op_type ) {
case OP_X:
case OP_C:
case OP_V_I1:
case OP_VC_I1:
case OP_VV_I1_I2:
case OP_VVVC_I1_I2_I3: return false;
// We use this ginormous set of cases rather than "default" so
// that when we add a new operand type, we have to consider
// its behavior here. (Same for many of the other switch's
// used for ZInst/ZinstI.)
case OP_V:
case OP_VC:
case OP_VV_FRAME:
case OP_VV_I2:
case OP_VVC_I2:
case OP_VVV_I2_I3:
case OP_VVVC_I2_I3:
case OP_VVVV_I2_I3_I4:
case OP_VV:
case OP_VVC:
case OP_VVV_I3:
case OP_VVVV_I3_I4:
case OP_VVVC_I3:
case OP_VVV:
case OP_VVVC:
case OP_VVVV_I4:
case OP_VVVV: auto fl = op1_flavor[op]; return fl == OP1_WRITE || fl == OP1_READ_WRITE;
}
return false;
}
bool ZInst::AssignsToSlot(int slot) const {
switch ( op ) {
case OP_NEXT_VECTOR_ITER_VAL_VAR_VVVV: return slot == 1 || slot == 2;
default: return slot == 1 && AssignsToSlot1();
}
}
string ZInst::ConstDump() const {
auto v = ConstVal();
@ -352,49 +396,6 @@ bool ZInstI::HasCaptures() const {
bool ZInstI::HasSideEffects() const { return op_side_effects[op]; }
bool ZInstI::AssignsToSlot1() const {
switch ( op_type ) {
case OP_X:
case OP_C:
case OP_V_I1:
case OP_VC_I1:
case OP_VV_I1_I2:
case OP_VVVC_I1_I2_I3: return false;
// We use this ginormous set of cases rather than "default" so
// that when we add a new operand type, we have to consider
// its behavior here. (Same for many of the other switch's
// used for ZInst/ZinstI.)
case OP_V:
case OP_VC:
case OP_VV_FRAME:
case OP_VV_I2:
case OP_VVC_I2:
case OP_VVV_I2_I3:
case OP_VVVC_I2_I3:
case OP_VVVV_I2_I3_I4:
case OP_VV:
case OP_VVC:
case OP_VVV_I3:
case OP_VVVV_I3_I4:
case OP_VVVC_I3:
case OP_VVV:
case OP_VVVC:
case OP_VVVV_I4:
case OP_VVVV: auto fl = op1_flavor[op]; return fl == OP1_WRITE || fl == OP1_READ_WRITE;
}
return false;
}
bool ZInstI::AssignsToSlot(int slot) const {
switch ( op ) {
case OP_NEXT_VECTOR_ITER_VAL_VAR_VVVV: return slot == 1 || slot == 2;
default: return slot == 1 && AssignsToSlot1();
}
}
bool ZInstI::UsesSlot(int slot) const {
auto fl = op1_flavor[op];
auto v1_relevant = fl == OP1_READ || fl == OP1_READ_WRITE;

View file

@ -92,6 +92,14 @@ public:
// a loop iteration, false otherwise.
bool IsLoopIterationAdvancement() const;
// True if the given instruction assigns to the frame location
// given by slot 1 (v1).
bool AssignsToSlot1() const;
// True if the given instruction assigns to the frame location
// corresponding to the given slot.
bool AssignsToSlot(int slot) const;
// Returns a string describing the constant.
std::string ConstDump() const;
@ -219,14 +227,6 @@ public:
// should not be pruned even if it has a dead assignment.
bool HasSideEffects() const;
// True if the given instruction assigns to the frame location
// given by slot 1 (v1).
bool AssignsToSlot1() const;
// True if the given instruction assigns to the frame location
// corresponding to the given slot.
bool AssignsToSlot(int slot) const;
// True if the given instruction uses the value in the given frame
// slot. (Assigning to the slot does not constitute using the value.)
bool UsesSlot(int slot) const;