ASSERT seatbelts for low-level vector accesses

This commit is contained in:
Vern Paxson 2023-07-13 11:42:53 -07:00
parent c61360e181
commit 3505827982
2 changed files with 5 additions and 2 deletions

View file

@ -37,7 +37,7 @@ void finalize_functions(const std::vector<FuncInfo>& funcs)
std::unordered_set<const Func*> leave_alone;
for ( auto& f : funcs )
if ( f.Body()->Tag() != STMT_ZAM )
if ( f.Body() && f.Body()->Tag() != STMT_ZAM )
// This function has a body that wasn't compiled,
// don't mess with its size.
leave_alone.insert(f.Func());
@ -473,7 +473,8 @@ void ZAMCompiler::ComputeFrameLifetimes()
int n = aux->n;
auto& slots = aux->slots;
for ( int i = 0; i < n; ++i )
ExtendLifetime(slots[i], EndOfLoop(inst, 1));
if ( slots[i] >= 0 )
ExtendLifetime(slots[i], EndOfLoop(inst, 1));
break;
}
@ -839,6 +840,7 @@ void ZAMCompiler::CheckSlotUse(int slot, const ZInstI* inst)
void ZAMCompiler::ExtendLifetime(int slot, const ZInstI* inst)
{
ASSERT(slot >= 0);
auto id = frame_denizens[slot];
auto& t = id->GetType();