Skip to content

Commit 54b1785

Browse files
committed
update branch
2 parents 55f64ba + ed67292 commit 54b1785

48 files changed

Lines changed: 1222 additions & 578 deletions

Some content is hidden

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

Config.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ foreach(component ${phasar_FIND_COMPONENTS})
99
endforeach()
1010

1111
function(phasar_config executable)
12-
find_package(LLVM 10 REQUIRED CONFIG)
12+
find_package(LLVM 12 REQUIRED CONFIG)
1313
include_directories(${LLVM_INCLUDE_DIRS})
1414
link_directories(${LLVM_LIB_PATH} ${LLVM_LIBRARY_DIRS})
1515
find_library(LLVM_LIBRARY NAMES LLVM HINTS ${LLVM_LIBRARY_DIRS})

external/googletest

Submodule googletest updated 69 files

external/json

Submodule json updated 373 files

external/json-schema-validator

include/phasar/Controller/AnalysisController.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class AnalysisController {
6262
std::string ProjectID;
6363
std::string OutDirectory;
6464
boost::filesystem::path ResultDirectory;
65-
[[maybe_unused]] Soundness S;
65+
[[maybe_unused]] Soundness SoundnessLevel;
66+
[[maybe_unused]] bool AutoGlobalSupport;
6667

6768
///
6869
/// \brief The maximum length of the CallStrings used in the InterMonoSolver
@@ -117,7 +118,8 @@ class AnalysisController {
117118
std::vector<DataFlowAnalysisKind> DataFlowAnalyses,
118119
std::vector<std::string> AnalysisConfigs,
119120
PointerAnalysisType PTATy, CallGraphAnalysisType CGTy,
120-
Soundness S, const std::set<std::string> &EntryPoints,
121+
Soundness SoundnessLevel, bool AutoGlobalSupport,
122+
const std::set<std::string> &EntryPoints,
121123
AnalysisStrategy Strategy,
122124
AnalysisControllerEmitterOptions EmitterOptions,
123125
const std::string &ProjectID = "default-phasar-project",

include/phasar/DB/ProjectIRDB.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ProjectIRDB {
138138
[[nodiscard]] const llvm::Module *
139139
getModuleDefiningFunction(const std::string &FunctionName) const;
140140

141-
[[nodiscard]] std::set<const llvm::Instruction *>
141+
[[nodiscard]] inline const std::set<const llvm::Instruction *> &
142142
getAllocaInstructions() const {
143143
return AllocaInstructions;
144144
};
@@ -159,26 +159,28 @@ class ProjectIRDB {
159159
[[nodiscard]] std::set<const llvm::StructType *>
160160
getAllocatedStructTypes() const;
161161

162-
[[nodiscard]] std::set<const llvm::Instruction *>
162+
[[nodiscard]] inline std::set<const llvm::Instruction *>
163163
getRetOrResInstructions() const {
164164
return RetOrResInstructions;
165165
};
166166

167-
[[nodiscard]] std::size_t getNumberOfModules() const {
167+
[[nodiscard]] inline std::size_t getNumberOfModules() const {
168168
return Modules.size();
169169
};
170170

171-
[[nodiscard]] std::size_t getNumInstructions() const {
171+
[[nodiscard]] inline std::size_t getNumInstructions() const {
172172
return IDInstructionMapping.size();
173173
}
174174

175-
[[nodiscard]] llvm::Instruction *getInstruction(std::size_t id);
175+
[[nodiscard]] std::size_t getNumGlobals() const;
176+
177+
[[nodiscard]] llvm::Instruction *getInstruction(std::size_t Id);
176178

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

179181
void print() const;
180182

181-
void emitPreprocessedIR(std::ostream &os = std::cout,
183+
void emitPreprocessedIR(std::ostream &OS = std::cout,
182184
bool ShortenIR = false) const;
183185

184186
/**

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFG.h

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <unordered_set>
1919
#include <vector>
2020

21+
#include "llvm/IR/LLVMContext.h"
22+
2123
#include "phasar/PhasarLLVM/ControlFlow/ICFG.h"
2224
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedBackwardCFG.h"
2325
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h"
@@ -42,17 +44,28 @@ class LLVMBasedBackwardsICFG
4244
: public ICFG<const llvm::Instruction *, const llvm::Function *>,
4345
public virtual LLVMBasedBackwardCFG {
4446
private:
45-
LLVMBasedICFG ForwardICFG;
47+
LLVMBasedICFG &ForwardICFG;
48+
static inline const std::unique_ptr<llvm::LLVMContext> LLVMBackwardRetCTX =
49+
std::make_unique<llvm::LLVMContext>();
50+
51+
class LLVMBackwardRet {
52+
private:
53+
const llvm::ReturnInst *Instance;
54+
55+
public:
56+
LLVMBackwardRet()
57+
: Instance(llvm::ReturnInst::Create(*LLVMBackwardRetCTX)){};
58+
[[nodiscard]] const llvm::ReturnInst *getInstance() const {
59+
return Instance;
60+
}
61+
};
62+
std::unordered_map<const llvm::Function *, LLVMBackwardRet> BackwardRets;
63+
llvm::DenseMap<const llvm::Instruction *, const llvm::Function *>
64+
BackwardRetToFunction;
4665

4766
public:
4867
LLVMBasedBackwardsICFG(LLVMBasedICFG &ICFG);
4968

50-
LLVMBasedBackwardsICFG(ProjectIRDB &IRDB, CallGraphAnalysisType CGType,
51-
const std::set<std::string> &EntryPoints = {},
52-
LLVMTypeHierarchy *TH = nullptr,
53-
LLVMPointsToInfo *PT = nullptr,
54-
Soundness S = Soundness::Soundy);
55-
5669
~LLVMBasedBackwardsICFG() override = default;
5770

5871
std::set<const llvm::Function *> getAllFunctions() const override;
@@ -77,6 +90,20 @@ class LLVMBasedBackwardsICFG
7790

7891
std::set<const llvm::Instruction *> allNonCallStartNodes() const override;
7992

93+
[[nodiscard]] const llvm::Function *
94+
getFunctionOf(const llvm::Instruction *Stmt) const override;
95+
96+
[[nodiscard]] std::vector<const llvm::Instruction *>
97+
getPredsOf(const llvm::Instruction *Stmt) const override;
98+
99+
[[nodiscard]] std::vector<const llvm::Instruction *>
100+
getSuccsOf(const llvm::Instruction *Stmt) const override;
101+
102+
[[nodiscard]] std::set<const llvm::Instruction *>
103+
getExitPointsOf(const llvm::Function *Fun) const override;
104+
105+
[[nodiscard]] bool isExitInst(const llvm::Instruction *Stmt) const override;
106+
80107
void mergeWith(const LLVMBasedBackwardsICFG &other);
81108

82109
using LLVMBasedBackwardCFG::print; // tell the compiler we wish to have both
@@ -95,6 +122,9 @@ class LLVMBasedBackwardsICFG
95122

96123
std::vector<const llvm::Function *> getDependencyOrderedFunctions();
97124

125+
private:
126+
void createBackwardRets();
127+
98128
protected:
99129
void collectGlobalCtors() override;
100130

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ class LLVMBasedCFG
7474

7575
[[nodiscard]] bool
7676
isFallThroughSuccessor(const llvm::Instruction *Inst,
77-
const llvm::Instruction *succ) const override;
77+
const llvm::Instruction *Succ) const override;
7878

7979
[[nodiscard]] bool
8080
isBranchTarget(const llvm::Instruction *Inst,
81-
const llvm::Instruction *succ) const override;
81+
const llvm::Instruction *Succ) const override;
8282

8383
[[nodiscard]] bool
8484
isHeapAllocatingFunction(const llvm::Function *Fun) const override;

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
#include "boost/container/flat_set.hpp"
3131
#include "boost/graph/adjacency_list.hpp"
3232

33+
#include "llvm/ADT/DenseSet.h"
3334
#include "llvm/ADT/StringRef.h"
3435
#include "llvm/IR/Constants.h"
36+
#include "llvm/IR/InstrTypes.h"
3537
#include "llvm/IR/Instruction.h"
3638
#include "llvm/IR/Module.h"
3739

@@ -71,35 +73,23 @@ class LLVMBasedICFG
7173
LLVMTypeHierarchy *TH;
7274
LLVMPointsToInfo *PT;
7375
std::unique_ptr<Resolver> Res;
74-
std::unordered_set<const llvm::Function *> VisitedFunctions;
75-
llvm::SmallPtrSet<llvm::Function *, 2> UserEntryPoints;
76+
llvm::DenseSet<const llvm::Function *> VisitedFunctions;
77+
std::unordered_set<llvm::Function *> UserEntryPoints;
7678

7779
GlobalCtorTy GlobalCtors;
7880
GlobalDtorTy GlobalDtors;
7981

80-
// llvm::SmallDenseMap<F, typename GlobalCtorTy::const_iterator, 2>
81-
// GlobalCtorFn; llvm::SmallDenseMap<F, typename GlobalDtorTy::const_iterator,
82-
// 2> GlobalDtorFn;
83-
8482
llvm::Function *GlobalCleanupFn = nullptr;
8583

8684
llvm::SmallDenseMap<const llvm::Module *, llvm::Function *>
8785
GlobalRegisteredDtorsCaller;
88-
/// Keeps track of the call-sites already resolved
89-
// std::vector<const llvm::Instruction *> CallStack;
90-
91-
// Keeps track of the type graph already constructed
92-
// TypeGraph_t typegraph;
93-
94-
// Any types that could be initialized outside of the module
95-
// std::set<const llvm::StructType*> unsound_types;
9686

9787
// The worklist for direct callee resolution.
9888
std::vector<const llvm::Function *> FunctionWL;
9989

10090
// Map indirect calls to the number of possible targets found for it. Fixpoint
10191
// is not reached when more targets are found.
102-
std::unordered_map<const llvm::Instruction *, unsigned> IndirectCalls;
92+
llvm::DenseMap<const llvm::Instruction *, unsigned> IndirectCalls;
10393
// The VertexProperties for our call-graph.
10494
struct VertexProperties {
10595
const llvm::Function *F = nullptr;
@@ -192,7 +182,7 @@ class LLVMBasedICFG
192182
LLVMBasedICFG(ProjectIRDB &IRDB, CallGraphAnalysisType CGType,
193183
const std::set<std::string> &EntryPoints = {},
194184
LLVMTypeHierarchy *TH = nullptr, LLVMPointsToInfo *PT = nullptr,
195-
Soundness S = Soundness::Soundy, bool IncludeGlobals = false);
185+
Soundness S = Soundness::Soundy, bool IncludeGlobals = true);
196186

197187
LLVMBasedICFG(const LLVMBasedICFG &);
198188

include/phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class CHAResolver : public Resolver {
3333

3434
~CHAResolver() override = default;
3535

36-
std::set<const llvm::Function *>
37-
resolveVirtualCall(const llvm::CallBase *CallSite) override;
36+
FunctionSetTy resolveVirtualCall(const llvm::CallBase *CallSite) override;
3837
};
3938
} // namespace psr
4039

0 commit comments

Comments
 (0)