From e3e2836db3e10d5d1b7a262c7b34f247af076b7a Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sun, 3 Jan 2016 00:40:08 -0800 Subject: [PATCH] Fix Loop Exit Bug --- classlist.h | 2 +- constgen.cc | 13 +++++++++++-- eprecord.cc | 4 +++- mcexecution.cc | 7 ++++--- schedulebuilder.cc | 14 +++++++++----- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/classlist.h b/classlist.h index ba7af68..637e7f1 100644 --- a/classlist.h +++ b/classlist.h @@ -38,7 +38,7 @@ class ScheduleBuilder; class IncrementalSolver; typedef unsigned int uint; -enum EventType {LOAD, STORE, RMW, BRANCHDIR, MERGE, FUNCTION, THREADCREATE, THREADBEGIN, NONLOCALTRANS, LABEL,YIELD, THREADJOIN, LOOPENTER, LOOPSTART, ALLOC, EQUALS, FENCE}; +enum EventType {LOAD, STORE, RMW, BRANCHDIR, MERGE, FUNCTION, THREADCREATE, THREADBEGIN, NONLOCALTRANS, LOOPEXIT, LABEL,YIELD, THREADJOIN, LOOPENTER, LOOPSTART, ALLOC, EQUALS, FENCE}; typedef HashSet RecordSet; typedef HSIterator RecordIterator; typedef HashTable BranchTable; diff --git a/constgen.cc b/constgen.cc index 60cceb7..cf58464 100644 --- a/constgen.cc +++ b/constgen.cc @@ -348,6 +348,9 @@ void ConstGen::printRecord(EPRecord *record, int file) { if (record->getType()==NONLOCALTRANS) { return; } + if (record->getType()==LOOPEXIT) { + return; + } if (record->getType()==BRANCHDIR) { EPRecord *next=record->getNextRecord(); if (next != NULL) @@ -661,13 +664,13 @@ void ConstGen::genTSOTransOrderConstraints() { Constraint * storeload=getOrderConstraint(store, rec); Constraint * earlystoreload=getOrderConstraint(laststore, rec); Constraint * c=new Constraint(IMPLIES, storeload, earlystoreload); - ADDCONSTRAINT(c, "earylstore"); + ADDCONSTRAINT(c, "earlystore"); } if (lastload != NULL) { Constraint * storeearlyload=getOrderConstraint(store, lastload); Constraint * storeload=getOrderConstraint(store, rec); Constraint * c=new Constraint(IMPLIES, storeearlyload, storeload); - ADDCONSTRAINT(c, "earylload"); + ADDCONSTRAINT(c, "earlyload"); } lastload=rec; } @@ -1788,6 +1791,9 @@ void ConstGen::visitRecord(EPRecord *record) { recordExecCond(record); insertBranch(record); break; + case LOOPEXIT: + recordExecCond(record); + break; case NONLOCALTRANS: recordExecCond(record); insertNonLocal(record); @@ -1865,6 +1871,9 @@ void ConstGen::traverseRecord(EPRecord *record, bool initial) { if (record->getType()==NONLOCALTRANS) { return; } + if (record->getType()==LOOPEXIT) { + return; + } if (record->getType()==BRANCHDIR) { EPRecord *next=record->getNextRecord(); if (next != NULL) diff --git a/eprecord.cc b/eprecord.cc index c7bf25f..10b4537 100644 --- a/eprecord.cc +++ b/eprecord.cc @@ -83,6 +83,8 @@ const char * eventToStr(EventType event) { return "yield"; case NONLOCALTRANS: return "nonlocal"; + case LOOPEXIT: + return "loopexit"; case LABEL: return "label"; case LOOPENTER: @@ -115,6 +117,7 @@ IntHashSet * EPRecord::getReturnValueSet() { case YIELD: case FENCE: case NONLOCALTRANS: + case LOOPEXIT: case LABEL: case LOOPENTER: case LOOPSTART: @@ -187,7 +190,6 @@ void EPRecord::print(int f) { dprintf(f,"}"); delete it; } - dprintf(f, "}"); execpoint->print(f); diff --git a/mcexecution.cc b/mcexecution.cc index 1166731..404569a 100644 --- a/mcexecution.cc +++ b/mcexecution.cc @@ -895,6 +895,9 @@ void MCExecution::exitLoop() { if (!currexecpoint->directInLoop()) { breakstate=getOrCreateCurrRecord(NONLOCALTRANS, NULL, 0, 0, 8, false); currexecpoint->incrementTop(); + } else { + breakstate=getOrCreateCurrRecord(LOOPEXIT, NULL, 0, 0, 8, false); + currexecpoint->incrementTop(); } /* Get Last Record */ @@ -927,9 +930,7 @@ void MCExecution::exitLoop() { if (loopenter->getNextRecord()==NULL) { loopenter->setNextRecord(labelrec); } - if (breakstate!=NULL) { - breakstate->setNextRecord(labelrec); - } + breakstate->setNextRecord(labelrec); currexecpoint->incrementTop(); } diff --git a/schedulebuilder.cc b/schedulebuilder.cc index 4473c74..cc17b1e 100644 --- a/schedulebuilder.cc +++ b/schedulebuilder.cc @@ -26,23 +26,27 @@ ScheduleBuilder::~ScheduleBuilder() { void neatPrint(EPRecord *r, ConstGen *cgen, bool *satsolution) { - StoreLoadSet * sls=cgen->getStoreLoadSet(r); r->print(); - model_print("address=%p ", sls->getAddressEncoding(cgen, r, satsolution)); switch(r->getType()) { case LOAD: { + StoreLoadSet * sls=cgen->getStoreLoadSet(r); + model_print("address=%p ", sls->getAddressEncoding(cgen, r, satsolution)); model_print("rd=%lu ", sls->getValueEncoding(cgen, r, satsolution)); } break; case STORE: { + StoreLoadSet * sls=cgen->getStoreLoadSet(r); + model_print("address=%p ", sls->getAddressEncoding(cgen, r, satsolution)); model_print("wr=%lu ", sls->getValueEncoding(cgen, r, satsolution)); - } break; case RMW: { + StoreLoadSet * sls=cgen->getStoreLoadSet(r); + model_print("address=%p ", sls->getAddressEncoding(cgen, r, satsolution)); model_print("rd=%lu ", sls->getRMWRValueEncoding(cgen, r, satsolution)); model_print("wr=%lu ", sls->getValueEncoding(cgen, r, satsolution)); } + break; default: ; } @@ -86,7 +90,6 @@ void ScheduleBuilder::buildSchedule(bool * satsolution) { } //Now we have just memory operations, find the first one...make it go first EPRecord *earliest=NULL; - for(uint index=0;indexempty()) { record=stores[index]->front(); - if (record!=NULL && (earliest==NULL || cg->getOrder(record, earliest, satsolution))) { earliest=record; @@ -208,6 +210,8 @@ EPRecord * ScheduleBuilder::processRecord(EPRecord *record, bool *satsolution) { break; case NONLOCALTRANS: break; + case LOOPEXIT: + break; case LABEL: break; case YIELD: -- 2.34.1