Skip to content

Commit 1d1be21

Browse files
fabianbs96MMory
andauthored
IDE Statistics (#697)
* Add some statistics to the edge functions in IDE * Make more of AnalysisController internal and reduce dependencies * More stats (WIP) * EF Stats object * More EF stats + add some JF stats * Apply some review comments * More review fixes --------- Co-authored-by: Martin Mory <mmo@mail.upb.de>
1 parent 8a786ac commit 1d1be21

32 files changed

Lines changed: 979 additions & 408 deletions

include/phasar/Controller/AnalysisController.h

Lines changed: 17 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -13,159 +13,27 @@
1313
#include "phasar/AnalysisStrategy/Strategies.h"
1414
#include "phasar/Controller/AnalysisControllerEmitterOptions.h"
1515
#include "phasar/DataFlow/IfdsIde/IFDSIDESolverConfig.h"
16-
#include "phasar/DataFlow/IfdsIde/Solver/IDESolver.h"
17-
#include "phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h"
18-
#include "phasar/DataFlow/IfdsIde/SolverResults.h"
19-
#include "phasar/DataFlow/Mono/Solver/InterMonoSolver.h"
20-
#include "phasar/DataFlow/Mono/Solver/IntraMonoSolver.h"
21-
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h"
22-
#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h"
2316
#include "phasar/PhasarLLVM/HelperAnalyses.h"
24-
#include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h"
25-
#include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h"
26-
#include "phasar/PhasarLLVM/TaintConfig/LLVMTaintConfig.h"
27-
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
2817
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h"
29-
#include "phasar/Utils/EnumFlags.h"
30-
#include "phasar/Utils/IO.h"
31-
#include "phasar/Utils/Soundness.h"
32-
33-
#include <set>
34-
#include <string>
35-
#include <vector>
3618

19+
#include <filesystem>
3720
namespace psr {
3821

3922
class AnalysisController {
40-
private:
41-
HelperAnalyses &HA;
42-
std::vector<DataFlowAnalysisType> DataFlowAnalyses;
43-
std::vector<std::string> AnalysisConfigs;
44-
std::vector<std::string> EntryPoints;
45-
[[maybe_unused]] AnalysisStrategy Strategy;
46-
AnalysisControllerEmitterOptions EmitterOptions =
47-
AnalysisControllerEmitterOptions::None;
48-
std::string ProjectID;
49-
std::filesystem::path ResultDirectory;
50-
IFDSIDESolverConfig SolverConfig;
51-
52-
///
53-
/// \brief The maximum length of the CallStrings used in the InterMonoSolver
54-
///
55-
static const unsigned K = 3;
56-
57-
void executeDemandDriven();
58-
59-
void executeIncremental();
60-
61-
void executeModuleWise();
62-
63-
void executeVariational();
64-
65-
void executeWholeProgram();
66-
67-
void emitRequestedHelperAnalysisResults();
68-
69-
void executeIFDSUninitVar();
70-
void executeIFDSConst();
71-
void executeIFDSTaint();
72-
void executeIFDSType();
73-
void executeIFDSSolverTest();
74-
void executeIFDSFieldSensTaint();
75-
void executeIDEXTaint();
76-
void executeIDEOpenSSLTS();
77-
void executeIDECSTDIOTS();
78-
void executeIDELinearConst();
79-
void executeIDESolverTest();
80-
void executeIDEIIA();
81-
void executeIntraMonoFullConstant();
82-
void executeIntraMonoSolverTest();
83-
void executeInterMonoSolverTest();
84-
void executeInterMonoTaint();
85-
86-
template <typename SolverTy, typename ProblemTy, typename... ArgTys>
87-
void executeMonoAnalysis(ArgTys &&...Args) {
88-
auto Problem =
89-
createAnalysisProblem<ProblemTy>(HA, std::forward<ArgTys>(Args)...);
90-
SolverTy Solver(Problem);
91-
Solver.solve();
92-
emitRequestedDataFlowResults(Solver);
93-
}
94-
95-
template <typename ProblemTy, typename... ArgTys>
96-
void executeIntraMonoAnalysis(ArgTys &&...Args) {
97-
executeMonoAnalysis<IntraMonoSolver_P<ProblemTy>, ProblemTy>(
98-
std::forward<ArgTys>(Args)...);
99-
}
100-
101-
template <typename ProblemTy, typename... ArgTys>
102-
void executeInterMonoAnalysis(ArgTys &&...Args) {
103-
executeMonoAnalysis<InterMonoSolver_P<ProblemTy, 3>, ProblemTy>(
104-
std::forward<ArgTys>(Args)...);
105-
}
106-
107-
template <typename SolverTy, typename ProblemTy, typename... ArgTys>
108-
void executeIfdsIdeAnalysis(ArgTys &&...Args) {
109-
auto Problem =
110-
createAnalysisProblem<ProblemTy>(HA, std::forward<ArgTys>(Args)...);
111-
SolverTy Solver(Problem, &HA.getICFG());
112-
Solver.solve();
113-
emitRequestedDataFlowResults(Solver);
114-
}
115-
116-
template <typename ProblemTy, typename... ArgTys>
117-
void executeIFDSAnalysis(ArgTys &&...Args) {
118-
executeIfdsIdeAnalysis<IFDSSolver_P<ProblemTy>, ProblemTy>(
119-
std::forward<ArgTys>(Args)...);
120-
}
121-
122-
template <typename ProblemTy, typename... ArgTys>
123-
void executeIDEAnalysis(ArgTys &&...Args) {
124-
executeIfdsIdeAnalysis<IDESolver_P<ProblemTy>, ProblemTy>(
125-
std::forward<ArgTys>(Args)...);
126-
}
127-
128-
LLVMTaintConfig makeTaintConfig();
129-
130-
template <typename T> void emitRequestedDataFlowResults(T &Solver) {
131-
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitTextReport) {
132-
if (!ResultDirectory.empty()) {
133-
if (auto OFS =
134-
openFileStream(ResultDirectory.string() + "/psr-report.txt")) {
135-
Solver.emitTextReport(*OFS);
136-
}
137-
} else {
138-
Solver.emitTextReport(llvm::outs());
139-
}
140-
}
141-
if (EmitterOptions &
142-
AnalysisControllerEmitterOptions::EmitGraphicalReport) {
143-
if (!ResultDirectory.empty()) {
144-
if (auto OFS =
145-
openFileStream(ResultDirectory.string() + "/psr-report.html")) {
146-
Solver.emitGraphicalReport(*OFS);
147-
}
148-
} else {
149-
Solver.emitGraphicalReport(llvm::outs());
150-
}
151-
}
152-
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitRawResults) {
153-
if (!ResultDirectory.empty()) {
154-
if (auto OFS = openFileStream(ResultDirectory.string() +
155-
"/psr-raw-results.txt")) {
156-
Solver.dumpResults(*OFS);
157-
}
158-
} else {
159-
Solver.dumpResults(llvm::outs());
160-
}
161-
}
162-
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitESGAsDot) {
163-
llvm::outs()
164-
<< "Front-end support for 'EmitESGAsDot' to be implemented\n";
165-
}
166-
}
167-
16823
public:
24+
struct ControllerData {
25+
HelperAnalyses *HA{};
26+
std::vector<DataFlowAnalysisType> DataFlowAnalyses;
27+
std::vector<std::string> AnalysisConfigs;
28+
std::vector<std::string> EntryPoints;
29+
[[maybe_unused]] AnalysisStrategy Strategy;
30+
AnalysisControllerEmitterOptions EmitterOptions =
31+
AnalysisControllerEmitterOptions::None;
32+
std::string ProjectID;
33+
std::filesystem::path ResultDirectory;
34+
IFDSIDESolverConfig SolverConfig{};
35+
};
36+
16937
explicit AnalysisController(
17038
HelperAnalyses &HA, std::vector<DataFlowAnalysisType> DataFlowAnalyses,
17139
std::vector<std::string> AnalysisConfigs,
@@ -175,21 +43,15 @@ class AnalysisController {
17543
std::string ProjectID = "default-phasar-project",
17644
std::string OutDirectory = "");
17745

178-
~AnalysisController() = default;
179-
180-
AnalysisController(const AnalysisController &) = delete;
181-
AnalysisController(AnalysisController &&) = delete;
182-
AnalysisController &operator=(const AnalysisController &) = delete;
183-
AnalysisController &operator=(const AnalysisController &&) = delete;
184-
185-
void executeAs(AnalysisStrategy Strategy);
186-
18746
static constexpr bool
18847
needsToEmitPTA(AnalysisControllerEmitterOptions EmitterOptions) {
18948
return (EmitterOptions & AnalysisControllerEmitterOptions::EmitPTAAsDot) ||
19049
(EmitterOptions & AnalysisControllerEmitterOptions::EmitPTAAsJson) ||
19150
(EmitterOptions & AnalysisControllerEmitterOptions::EmitPTAAsText);
19251
}
52+
53+
private:
54+
ControllerData Data;
19355
};
19456

19557
} // namespace psr

0 commit comments

Comments
 (0)