Skip to content

Commit 5dd3811

Browse files
committed
polish phasar-llvm front-end
1 parent 6c23845 commit 5dd3811

26 files changed

Lines changed: 292 additions & 101 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ COPY . /usr/src/phasar
1212

1313
RUN ./bootstrap_docker.sh
1414

15-
ENTRYPOINT [ "./build/phasar" ]
15+
ENTRYPOINT [ "./build/phasar-llvm/phasar-llvm" ]

include/phasar/Controller/AnalysisController.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,25 @@
2121
#include <phasar/PhasarLLVM/Pointer/LLVMPointsToInfo.h>
2222
#include <phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h>
2323
#include <phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h>
24+
#include <phasar/Utils/EnumFlags.h>
2425

2526
namespace psr {
2627

28+
enum class AnalysisControllerEmitterOptions : uint32_t {
29+
None = 0,
30+
EmitIR = (1 << 0),
31+
EmitRawResults = (1 << 1),
32+
EmitTextReport = (1 << 2),
33+
EmitGraphicalReport = (1 << 3),
34+
EmitESGAsDot = (1 << 4),
35+
EmitTHAsText = (1 << 5),
36+
EmitTHAsDot = (1 << 6),
37+
EmitCGAsText = (1 << 7),
38+
EmitCGAsDot = (1 << 8),
39+
EmitPTAAsText = (1 << 9),
40+
EmitPTAAsDOT = (1 << 10)
41+
};
42+
2743
class AnalysisController {
2844
private:
2945
ProjectIRDB &IRDB;
@@ -34,21 +50,45 @@ class AnalysisController {
3450
std::vector<std::string> AnalysisConfigs;
3551
std::set<std::string> EntryPoints;
3652
[[maybe_unused]] AnalysisStrategy Strategy;
53+
AnalysisControllerEmitterOptions EmitterOptions =
54+
AnalysisControllerEmitterOptions::None;
3755

3856
void executeDemandDriven();
57+
3958
void executeIncremental();
59+
4060
void executeModuleWise();
61+
4162
void executeVariational();
63+
4264
void executeWholeProgram();
4365

66+
template <typename T> void emitRequestedResults(T &WPA) {
67+
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitTextReport) {
68+
WPA.emitTextReport();
69+
}
70+
if (EmitterOptions &
71+
AnalysisControllerEmitterOptions::EmitGraphicalReport) {
72+
WPA.emitGraphicalReport();
73+
}
74+
if (EmitterOptions & AnalysisControllerEmitterOptions::EmitRawResults) {
75+
WPA.dumpResults();
76+
}
77+
}
78+
4479
public:
4580
AnalysisController(ProjectIRDB &IRDB,
4681
std::vector<DataFlowAnalysisType> DataFlowAnalyses,
4782
std::vector<std::string> AnalysisConfigs,
83+
PointerAnalysisType PTATy, CallGraphAnalysisType CGTy,
4884
std::set<std::string> EntryPoints,
49-
AnalysisStrategy Strategy);
85+
AnalysisStrategy Strategy,
86+
AnalysisControllerEmitterOptions EmitterOptions);
87+
5088
~AnalysisController() = default;
89+
5190
AnalysisController(const AnalysisController &) = delete;
91+
5292
AnalysisController(AnalysisController &&) = delete;
5393

5494
void executeAs(AnalysisStrategy Strategy);

include/phasar/DB/ProjectIRDB.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef PHASAR_DB_PROJECTIRDB_H_
1111
#define PHASAR_DB_PROJECTIRDB_H_
1212

13-
#include <initializer_list>
13+
#include <iostream>
1414
#include <map>
1515
#include <memory>
1616
#include <set>
@@ -146,7 +146,8 @@ class ProjectIRDB {
146146

147147
void print() const;
148148

149-
void emitPreprocessedIR(std::ostream &os, bool shortendIR) const;
149+
void emitPreprocessedIR(std::ostream &os = std::cout,
150+
bool shortendIR = true) const;
150151

151152
/**
152153
* Allows the (de-)serialization of Instructions, Arguments, GlobalValues and

include/phasar/PhasarLLVM/AnalysisStrategy/WholeProgramAnalysis.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,27 @@ class WholeProgramAnalysis {
128128

129129
void operator()() { solve(); }
130130

131-
void dumpResults(std::ostream &OS = std::cout) {}
131+
void dumpResults(std::ostream &OS = std::cout) {
132+
DataFlowSolver.dumpResults(OS);
133+
}
132134

133-
void emitTextualReport(std::ostream &OS) {}
135+
void emitTextReport(std::ostream &OS = std::cout) {
136+
DataFlowSolver.emitTextReport(OS);
137+
}
134138

135-
void emitGraphicalReport() {}
139+
void emitGraphicalReport(std::ostream &OS = std::cout) {
140+
DataFlowSolver.emitGraphicalReport(OS);
141+
}
136142

137143
void releaseAllHelperAnalyses() {
138144
releasePointerInformation();
139145
releaseCallGraph();
140146
releaseTypeHierarchy();
141147
}
142148

143-
TypeHierarchyTy *releasePointerInformation() { return PointerInfo.release(); }
149+
PointerAnalysisTy *releasePointerInformation() {
150+
return PointerInfo.release();
151+
}
144152

145153
CallGraphAnalysisTy *releaseCallGraph() { return CallGraph.release(); }
146154

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IDETabulationProblem.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef PHASAR_PHASARLLVM_IFDSIDE_IDETABULATIONPROBLEM_H_
1818
#define PHASAR_PHASARLLVM_IFDSIDE_IDETABULATIONPROBLEM_H_
1919

20+
#include <iostream>
2021
#include <memory>
2122
#include <set>
2223
#include <string>
@@ -51,13 +52,22 @@ class IDETabulationProblem : public IFDSTabulationProblem<N, D, M, T, V, I>,
5152
virtual std::shared_ptr<EdgeFunction<L>> allTopFunction() = 0;
5253
#pragma clang diagnostic push
5354
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
54-
virtual void emitTextReport(std::ostream &os,
55-
const SolverResults<N, D, L> &SR) {
56-
os << "No text report available!\n";
55+
virtual void emitTextReport(const SolverResults<N, D, L> &SR,
56+
std::ostream &OS = std::cout) {
57+
OS << "No text report available!\n";
58+
}
59+
#pragma clang diagnostic pop
60+
61+
#pragma clang diagnostic push
62+
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
63+
virtual void emitGraphicalReport(const SolverResults<N, D, L> &SR,
64+
std::ostream &OS = std::cout) {
65+
OS << "No graphical report available!\n";
5766
}
5867
#pragma clang diagnostic pop
5968
private:
6069
using IFDSTabulationProblem<N, D, M, T, V, I>::emitTextReport;
70+
using IFDSTabulationProblem<N, D, M, T, V, I>::emitGraphicalReport;
6171
};
6272

6373
} // namespace psr

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSIDESolverConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct IFDSIDESolverConfig {
3636
bool followReturnsPastSeeds = false;
3737
bool autoAddZero = true;
3838
bool computeValues = true;
39-
bool recordEdges = false;
39+
bool recordEdges = true;
4040
bool emitESG =
4141
(PhasarConfig::VariablesMap().count("emit-esg-as-dot"))
4242
? PhasarConfig::VariablesMap()["emit-esg-as-dot"].as<bool>()

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSTabulationProblem.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef PHASAR_PHASARLLVM_IFDSIDE_IFDSTABULATIONPROBLEM_H_
1818
#define PHASAR_PHASARLLVM_IFDSIDE_IFDSTABULATIONPROBLEM_H_
1919

20-
#include <initializer_list>
20+
#include <iostream>
2121
#include <map>
2222
#include <set>
2323
#include <string>
@@ -89,9 +89,14 @@ class IFDSTabulationProblem : public virtual FlowFunctions<N, D, M>,
8989

9090
IFDSIDESolverConfig getIFDSIDESolverConfig() const { return SolverConfig; }
9191

92-
virtual void emitTextReport(std::ostream &os,
93-
const SolverResults<N, D, BinaryDomain> &SR) {
94-
os << "No text report available!\n";
92+
virtual void emitTextReport(const SolverResults<N, D, BinaryDomain> &SR,
93+
std::ostream &OS = std::cout) {
94+
OS << "No text report available!\n";
95+
}
96+
97+
virtual void emitGraphicalReport(const SolverResults<N, D, BinaryDomain> &SR,
98+
std::ostream &OS = std::cout) {
99+
OS << "No graphical report available!\n";
95100
}
96101
};
97102
} // namespace psr

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDELinearConstantAnalysis.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDELINEARCONSTANTANALYSIS_H_
1111
#define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDELINEARCONSTANTANALYSIS_H_
1212

13+
#include <iostream>
1314
#include <map>
1415
#include <memory>
1516
#include <set>
@@ -245,8 +246,8 @@ class IDELinearConstantAnalysis
245246

246247
lca_restults_t getLCAResults(SolverResults<n_t, d_t, l_t> SR);
247248

248-
void emitTextReport(std::ostream &os,
249-
const SolverResults<n_t, d_t, l_t> &SR) override;
249+
void emitTextReport(const SolverResults<n_t, d_t, l_t> &SR,
250+
std::ostream &OS = std::cout) override;
250251
};
251252

252253
} // namespace psr

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IDETypeStateAnalysis.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDETYPESTATEANALYSIS_H_
1111
#define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDETYPESTATEANALYSIS_H_
1212

13+
#include <iostream>
1314
#include <map>
1415
#include <memory>
15-
#include <ostream>
1616
#include <set>
1717
#include <string>
1818
#include <type_traits>
@@ -175,8 +175,8 @@ class IDETypeStateAnalysis
175175

176176
void printEdgeFact(std::ostream &os, l_t l) const override;
177177

178-
void emitTextReport(std::ostream &os,
179-
const SolverResults<n_t, d_t, l_t> &SR) override;
178+
void emitTextReport(const SolverResults<n_t, d_t, l_t> &SR,
179+
std::ostream &OS = std::cout) override;
180180

181181
// customize the edge function composer
182182
class TSEdgeFunctionComposer : public EdgeFunctionComposer<l_t> {

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/IFDSConstAnalysis.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IFDSCONSTANALYSIS_H_
1111
#define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IFDSCONSTANALYSIS_H_
1212

13+
#include <iostream>
1314
#include <map>
1415
#include <memory>
1516
#include <set>
@@ -171,8 +172,8 @@ class IFDSConstAnalysis
171172

172173
void printFunction(std::ostream &os, m_t m) const override;
173174

174-
void emitTextReport(std::ostream &os,
175-
const SolverResults<n_t, d_t, BinaryDomain> &SR) override;
175+
void emitTextReport(const SolverResults<n_t, d_t, BinaryDomain> &SR,
176+
std::ostream &OS = std::cout) override;
176177

177178
/**
178179
* @note Global Variables are always intialized in llvm IR, and therefore

0 commit comments

Comments
 (0)