Skip to content

Commit 797ade3

Browse files
authored
Merge pull request #515 from secure-software-engineering/f-RedesignICFG
Redesign ICFG
2 parents 11aab80 + 499a19d commit 797ade3

150 files changed

Lines changed: 4624 additions & 3922 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Checks: '-*,
1515
-readability-function-cognitive-complexity,
1616
-readability-convert-member-functions-to-static,
1717
-readability-isolate-declaration,
18+
-readability-identifier-length,
1819
cppcoreguidelines-*,
1920
-cppcoreguidelines-avoid-non-const-global-variables,
2021
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
@@ -28,7 +29,6 @@ Checks: '-*,
2829
-bugprone-easily-swappable-parameters,
2930
modernize-*,
3031
-modernize-use-trailing-return-type,
31-
-modernize-pass-by-value,
3232
performance-*,
3333
clang-analyzer-*,
3434
'

config/DOTGraphConfig.json

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
11
{
2-
"CFNode": {
3-
"style": "filled",
4-
"shape": "record"
5-
},
6-
"CFIntraEdge": {
7-
},
8-
"CFInterEdge": {
9-
"weight": "1"
10-
},
11-
"FactNode": {
12-
"style": "rounded"
13-
},
14-
"FactIDEdge": {
15-
"style": "dotted",
16-
"arrowhead": "normal",
17-
"fontsize": "11",
18-
"arrowsize": "0.7"
19-
},
20-
"FactCrossEdge": {
2+
"CFNode": {
3+
"style": "filled",
4+
"shape": "record"
5+
},
6+
"CFIntraEdge": {},
7+
"CFInterEdge": {
8+
"weight": "1"
9+
},
10+
"FactNode": {
11+
"style": "rounded"
12+
},
13+
"FactIDEdge": {
2114
"style": "dotted",
22-
"arrowhead": "normal",
23-
"fontsize": "11",
24-
"arrowsize": "0.7"
25-
},
26-
"FactInterEdge": {
15+
"arrowhead": "normal",
16+
"fontsize": "11",
17+
"arrowsize": "0.7"
18+
},
19+
"FactCrossEdge": {
20+
"style": "dotted",
21+
"arrowhead": "normal",
22+
"fontsize": "11",
23+
"arrowsize": "0.7"
24+
},
25+
"FactInterEdge": {
2726
"weight": "0.1",
28-
"style": "dashed",
29-
"arrowhead": "normal",
30-
"fontsize": "11",
31-
"arrowsize": "0.7"
32-
},
33-
"LambdaNode": {
34-
"style": "rounded"
35-
},
36-
"LambdaIDEdge": {
37-
"style": "dotted",
38-
"arrowhead": "normal",
39-
"fontsize": "11",
40-
"arrowsize": "0.7"
41-
},
42-
"LambdaInterEdge": {
27+
"style": "dashed",
28+
"arrowhead": "normal",
29+
"fontsize": "11",
30+
"arrowsize": "0.7"
31+
},
32+
"LambdaNode": {
33+
"style": "rounded"
34+
},
35+
"LambdaIDEdge": {
36+
"style": "dotted",
37+
"arrowhead": "normal",
38+
"fontsize": "11",
39+
"arrowsize": "0.7"
40+
},
41+
"LambdaInterEdge": {
4342
"weight": "0.1",
44-
"style": "dashed",
45-
"arrowhead": "normal",
46-
"fontsize": "11",
47-
"arrowsize": "0.7"
48-
}
43+
"style": "dashed",
44+
"arrowhead": "normal",
45+
"fontsize": "11",
46+
"arrowsize": "0.7"
47+
}
4948
}
Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
{
2-
"Source Functions": {
3-
"source()": {
4-
"Args": [],
5-
"Return": true
6-
},
7-
"read": {
8-
"Args": [0, 1, 3],
9-
"Return": false
10-
}
11-
},
12-
"Sink Functions": {
13-
"sink(int)": {
14-
"Args": [0]
15-
},
16-
"write": {
17-
"Args": [1]
18-
}
19-
}
2+
"Source Functions": {
3+
"source()": {
4+
"Args": [],
5+
"Return": true
6+
},
7+
"read": {
8+
"Args": [
9+
0,
10+
1,
11+
3
12+
],
13+
"Return": false
14+
}
15+
},
16+
"Sink Functions": {
17+
"sink(int)": {
18+
"Args": [
19+
0
20+
]
21+
},
22+
"write": {
23+
"Args": [
24+
1
25+
]
26+
}
27+
}
2028
}

include/phasar/Controller/AnalysisController.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ enum class AnalysisControllerEmitterOptions : uint32_t {
4343
EmitTHAsText = (1 << 5),
4444
EmitTHAsDot = (1 << 6),
4545
EmitTHAsJson = (1 << 7),
46-
EmitCGAsText = (1 << 8),
46+
// EmitCGAsText = (1 << 8),
4747
EmitCGAsDot = (1 << 9),
48-
EmitCGAsJson = (1 << 10),
48+
// EmitCGAsJson = (1 << 10),
4949
EmitPTAAsText = (1 << 11),
5050
EmitPTAAsDot = (1 << 12),
5151
EmitPTAAsJson = (1 << 13),
@@ -60,7 +60,7 @@ class AnalysisController {
6060
LLVMBasedICFG ICF;
6161
std::vector<DataFlowAnalysisType> DataFlowAnalyses;
6262
std::vector<std::string> AnalysisConfigs;
63-
std::set<std::string> EntryPoints;
63+
std::vector<std::string> EntryPoints;
6464
[[maybe_unused]] AnalysisStrategy Strategy;
6565
AnalysisControllerEmitterOptions EmitterOptions =
6666
AnalysisControllerEmitterOptions::None;
@@ -193,7 +193,7 @@ class AnalysisController {
193193
std::vector<std::string> AnalysisConfigs,
194194
PointerAnalysisType PTATy, CallGraphAnalysisType CGTy,
195195
Soundness SoundnessLevel, bool AutoGlobalSupport,
196-
const std::set<std::string> &EntryPoints,
196+
std::vector<std::string> EntryPoints,
197197
AnalysisStrategy Strategy,
198198
AnalysisControllerEmitterOptions EmitterOptions,
199199
IFDSIDESolverConfig SolverConfig,

include/phasar/DB/ProjectIRDB.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class ProjectIRDB {
6161
std::map<std::string, std::unique_ptr<llvm::Module>> Modules;
6262
// Maps an id to its corresponding instruction
6363
std::map<std::size_t, llvm::Instruction *> IDInstructionMapping;
64-
size_t NumberCallsites;
64+
size_t NumGlobals = 0;
65+
size_t NumberCallsites = 0;
6566
nlohmann::json StatsJson;
6667

6768
void buildIDModuleMapping(llvm::Module *M);
@@ -97,6 +98,7 @@ class ProjectIRDB {
9798
~ProjectIRDB();
9899

99100
void insertModule(llvm::Module *M);
101+
void insertFunction(llvm::Function *F);
100102

101103
// add WPA support by providing a fat completely linked module
102104
void linkForWPA();
@@ -180,6 +182,8 @@ class ProjectIRDB {
180182

181183
[[nodiscard]] std::size_t getNumGlobals() const;
182184

185+
[[nodiscard]] std::size_t getNumFunctions() const;
186+
183187
[[nodiscard]] llvm::Instruction *getInstruction(std::size_t Id) const;
184188

185189
[[nodiscard]] static std::size_t getInstructionID(const llvm::Instruction *I);

include/phasar/PhasarLLVM/AnalysisStrategy/WholeProgramAnalysis.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "phasar/DB/ProjectIRDB.h"
2121
#include "phasar/PhasarLLVM/AnalysisStrategy/AnalysisSetup.h"
22+
#include "phasar/PhasarLLVM/ControlFlow/Resolver/CallGraphAnalysisType.h"
2223
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSIDESolverConfig.h"
2324
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver/IDESolver.h"
2425

@@ -54,7 +55,7 @@ class WholeProgramAnalysis {
5455

5556
public:
5657
WholeProgramAnalysis(IFDSIDESolverConfig SolverConfig, ProjectIRDB &IRDB,
57-
std::set<std::string> EntryPoints = {},
58+
llvm::ArrayRef<std::string> EntryPoints = {},
5859
PointerAnalysisTy *PointerInfo = nullptr,
5960
CallGraphAnalysisTy *CallGraph = nullptr,
6061
TypeHierarchyTy *TypeHierarchy = nullptr)
@@ -67,11 +68,12 @@ class WholeProgramAnalysis {
6768
: std::unique_ptr<PointerAnalysisTy>(PointerInfo)),
6869
CallGraph(CallGraph == nullptr
6970
? std::make_unique<CallGraphAnalysisTy>(
70-
IRDB, CallGraphAnalysisType::OTF, EntryPoints,
71+
&IRDB, CallGraphAnalysisType::OTF, EntryPoints,
7172
this->TypeHierarchy.get(), this->PointerInfo.get())
7273
: std::unique_ptr<CallGraphAnalysisTy>(CallGraph)),
73-
EntryPoints(EntryPoints),
74-
ProblemDesc(&IRDB, TypeHierarchy, CallGraph, PointerInfo, EntryPoints),
74+
EntryPoints(EntryPoints.begin(), EntryPoints.end()),
75+
ProblemDesc(&IRDB, TypeHierarchy, CallGraph, PointerInfo,
76+
this->EntryPoints),
7577
DataFlowSolver(ProblemDesc) {
7678
if constexpr (has_setIFDSIDESolverConfig_v<ProblemDescription>) {
7779
ProblemDesc.setIFDSIDESolverConfig(SolverConfig);
@@ -83,7 +85,7 @@ class WholeProgramAnalysis {
8385
typename T::ConfigurationTy, HasNoConfigurationType>>>
8486
WholeProgramAnalysis(IFDSIDESolverConfig SolverConfig, ProjectIRDB &IRDB,
8587
ConfigurationTy *Config,
86-
std::set<std::string> EntryPoints = {},
88+
llvm::ArrayRef<std::string> EntryPoints = {},
8789
PointerAnalysisTy *PointerInfo = nullptr,
8890
CallGraphAnalysisTy *CallGraph = nullptr,
8991
TypeHierarchyTy *TypeHierarchy = nullptr)
@@ -96,12 +98,12 @@ class WholeProgramAnalysis {
9698
: std::unique_ptr<PointerAnalysisTy>(PointerInfo)),
9799
CallGraph(CallGraph == nullptr
98100
? std::make_unique<CallGraphAnalysisTy>(
99-
IRDB, CallGraphAnalysisType::OTF, EntryPoints,
101+
&IRDB, CallGraphAnalysisType::OTF, EntryPoints,
100102
this->TypeHierarchy.get(), this->PointerInfo.get())
101103
: std::unique_ptr<CallGraphAnalysisTy>(CallGraph)),
102-
EntryPoints(EntryPoints), Config(Config),
104+
EntryPoints(EntryPoints.begin(), EntryPoints.end()), Config(Config),
103105
ProblemDesc(&IRDB, TypeHierarchy, CallGraph, PointerInfo, *Config,
104-
EntryPoints),
106+
this->EntryPoints),
105107
DataFlowSolver(ProblemDesc) {
106108
if constexpr (has_setIFDSIDESolverConfig_v<ProblemDescription>) {
107109
ProblemDesc.setIFDSIDESolverConfig(SolverConfig);
@@ -113,7 +115,7 @@ class WholeProgramAnalysis {
113115
typename T::ConfigurationTy, HasNoConfigurationType>>>
114116
WholeProgramAnalysis(IFDSIDESolverConfig SolverConfig, ProjectIRDB &IRDB,
115117
std::string ConfigPath,
116-
std::set<std::string> EntryPoints = {},
118+
llvm::ArrayRef<std::string> EntryPoints = {},
117119
PointerAnalysisTy *PointerInfo = nullptr,
118120
CallGraphAnalysisTy *CallGraph = nullptr,
119121
TypeHierarchyTy *TypeHierarchy = nullptr)
@@ -126,13 +128,14 @@ class WholeProgramAnalysis {
126128
: std::unique_ptr<PointerAnalysisTy>(PointerInfo)),
127129
CallGraph(CallGraph == nullptr
128130
? std::make_unique<CallGraphAnalysisTy>(
129-
IRDB, CallGraphAnalysisType::OTF, EntryPoints,
131+
&IRDB, CallGraphAnalysisType::OTF, EntryPoints,
130132
this->TypeHierarchy.get(), this->PointerInfo.get())
131133
: std::unique_ptr<CallGraphAnalysisTy>(CallGraph)),
132-
EntryPoints(EntryPoints), Config(new ConfigurationTy(ConfigPath)),
133-
OwnsConfig(true), ConfigPath(ConfigPath),
134+
EntryPoints(EntryPoints.begin(), EntryPoints.end()),
135+
Config(new ConfigurationTy(ConfigPath)), OwnsConfig(true),
136+
ConfigPath(ConfigPath),
134137
ProblemDesc(&IRDB, TypeHierarchy, CallGraph, PointerInfo, *Config,
135-
EntryPoints),
138+
this->EntryPoints),
136139
DataFlowSolver(ProblemDesc) {
137140
if constexpr (has_setIFDSIDESolverConfig_v<ProblemDescription>) {
138141
ProblemDesc.setIFDSIDESolverConfig(SolverConfig);

include/phasar/PhasarLLVM/ControlFlow/BiDiICFG.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)