Skip to content

Commit 512ca66

Browse files
committed
merge branch
2 parents 288e44e + efc6452 commit 512ca66

38 files changed

Lines changed: 851 additions & 477 deletions

external/json

Submodule json updated 203 files

include/phasar/DB/ProjectIRDB.h

Lines changed: 11 additions & 5 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,22 +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]] llvm::Instruction *getInstruction(std::size_t id);
171+
[[nodiscard]] inline std::size_t getNumInstructions() const {
172+
return IDInstructionMapping.size();
173+
}
174+
175+
[[nodiscard]] std::size_t getNumGlobals() const;
176+
177+
[[nodiscard]] llvm::Instruction *getInstruction(std::size_t Id);
172178

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

175181
void print() const;
176182

177-
void emitPreprocessedIR(std::ostream &os = std::cout,
183+
void emitPreprocessedIR(std::ostream &OS = std::cout,
178184
bool ShortenIR = false) const;
179185

180186
/**

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h

Lines changed: 4 additions & 14 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;
76+
llvm::DenseSet<const llvm::Function *> VisitedFunctions;
7577
llvm::SmallPtrSet<llvm::Function *, 2> 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;

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class DTAResolver : public CHAResolver {
6161

6262
~DTAResolver() override = default;
6363

64-
std::set<const llvm::Function *>
65-
resolveVirtualCall(const llvm::CallBase *CallSite) override;
64+
FunctionSetTy resolveVirtualCall(const llvm::CallBase *CallSite) override;
6665

6766
void otherInst(const llvm::Instruction *Inst) override;
6867
};

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,14 @@ class NOResolver final : public Resolver {
3636

3737
void preCall(const llvm::Instruction *Inst) override;
3838

39-
void handlePossibleTargets(
40-
const llvm::CallBase *CallSite,
41-
std::set<const llvm::Function *> &PossibleTargets) override;
39+
void handlePossibleTargets(const llvm::CallBase *CallSite,
40+
FunctionSetTy &PossibleTargets) override;
4241

4342
void postCall(const llvm::Instruction *Inst) override;
4443

45-
std::set<const llvm::Function *>
46-
resolveVirtualCall(const llvm::CallBase *CallSite) override;
44+
FunctionSetTy resolveVirtualCall(const llvm::CallBase *CallSite) override;
4745

48-
std::set<const llvm::Function *>
49-
resolveFunctionPointer(const llvm::CallBase *CallSite) override;
46+
FunctionSetTy resolveFunctionPointer(const llvm::CallBase *CallSite) override;
5047

5148
void otherInst(const llvm::Instruction *Inst) override;
5249
};

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020
#include <set>
2121
#include <string>
22+
#include <unordered_map>
2223
#include <unordered_set>
2324
#include <utility>
2425
#include <vector>
2526

2627
#include "phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h"
2728
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToInfo.h"
29+
#include "llvm/ADT/DenseSet.h"
30+
#include "llvm/ADT/TinyPtrVector.h"
2831

2932
namespace llvm {
3033
class Instruction;
@@ -53,20 +56,17 @@ class OTFResolver : public CHAResolver {
5356

5457
void preCall(const llvm::Instruction *Inst) override;
5558

56-
void handlePossibleTargets(
57-
const llvm::CallBase *CallSite,
58-
std::set<const llvm::Function *> &CalleeTargets) override;
59+
void handlePossibleTargets(const llvm::CallBase *CallSite,
60+
FunctionSetTy &CalleeTargets) override;
5961

6062
void postCall(const llvm::Instruction *Inst) override;
6163

62-
std::set<const llvm::Function *>
63-
resolveVirtualCall(const llvm::CallBase *CallSite) override;
64+
FunctionSetTy resolveVirtualCall(const llvm::CallBase *CallSite) override;
6465

65-
std::set<const llvm::Function *>
66-
resolveFunctionPointer(const llvm::CallBase *CallSite) override;
66+
FunctionSetTy resolveFunctionPointer(const llvm::CallBase *CallSite) override;
6767

6868
static std::set<const llvm::Type *>
69-
getReachableTypes(const std::unordered_set<const llvm::Value *> &Values);
69+
getReachableTypes(const LLVMPointsToInfo::PointsToSetTy &Values);
7070

7171
static std::vector<std::pair<const llvm::Value *, const llvm::Value *>>
7272
getActualFormalPointerPairs(const llvm::CallBase *CallSite,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RTAResolver : public CHAResolver {
3434

3535
~RTAResolver() override = default;
3636

37-
virtual std::set<const llvm::Function *>
37+
virtual FunctionSetTy
3838
resolveVirtualCall(const llvm::CallBase *CallSite) override;
3939
};
4040
} // namespace psr

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <set>
2121
#include <string>
2222

23+
#include "llvm/ADT/DenseSet.h"
24+
2325
namespace llvm {
2426
class Instruction;
2527
class CallBase;
@@ -49,23 +51,22 @@ class Resolver {
4951
const llvm::CallBase *CallSite);
5052

5153
public:
54+
using FunctionSetTy = llvm::SmallDenseSet<const llvm::Function *, 4>;
55+
5256
Resolver(ProjectIRDB &IRDB, LLVMTypeHierarchy &TH);
5357

5458
virtual ~Resolver() = default;
5559

5660
virtual void preCall(const llvm::Instruction *Inst);
5761

58-
virtual void
59-
handlePossibleTargets(const llvm::CallBase *CallSite,
60-
std::set<const llvm::Function *> &PossibleTargets);
62+
virtual void handlePossibleTargets(const llvm::CallBase *CallSite,
63+
FunctionSetTy &PossibleTargets);
6164

6265
virtual void postCall(const llvm::Instruction *Inst);
6366

64-
virtual std::set<const llvm::Function *>
65-
resolveVirtualCall(const llvm::CallBase *CallSite) = 0;
67+
virtual FunctionSetTy resolveVirtualCall(const llvm::CallBase *CallSite) = 0;
6668

67-
virtual std::set<const llvm::Function *>
68-
resolveFunctionPointer(const llvm::CallBase *CallSite);
69+
virtual FunctionSetTy resolveFunctionPointer(const llvm::CallBase *CallSite);
6970

7071
virtual void otherInst(const llvm::Instruction *Inst);
7172
};

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class IDEInstInteractionAnalysisT
255255
//
256256
struct IIAFlowFunction : FlowFunction<d_t, container_type> {
257257
const llvm::LoadInst *Load;
258-
std::shared_ptr<std::unordered_set<d_t>> PTS;
258+
LLVMPointsToInfo::AllocationSiteSetPtrTy PTS;
259259

260260
IIAFlowFunction(IDEInstInteractionAnalysisT &Problem,
261261
const llvm::LoadInst *Load)
@@ -300,8 +300,8 @@ class IDEInstInteractionAnalysisT
300300
//
301301
struct IIAFlowFunction : FlowFunction<d_t, container_type> {
302302
const llvm::StoreInst *Store;
303-
std::shared_ptr<std::unordered_set<d_t>> ValuePTS;
304-
std::shared_ptr<std::unordered_set<d_t>> PointerPTS;
303+
LLVMPointsToInfo::AllocationSiteSetPtrTy ValuePTS;
304+
LLVMPointsToInfo::AllocationSiteSetPtrTy PointerPTS;
305305

306306
IIAFlowFunction(IDEInstInteractionAnalysisT &Problem,
307307
const llvm::StoreInst *Store)
@@ -311,8 +311,9 @@ class IDEInstInteractionAnalysisT
311311
Store->getValueOperand(),
312312
Problem.OnlyConsiderLocalAliases);
313313
} else {
314-
return std::make_shared<std::unordered_set<d_t>>(
315-
std::unordered_set<d_t>{Store->getValueOperand()});
314+
return std::make_unique<LLVMPointsToInfo::PointsToSetTy>(
315+
LLVMPointsToInfo::PointsToSetTy{
316+
Store->getValueOperand()});
316317
}
317318
}()),
318319
PointerPTS(Problem.PT->getReachableAllocationSites(

0 commit comments

Comments
 (0)