Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue 1139 #1155

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions svf/include/WPA/Andersen.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class AndersenBase: public WPAConstraintSolver, public BVDataPTAImpl
/// Andersen analysis
virtual void analyze() override;

virtual void solveAndwritePtsToFile(const std::string& filename);

virtual void readPtsFromFile(const std::string& filename);

virtual void solveConstraints();

/// Initialize analysis
virtual void initialize() override;

Expand Down
6 changes: 6 additions & 0 deletions svf/include/WPA/FlowSensitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ class FlowSensitive : public WPASVFGFSSolver, public BVDataPTAImpl
/// Flow sensitive analysis
void analyze() override;

virtual void solveAndwritePtsToFile(const std::string& filename);

virtual void readPtsFromFile(const std::string& filename);

virtual void solveConstraints();

/// Initialize analysis
void initialize() override;

Expand Down
4 changes: 2 additions & 2 deletions svf/lib/MemoryModel/PointerAnalysisImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void BVDataPTAImpl::writeObjVarToFile(const string& filename)
outs() << " error opening file for writing!\n";
return;
}

// Write BaseNodes insensitivity to file
NodeBS NodeIDs;
for (auto it = pag->begin(), ie = pag->end(); it != ie; ++it)
Expand All @@ -185,14 +185,14 @@ void BVDataPTAImpl::writeObjVarToFile(const string& filename)

f << "------\n";

// Job finish and close file
f.close();
if (f.good())
{
outs() << "\n";
return;
}


}

/*!
Expand Down
73 changes: 45 additions & 28 deletions svf/lib/WPA/Andersen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,9 @@ void AndersenBase::finalize()
BVDataPTAImpl::finalize();
}

/*!
* Andersen analysis
*/
void AndersenBase::analyze()
void AndersenBase::solveConstraints()
{
/// Initialization for the Solver
initialize();

bool readResultsFromFile = false;
if(!Options::ReadAnder().empty())
{
readResultsFromFile = this->readFromFile(Options::ReadAnder());
// Finalize the analysis
PointerAnalysis::finalize();
}

if (!Options::WriteAnder().empty())
this->writeObjVarToFile(Options::WriteAnder());

if(!readResultsFromFile)
{
// Start solving constraints
// Start solving constraints
DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Start Solving Constraints\n"));

bool limitTimerSet = SVFUtil::startAnalysisLimitTimer(Options::AnderTimeLimit());
Expand All @@ -144,17 +125,53 @@ void AndersenBase::analyze()
SVFUtil::stopAnalysisLimitTimer(limitTimerSet);

DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Finish Solving Constraints\n"));
}

}

if (!Options::WriteAnder().empty())
/*!
* Andersen analysis
*/
void AndersenBase::analyze()
{
if(!Options::ReadAnder().empty())
{
this->writeToFile(Options::WriteAnder());
readPtsFromFile(Options::ReadAnder());
}
else{
if(Options::WriteAnder().empty())
{
initialize();
solveConstraints();
finalize();
}else{
solveAndwritePtsToFile(Options::WriteAnder());
}
}
}

/*!
* Andersen analysis: read pointer analysis result from file
*/
void AndersenBase::readPtsFromFile(const std::string& filename)
{
initialize();
if (!filename.empty())
this->readFromFile(filename);
PointerAnalysis::finalize();
}

if (!readResultsFromFile)
// Finalize the analysis
finalize();
/*!
* Andersen analysis: solve constraints and write pointer analysis result to file
*/
void AndersenBase:: solveAndwritePtsToFile(const std::string& filename)
{
/// Initialization for the Solver
initialize();
if (!filename.empty())
this->writeObjVarToFile(filename);
solveConstraints();
if (!filename.empty())
this->writeToFile(filename);
finalize();
}

void AndersenBase::cleanConsCG(NodeID id)
Expand Down
59 changes: 49 additions & 10 deletions svf/lib/WPA/FlowSensitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,10 @@
setGraph(svfg);
//AndersenWaveDiff::releaseAndersenWaveDiff();
}

/*!
* Start analysis
*/
void FlowSensitive::analyze()
void FlowSensitive::solveConstraints()
{
bool limitTimerSet = SVFUtil::startAnalysisLimitTimer(Options::FsTimeLimit());

/// Initialization for the Solver
initialize();


double start = stat->getClk(true);
/// Start solving constraints
DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Start Solving Constraints\n"));
Expand All @@ -104,17 +97,63 @@
while (updateCallGraph(getIndirectCallsites()));

DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Finish Solving Constraints\n"));

// Reset the time-up alarm; analysis is done.
SVFUtil::stopAnalysisLimitTimer(limitTimerSet);

double end = stat->getClk(true);
solveTime += (end - start) / TIMEINTERVAL;

}

/*!
* Start analysis
*/
void FlowSensitive::solveAndwritePtsToFile(const std::string& filename)

Check warning on line 112 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L112

Added line #L112 was not covered by tests
{
/// Initialization for the Solver
initialize();
if(!filename.empty())
writeObjVarToFile(filename);
solveConstraints();
if(!filename.empty())
writeToFile(filename);

Check warning on line 120 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L115-L120

Added lines #L115 - L120 were not covered by tests
/// finalize the analysis
finalize();
}

/*!
* Start analysis
*/
void FlowSensitive::analyze()
{
if(!Options::ReadAnder().empty())
{
readPtsFromFile(Options::ReadAnder());

Check warning on line 132 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L132

Added line #L132 was not covered by tests
}
else{
if(Options::WriteAnder().empty())
{
initialize();
solveConstraints();
finalize();
}else{
solveAndwritePtsToFile(Options::WriteAnder());

Check warning on line 141 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L141

Added line #L141 was not covered by tests
}
}
}

void FlowSensitive::readPtsFromFile(const std::string& filename)

Check warning on line 146 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L146

Added line #L146 was not covered by tests
{
/// Initialization for the Solver
initialize();

Check warning on line 149 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L149

Added line #L149 was not covered by tests
/// Load the pts from file
if(!filename.empty())
this->readFromFile(filename);

Check warning on line 152 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L151-L152

Added lines #L151 - L152 were not covered by tests
/// finalize the analysis
finalize();
}

Check warning on line 155 in svf/lib/WPA/FlowSensitive.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/WPA/FlowSensitive.cpp#L154-L155

Added lines #L154 - L155 were not covered by tests

/*!
* Finalize analysis
*/
Expand Down
Loading