@@ -357,20 +357,22 @@ void ComputeWriteSet::enterScope(const IR::ParameterList* parameters,
357
357
auto startPoints = new ProgramPoints (entryPoint);
358
358
auto uninit = new ProgramPoints (ProgramPoint::beforeStart);
359
359
360
- for (auto p : *parameters->parameters ) {
361
- StorageLocation* loc = definitions->storageMap ->getOrAdd (p);
362
- if (loc == nullptr )
363
- continue ;
364
- if (p->direction == IR::Direction::In ||
365
- p->direction == IR::Direction::InOut ||
366
- p->direction == IR::Direction::None)
367
- defs->set (loc, startPoints);
368
- else if (p->direction == IR::Direction::Out)
369
- defs->set (loc, uninit);
370
- auto valid = loc->getValidBits ();
371
- defs->set (valid, startPoints);
372
- auto lastIndex = loc->getLastIndexField ();
373
- defs->set (lastIndex, startPoints);
360
+ if (parameters != nullptr ) {
361
+ for (auto p : *parameters->parameters ) {
362
+ StorageLocation* loc = definitions->storageMap ->getOrAdd (p);
363
+ if (loc == nullptr )
364
+ continue ;
365
+ if (p->direction == IR::Direction::In ||
366
+ p->direction == IR::Direction::InOut ||
367
+ p->direction == IR::Direction::None)
368
+ defs->set (loc, startPoints);
369
+ else if (p->direction == IR::Direction::Out)
370
+ defs->set (loc, uninit);
371
+ auto valid = loc->getValidBits ();
372
+ defs->set (valid, startPoints);
373
+ auto lastIndex = loc->getLastIndexField ();
374
+ defs->set (lastIndex, startPoints);
375
+ }
374
376
}
375
377
if (locals != nullptr ) {
376
378
for (auto d : *locals) {
@@ -394,11 +396,13 @@ void ComputeWriteSet::enterScope(const IR::ParameterList* parameters,
394
396
void ComputeWriteSet::exitScope (const IR::ParameterList* parameters,
395
397
const IR::IndexedVector<IR::Declaration>* locals) {
396
398
currentDefinitions = currentDefinitions->clone ();
397
- for (auto p : *parameters->parameters ) {
398
- StorageLocation* loc = definitions->storageMap ->getStorage (p);
399
- if (loc == nullptr )
400
- continue ;
401
- currentDefinitions->remove (loc);
399
+ if (parameters != nullptr ) {
400
+ for (auto p : *parameters->parameters ) {
401
+ StorageLocation* loc = definitions->storageMap ->getStorage (p);
402
+ if (loc == nullptr )
403
+ continue ;
404
+ currentDefinitions->remove (loc);
405
+ }
402
406
}
403
407
if (locals != nullptr ) {
404
408
for (auto d : *locals) {
@@ -876,7 +880,7 @@ bool ComputeWriteSet::preorder(const IR::Function* function) {
876
880
bool ComputeWriteSet::preorder (const IR::P4Table* table) {
877
881
LOG1 (" CWS Visiting " << dbp (table));
878
882
ProgramPoint pt (callingContext, table);
879
- enterScope (table-> parameters , nullptr , pt, false );
883
+ enterScope (nullptr , nullptr , pt, false );
880
884
881
885
// non-deterministic call of one of the actions in the table
882
886
auto after = new Definitions ();
@@ -889,7 +893,7 @@ bool ComputeWriteSet::preorder(const IR::P4Table* table) {
889
893
visit (ale->expression );
890
894
after = after->join (currentDefinitions);
891
895
}
892
- exitScope (table-> parameters , nullptr );
896
+ exitScope (nullptr , nullptr );
893
897
currentDefinitions = after;
894
898
return false ;
895
899
}
0 commit comments