tweaks to address some compiler warnings

This commit is contained in:
Vern Paxson 2021-09-13 19:55:26 -07:00
parent 7f3993ca0e
commit 693fc14eb2
13 changed files with 44 additions and 27 deletions

View file

@ -450,7 +450,7 @@ void GenIDDefs::EndConfluenceBlock(bool no_orig)
confluence_blocks.pop_back(); confluence_blocks.pop_back();
int bb = barrier_blocks.back(); auto bb = barrier_blocks.back();
if ( bb > 0 && confluence_blocks.size() == bb ) if ( bb > 0 && confluence_blocks.size() == bb )
barrier_blocks.pop_back(); barrier_blocks.pop_back();
@ -520,7 +520,7 @@ void GenIDDefs::TrackID(const ID* id, const ExprPtr& e)
// Ensure we track this identifier across all relevant // Ensure we track this identifier across all relevant
// confluence regions. // confluence regions.
for ( int i = barrier_blocks.back(); i < confluence_blocks.size(); ++i ) for ( auto i = barrier_blocks.back(); i < confluence_blocks.size(); ++i )
// Add one because modified_IDs includes outer non-confluence // Add one because modified_IDs includes outer non-confluence
// block. // block.
modified_IDs[i+1].insert(id); modified_IDs[i+1].insert(id);

View file

@ -99,7 +99,7 @@ private:
// unseen confluence regions outer to those, and (2) they // unseen confluence regions outer to those, and (2) they
// can get quite deep due when inlining, so there are savings // can get quite deep due when inlining, so there are savings
// to avoid having to track outer to them. // to avoid having to track outer to them.
std::vector<int> barrier_blocks; std::vector<bro_uint_t> barrier_blocks;
// The following is parallel to confluence_blocks except // The following is parallel to confluence_blocks except
// the front entry tracks identifiers at the outermost // the front entry tracks identifiers at the outermost

View file

@ -71,7 +71,7 @@ void IDOptInfo::Clear()
void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e, void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e,
const std::vector<const Stmt*>& conf_blocks, const std::vector<const Stmt*>& conf_blocks,
int conf_start) bro_uint_t conf_start)
{ {
if ( tracing ) if ( tracing )
printf("ID %s defined at %d: %s\n", trace_ID, s ? s->GetOptInfo()->stmt_num : NO_DEF, s ? obj_desc(s).c_str() : "<entry>"); printf("ID %s defined at %d: %s\n", trace_ID, s ? s->GetOptInfo()->stmt_num : NO_DEF, s ? obj_desc(s).c_str() : "<entry>");
@ -174,7 +174,7 @@ void IDOptInfo::BranchBackTo(const Stmt* from, const Stmt* to, bool close_all)
auto from_reg = ActiveRegion(); auto from_reg = ActiveRegion();
auto f_oi = from->GetOptInfo(); auto f_oi = from->GetOptInfo();
auto t_oi = to->GetOptInfo(); auto t_oi = to->GetOptInfo();
auto t_r_ind = FindRegionBeforeIndex(t_oi->stmt_num); bro_uint_t t_r_ind = FindRegionBeforeIndex(t_oi->stmt_num);
auto& t_r = usage_regions[t_r_ind]; auto& t_r = usage_regions[t_r_ind];
if ( from_reg && from_reg->DefinedAfter() != t_r.DefinedAfter() && if ( from_reg && from_reg->DefinedAfter() != t_r.DefinedAfter() &&
@ -327,7 +327,7 @@ void IDOptInfo::ConfluenceBlockEndsAfter(const Stmt* s, bool no_orig_flow)
int num_regions = 0; int num_regions = 0;
for ( auto i = 0; i < usage_regions.size(); ++i ) for ( auto i = 0U; i < usage_regions.size(); ++i )
{ {
auto& ur = usage_regions[i]; auto& ur = usage_regions[i];
@ -480,7 +480,7 @@ void IDOptInfo::EndRegionsAfter(int stmt_num, int level)
int IDOptInfo::FindRegionBeforeIndex(int stmt_num) int IDOptInfo::FindRegionBeforeIndex(int stmt_num)
{ {
int region_ind = NO_DEF; int region_ind = NO_DEF;
for ( auto i = 0; i < usage_regions.size(); ++i ) for ( auto i = 0U; i < usage_regions.size(); ++i )
{ {
auto ur = usage_regions[i]; auto ur = usage_regions[i];

View file

@ -142,7 +142,7 @@ public:
// conf_blocks may be empty). // conf_blocks may be empty).
void DefinedAfter(const Stmt* s, const ExprPtr& e, void DefinedAfter(const Stmt* s, const ExprPtr& e,
const std::vector<const Stmt*>& conf_blocks, const std::vector<const Stmt*>& conf_blocks,
int conf_start); bro_uint_t conf_start);
// Called upon encountering a "return" statement. // Called upon encountering a "return" statement.
void ReturnAt(const Stmt* s); void ReturnAt(const Stmt* s);

View file

@ -952,9 +952,9 @@ ZInstI* ZAMCompiler::FirstLiveInst(ZInstI* i, bool follow_gotos)
return nullptr; return nullptr;
} }
int ZAMCompiler::FirstLiveInst(int i, bool follow_gotos) bro_uint_t ZAMCompiler::FirstLiveInst(bro_uint_t i, bool follow_gotos)
{ {
int num_inspected = 0; bro_uint_t num_inspected = 0;
while ( i < insts1.size() ) while ( i < insts1.size() )
{ {
auto i0 = insts1[i]; auto i0 = insts1[i];
@ -982,7 +982,7 @@ int ZAMCompiler::FirstLiveInst(int i, bool follow_gotos)
return i; return i;
} }
void ZAMCompiler::KillInst(int i) void ZAMCompiler::KillInst(bro_uint_t i)
{ {
auto inst = insts1[i]; auto inst = insts1[i];
@ -1037,7 +1037,7 @@ void ZAMCompiler::KillInst(int i)
} }
} }
void ZAMCompiler::KillInsts(int i) void ZAMCompiler::KillInsts(bro_uint_t i)
{ {
auto inst = insts1[i]; auto inst = insts1[i];

View file

@ -494,12 +494,12 @@ private:
// First form returns nil if there's nothing live after i. // First form returns nil if there's nothing live after i.
// Second form returns insts1.size() in that case. // Second form returns insts1.size() in that case.
ZInstI* FirstLiveInst(ZInstI* i, bool follow_gotos = false); ZInstI* FirstLiveInst(ZInstI* i, bool follow_gotos = false);
int FirstLiveInst(int i, bool follow_gotos = false); bro_uint_t FirstLiveInst(bro_uint_t i, bool follow_gotos = false);
// Same, but not including i. // Same, but not including i.
ZInstI* NextLiveInst(ZInstI* i, bool follow_gotos = false) ZInstI* NextLiveInst(ZInstI* i, bool follow_gotos = false)
{ {
if ( i->inst_num == insts1.size() - 1 ) if ( i->inst_num == static_cast<int>(insts1.size()) - 1 )
return nullptr; return nullptr;
return FirstLiveInst(insts1[i->inst_num + 1], follow_gotos); return FirstLiveInst(insts1[i->inst_num + 1], follow_gotos);
} }
@ -511,12 +511,12 @@ private:
// into insts1; any labels associated with it are transferred // into insts1; any labels associated with it are transferred
// to its next live successor, if any. // to its next live successor, if any.
void KillInst(ZInstI* i) { KillInst(i->inst_num); } void KillInst(ZInstI* i) { KillInst(i->inst_num); }
void KillInst(int i); void KillInst(bro_uint_t i);
// The same, but kills any successor instructions until finding // The same, but kills any successor instructions until finding
// one that's labeled. // one that's labeled.
void KillInsts(ZInstI* i) { KillInsts(i->inst_num); } void KillInsts(ZInstI* i) { KillInsts(i->inst_num); }
void KillInsts(int i); void KillInsts(bro_uint_t i);
// The first of these is used as we compile down to ZInstI's. // The first of these is used as we compile down to ZInstI's.
// The second is the final intermediary code. They're separate // The second is the final intermediary code. They're separate

View file

@ -1186,7 +1186,7 @@ const ZAMStmt ZAMCompiler::RecordCoerce(const NameExpr* n, const Expr* e)
z.aux = new ZInstAux(map_size); z.aux = new ZInstAux(map_size);
z.aux->map = map; z.aux->map = map;
for ( auto i = 0; i < map_size; ++i ) for ( auto i = 0U; i < map_size; ++i )
z.aux->Add(i, map[i], nullptr); z.aux->Add(i, map[i], nullptr);
// Mark the integer entries in z.aux as not being frame slots as usual. // Mark the integer entries in z.aux as not being frame slots as usual.

View file

@ -923,7 +923,7 @@ void ZAM_ExprOpTemplate::Parse(const string& attr, const string& line,
if ( words.size() == 1 ) if ( words.size() == 1 )
g->Gripe("op-type needs arguments", line); g->Gripe("op-type needs arguments", line);
for ( auto i = 1; i < words.size(); ++i ) for ( auto i = 1U; i < words.size(); ++i )
{ {
auto& w_i = words[i]; auto& w_i = words[i];
if ( w_i.size() != 1 ) if ( w_i.size() != 1 )
@ -1023,7 +1023,7 @@ void ZAM_ExprOpTemplate::Instantiate()
InstantiateC3(op_types); InstantiateC3(op_types);
bool all_var = true; bool all_var = true;
for ( auto i = 1; i < op_types.size(); ++i ) for ( auto i = 1U; i < op_types.size(); ++i )
if ( op_types[i] != ZAM_OT_VAR ) if ( op_types[i] != ZAM_OT_VAR )
all_var = false; all_var = false;

View file

@ -791,13 +791,13 @@ internal-op Val-Is-In-Vector
type VVV type VVV
eval auto& vec = frame[z.v3].vector_val; eval auto& vec = frame[z.v3].vector_val;
auto ind = frame[z.v2].int_val; auto ind = frame[z.v2].int_val;
frame[z.v1].int_val = ind >= 0 && ind < vec->Size(); frame[z.v1].int_val = ind >= 0 && static_cast<bro_uint_t>(ind) < vec->Size();
internal-op Const-Is-In-Vector internal-op Const-Is-In-Vector
type VCV type VCV
eval auto& vec = frame[z.v2].vector_val; eval auto& vec = frame[z.v2].vector_val;
auto ind = z.c.int_val; auto ind = z.c.int_val;
frame[z.v1].int_val = ind >= 0 && ind < vec->Size(); frame[z.v1].int_val = ind >= 0 && static_cast<bro_uint_t>(ind) < vec->Size();
expr-op Cond expr-op Cond
type VVVV type VVVV
@ -902,7 +902,7 @@ eval EvalIndexVec(frame[z.v3].uint_val)
macro EvalIndexVec(index) macro EvalIndexVec(index)
auto vv = frame[z.v2].vector_val->RawVec(); auto vv = frame[z.v2].vector_val->RawVec();
const auto& vec = *vv; const auto& vec = *vv;
auto ind = index; bro_uint_t ind = index;
if ( ind >= vv->size() ) if ( ind >= vv->size() )
ZAM_run_time_error(z.loc, "no such index"); ZAM_run_time_error(z.loc, "no such index");
AssignV1(CopyVal(*vec[ind])) AssignV1(CopyVal(*vec[ind]))
@ -917,7 +917,7 @@ eval EvalIndexAnyVec(frame[z.v3].uint_val)
macro EvalIndexAnyVec(index) macro EvalIndexAnyVec(index)
auto vv = frame[z.v2].vector_val; auto vv = frame[z.v2].vector_val;
auto ind = index; bro_uint_t ind = index;
if ( ind >= vv->Size() ) if ( ind >= vv->Size() )
ZAM_run_time_error(z.loc, "no such index"); ZAM_run_time_error(z.loc, "no such index");
AssignV1(ZVal(vv->ValAt(ind).release())) AssignV1(ZVal(vv->ValAt(ind).release()))
@ -1749,7 +1749,7 @@ op CheckAnyLen
op1-read op1-read
type Vi type Vi
eval auto v = frame[z.v1].list_val; eval auto v = frame[z.v1].list_val;
if ( v->Vals().size() != z.v2 ) if ( v->Vals().size() != static_cast<bro_uint_t>(z.v2) )
ZAM_run_time_error(z.loc, "mismatch in list lengths"); ZAM_run_time_error(z.loc, "mismatch in list lengths");
op Print op Print

View file

@ -807,7 +807,7 @@ const ZAMStmt ZAMCompiler::LoopOverTable(const ForStmt* f, const NameExpr* val)
auto aux = new ZInstAux(0); auto aux = new ZInstAux(0);
for ( int i = 0; i < loop_vars->length(); ++i ) for ( auto i = 0U; i < loop_vars->length(); ++i )
{ {
auto id = (*loop_vars)[i]; auto id = (*loop_vars)[i];

View file

@ -49,7 +49,8 @@ void report_ZOP_profile()
// assigned value was missing (which we can only tell for managed types), // assigned value was missing (which we can only tell for managed types),
// true otherwise. // true otherwise.
static bool copy_vec_elem(VectorVal* vv, int ind, ZVal zv, const TypePtr& t) static bool copy_vec_elem(VectorVal* vv, bro_uint_t ind, ZVal zv,
const TypePtr& t)
{ {
if ( vv->Size() <= ind ) if ( vv->Size() <= ind )
vv->Resize(ind + 1); vv->Resize(ind + 1);
@ -263,7 +264,7 @@ ValPtr ZBody::DoExec(Frame* f, int start_pc, StmtFlowType& flow)
const int end_pc = ninst; const int end_pc = ninst;
// Return value, or nil if none. // Return value, or nil if none.
const ZVal* ret_u; const ZVal* ret_u = nullptr;
// Type of the return value. If nil, then we don't have a value. // Type of the return value. If nil, then we don't have a value.
TypePtr ret_type; TypePtr ret_type;

View file

@ -170,6 +170,8 @@ int ZInst::NumFrameSlots() const
case OP_VVVV: case OP_VVVV:
return 4; return 4;
} }
return -1;
} }
int ZInst::NumSlots() const int ZInst::NumSlots() const
@ -208,6 +210,8 @@ int ZInst::NumSlots() const
case OP_VVVV_I2_I3_I4: case OP_VVVV_I2_I3_I4:
return 4; return 4;
} }
return -1;
} }
string ZInst::VName(int n, int inst_num, const FrameReMap* mappings) const string ZInst::VName(int n, int inst_num, const FrameReMap* mappings) const
@ -278,6 +282,8 @@ ValPtr ZInst::ConstVal() const
case OP_VVVV_I2_I3_I4: case OP_VVVV_I2_I3_I4:
return nullptr; return nullptr;
} }
return nullptr;
} }
string ZInst::ConstDump() const string ZInst::ConstDump() const
@ -431,6 +437,8 @@ bool ZInstI::AssignsToSlot1() const
auto fl = op1_flavor[op]; auto fl = op1_flavor[op];
return fl == OP1_WRITE || fl == OP1_READ_WRITE; return fl == OP1_WRITE || fl == OP1_READ_WRITE;
} }
return false;
} }
bool ZInstI::UsesSlot(int slot) const bool ZInstI::UsesSlot(int slot) const
@ -473,6 +481,8 @@ bool ZInstI::UsesSlot(int slot) const
case OP_VVVV: case OP_VVVV:
return v1_match || v2 == slot || v3 == slot || v4 == slot; return v1_match || v2 == slot || v3 == slot || v4 == slot;
} }
return false;
} }
bool ZInstI::UsesSlots(int& s1, int& s2, int& s3, int& s4) const bool ZInstI::UsesSlots(int& s1, int& s2, int& s3, int& s4) const
@ -538,6 +548,8 @@ bool ZInstI::UsesSlots(int& s1, int& s2, int& s3, int& s4) const
return true; return true;
} }
return false;
} }
void ZInstI::UpdateSlots(std::vector<int>& slot_mapping) void ZInstI::UpdateSlots(std::vector<int>& slot_mapping)

View file

@ -12,6 +12,8 @@ const char* ZOP_name(ZOp op)
#include "zeek/ZAM-OpsNamesDefs.h" #include "zeek/ZAM-OpsNamesDefs.h"
case OP_NOP: return "nop"; case OP_NOP: return "nop";
} }
return "<error>";
} }
static const char* op_type_name(ZAMOpType ot) static const char* op_type_name(ZAMOpType ot)
@ -41,6 +43,8 @@ static const char* op_type_name(ZAMOpType ot)
case OP_VVVV_I3_I4: return "VVVV_I3_I4"; case OP_VVVV_I3_I4: return "VVVV_I3_I4";
case OP_VVVV_I2_I3_I4: return "VVVV_I2_I3_I4"; case OP_VVVV_I2_I3_I4: return "VVVV_I2_I3_I4";
} }
return "<error>";
} }