Skip to content

Commit c78bfd0

Browse files
committed
added number of callsites to statistics
1 parent 93fb8ca commit c78bfd0

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

include/phasar/Controller/AnalysisController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum class AnalysisControllerEmitterOptions : uint32_t {
4949
EmitPTAAsText = (1 << 11),
5050
EmitPTAAsDot = (1 << 12),
5151
EmitPTAAsJson = (1 << 13),
52+
EmitStatisticAsJson = (1 << 14),
5253
};
5354

5455
class AnalysisController {

include/phasar/DB/ProjectIRDB.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class ProjectIRDB {
6060
std::map<std::string, std::unique_ptr<llvm::Module>> Modules;
6161
// Maps an id to its corresponding instruction
6262
std::map<std::size_t, llvm::Instruction *> IDInstructionMapping;
63+
size_t NumberCallsites;
6364

6465
void buildIDModuleMapping(llvm::Module *M);
6566

@@ -171,6 +172,10 @@ class ProjectIRDB {
171172
return IDInstructionMapping.size();
172173
}
173174

175+
[[nodiscard]] inline std::size_t getNumCallsites() const {
176+
return NumberCallsites;
177+
}
178+
174179
[[nodiscard]] std::size_t getNumGlobals() const;
175180

176181
[[nodiscard]] llvm::Instruction *getInstruction(std::size_t Id) const;

lib/DB/ProjectIRDB.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void ProjectIRDB::preprocessModule(llvm::Module *M) {
126126
MPM.run(*M, MAM);
127127
// retrieve data from the GeneralStatisticsAnalysis registered earlier
128128
auto GSPResult = MAM.getResult<GeneralStatisticsAnalysis>(*M);
129+
NumberCallsites = GSPResult.getFunctioncalls();
129130
auto Allocas = GSPResult.getAllocaInstructions();
130131
AllocaInstructions.insert(Allocas.begin(), Allocas.end());
131132
auto ATypes = GSPResult.getAllocatedTypes();

tools/phasar-llvm/phasar-llvm.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ int main(int Argc, const char **Argv) {
209209
("emit-pta-as-text", "Emit the points-to information as text")
210210
("emit-pta-as-dot", "Emit the points-to information as DOT graph")
211211
("emit-pta-as-json", "Emit the points-to information as JSON")
212+
("emit-statistic-as-json", "Emit the statistic information as JSON")
212213
("follow-return-past-seeds", boost::program_options::value<bool>()->default_value(false), "Let the IFDS/IDE Solver process unbalanced returns")
213214
("auto-add-zero", boost::program_options::value<bool>()->default_value(true), "Let the IFDS/IDE Solver automatically add the special zero value to any set of dataflow-facts")
214215
("compute-values", boost::program_options::value<bool>()->default_value(true), "Let the IDE Solver compute the values attached to each edge in the ESG")
@@ -319,6 +320,9 @@ int main(int Argc, const char **Argv) {
319320
llvm::outs() << "> functions:\t\t" << IRDB.getWPAModule()->size() << "\n";
320321
llvm::outs() << "> global variables:\t"
321322
<< IRDB.getWPAModule()->global_size() << "\n";
323+
llvm::outs() << "> Alloca instructions:\t" << IRDB.getAllocaInstructions().size() << "\n";
324+
llvm::outs() << "> Memory Locations:\t" << IRDB.getAllMemoryLocations().size() << "\n";
325+
llvm::outs() << "> Call Sites:\t" << IRDB.getNumCallsites() << "\n";
322326
}
323327

324328
// store enabled data-flow analyses
@@ -401,6 +405,9 @@ int main(int Argc, const char **Argv) {
401405
if (PhasarConfig::VariablesMap().count("emit-pta-as-json")) {
402406
EmitterOptions |= AnalysisControllerEmitterOptions::EmitPTAAsJson;
403407
}
408+
if (PhasarConfig::VariablesMap().count("emit-statistic-as-json")) {
409+
EmitterOptions |= AnalysisControllerEmitterOptions::EmitStatisticAsJson;
410+
}
404411
if (PhasarConfig::VariablesMap().count("follow-return-past-seeds")) {
405412
SolverConfig.setFollowReturnsPastSeeds(
406413
PhasarConfig::VariablesMap()["follow-return-past-seeds"].as<bool>());

0 commit comments

Comments
 (0)