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 ba7af683880a586e1652f8ce851136eedfa05433..637e7f14efb88736c04e664cd3fa74345b8f148c 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 60cceb7a3bb7f9d8dd1de73add4693e80e3b895c..cf584646b340ce7d160aba52c1e49e1e8fb797ab 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 c7bf25f67ad8c68554433b661711e997e9399140..10b4537980e28b9173fddd07bc22ce9ca7fa0366 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 1166731c1b6758a88f3c0e5b680dbb147e6d32ed..404569a1ff92e927098d2b0830d80a44f6f71025 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 4473c74e3a97461d4187f0af61b3e4af581738bd..cc17b1e025d9bcddab4dfce489644df235f5b30e 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: