-
Notifications
You must be signed in to change notification settings - Fork 2
/
PointsTo.h
57 lines (46 loc) · 1.69 KB
/
PointsTo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "llvm/IR/Value.h"
#include "InstLoc.h"
#include "Object.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <set>
// This class represents the relation of one memory object pointing to another memory object
class ObjPto
{
public:
ObjId srcObjId;
offset_t srcOffset;
ObjId dstObjId;
offset_t dstOffset;
InstLoc instLoc; // for memory SSA
ObjPto(ObjId srcObjId, offset_t srcOffset, ObjId dstObjId, offset_t dstOffset, InstLoc instLoc);
bool operator<(const ObjPto &rhs) const; // for std::set
};
typedef boost::multi_index::multi_index_container<
ObjPto,
boost::multi_index::indexed_by<
boost::multi_index::ordered_non_unique<
boost::multi_index::composite_key<
ObjPto,
boost::multi_index::member<ObjPto, ObjId, &ObjPto::srcObjId>,
boost::multi_index::member<ObjPto, offset_t, &ObjPto::srcOffset>>>>>
ObjPtos;
class PointsToRecords
{
private:
std::map<llvm::GlobalVariable *, std::set<ObjLoc>> globalData;
std::map<Context, std::map<llvm::Value *, std::set<ObjLoc>>> valueData;
ObjPtos objPtos;
public:
// value
std::set<ObjLoc> getPteesOfValPtr(Context context, llvm::Value *pointer);
void addPteesForValPtr(Context context, llvm::Value *pointer, std::set<ObjLoc> pointees);
// object
std::set<ObjLoc> getPteesOfObjPtr(ObjLoc pointer, InstLoc currLoc);
void addPteesForObjPtr(ObjLoc pointer, std::set<ObjLoc> pointees, InstLoc updateLoc);
std::set<ObjPto> getRecordsOfObj(ObjId objId);
std::string toString();
};