Fix Loop Exit Bug
authorbdemsky <bdemsky@uci.edu>
Sun, 3 Jan 2016 08:40:08 +0000 (00:40 -0800)
committerbdemsky <bdemsky@uci.edu>
Sun, 3 Jan 2016 08:40:08 +0000 (00:40 -0800)
classlist.h
constgen.cc
eprecord.cc
mcexecution.cc
schedulebuilder.cc

index ba7af68..637e7f1 100644 (file)
@@ -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<EPRecord *, uintptr_t, 0, model_malloc, model_calloc, model_free> RecordSet;
 typedef HSIterator<EPRecord *, uintptr_t, 0, model_malloc, model_calloc, model_free> RecordIterator;
 typedef HashTable<EPRecord *, BranchRecord *, uintptr_t, 4, model_malloc, model_calloc, model_free> BranchTable;
index 60cceb7..cf58464 100644 (file)
@@ -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)
index c7bf25f..10b4537 100644 (file)
@@ -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);
index 1166731..404569a 100644 (file)
@@ -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();
 }
 
index 4473c74..cc17b1e 100644 (file)
@@ -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;index<threads.size();index++) {
                        EPRecord *record=threads[index];
                        
@@ -97,7 +100,6 @@ void ScheduleBuilder::buildSchedule(bool * satsolution) {
 #ifdef TSO
                        if (!stores[index]->empty()) {
                                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: