@@ -34,6 +34,7 @@ namespace smack{
3434 CFDEBUG (std::cout << " INFO: register global variable: " << globalVarOrigName << " : " << typeStr << std::endl;);
3535 this ->cfg ->addVarType (globalVarOrigName, typeStr);
3636 std::pair<const VarExpr*, std::string> usedVarNamePair = this ->useVarAndName (globalVarOrigName);
37+ // this->globalStaticVars.insert(globalVarOrigName);
3738 const VarExpr* globalVar = usedVarNamePair.first ;
3839 std::string globalVarName = usedVarNamePair.second ;
3940 if (this ->getVarType (globalVarName) == VarType::DATA){
@@ -51,6 +52,7 @@ namespace smack{
5152 CFDEBUG (std::cout << " INFO: useVar " << staticVarOrigName << std::endl;);
5253 this ->cfg ->addVarType (staticVarOrigName, typeStr);
5354 std::pair<const VarExpr*, std::string> usedVarNamePair = this ->useVarAndName (staticVarOrigName);
55+ // this->globalStaticVars.insert(staticVarOrigName);
5456 const VarExpr* staticVar = usedVarNamePair.first ;
5557 std::string staticVarName = usedVarNamePair.second ;
5658
@@ -148,6 +150,22 @@ namespace smack{
148150 CFDEBUG (std::cout << " ERROR: This should not happen." );
149151 assert (false );
150152 }
153+
154+ // update with memtrack utils
155+
156+ if (this ->IROrigVar2Src .find (lhsVarOrigName) != this ->IROrigVar2Src .end ()){
157+ // there is a main src variable corresponds to lhsVar
158+ // update the srcVar to the usedVarName
159+ this ->src2IRVar [this ->IROrigVar2Src [lhsVarOrigName]] = lhsVarName;
160+ }
161+ if (lhsVarOrigName.find (" $M." ) != std::string::npos){
162+ this ->globalStaticVars .insert (lhsVarOrigName);
163+ }
164+
165+ CFDEBUG (std::cout << " INFO: update src mapping" << std::endl;);
166+ for (auto i : this ->src2IRVar ){
167+ CFDEBUG (std::cout << " SrcVar: " << i.first << " IRVar: " << i.second << std::endl;)
168+ }
151169 // // TODOsh: refactor to make it more compatible with varFactory
152170 // if(lhsVarName.find("$M") != std::string::npos){
153171 // this->cfg->addVarType(lhsVarOrigName, "ref" + std::to_string(8 * PTR_BYTEWIDTH));
@@ -3592,7 +3610,10 @@ namespace smack{
35923610 this ->storeSplit = previousExecState->getStoreSplit ();
35933611 // Initialize callStack
35943612 this ->callStack = previousExecState->getCallStack ();
3595-
3613+ // Initialize memtrack utils
3614+ this ->src2IRVar = previousExecState->getSrc2IRVar ();
3615+ this ->globalStaticVars = previousExecState->getGlobalStaticVars ();
3616+
35963617 StatementList newStmts;
35973618 newStmts.push_back (Stmt::symbheap (previousSH));
35983619 SHExprPtr currSH = previousSH;
@@ -3605,7 +3626,7 @@ namespace smack{
36053626 currSH = newSH;
36063627 }
36073628
3608- ExecutionStatePtr resultExecState = std::make_shared<ExecutionState>(currSH, this ->varEquiv , this ->varFactory , this ->storeSplit , this ->callStack );
3629+ ExecutionStatePtr resultExecState = std::make_shared<ExecutionState>(currSH, this ->varEquiv , this ->varFactory , this ->storeSplit , this ->callStack , this -> src2IRVar , this -> globalStaticVars );
36093630 return std::pair<ExecutionStatePtr, StatementList>(resultExecState, newStmts);
36103631 }
36113632
@@ -3620,10 +3641,13 @@ namespace smack{
36203641 this ->storeSplit = initialExecState->getStoreSplit ();
36213642 // Initialize stack
36223643 this ->callStack = initialExecState->getCallStack ();
3644+ // Initialize memtrack utils
3645+ this ->src2IRVar = initialExecState->getSrc2IRVar ();
3646+ this ->globalStaticVars = initialExecState->getGlobalStaticVars ();
36233647
36243648 SHExprPtr newSH = this ->executeGlobal (previousSH);
36253649
3626- ExecutionStatePtr resultExecState = std::make_shared<ExecutionState>(newSH, this ->varEquiv , this ->varFactory , this ->storeSplit , this ->callStack );
3650+ ExecutionStatePtr resultExecState = std::make_shared<ExecutionState>(newSH, this ->varEquiv , this ->varFactory , this ->storeSplit , this ->callStack , this -> src2IRVar , this -> globalStaticVars );
36273651 return resultExecState;
36283652 }
36293653
0 commit comments