10
10
#ifndef PHASAR_PHASARLLVM_POINTER_FILTEREDLLVMALIASSET_H
11
11
#define PHASAR_PHASARLLVM_POINTER_FILTEREDLLVMALIASSET_H
12
12
13
+ #include " phasar/PhasarLLVM/Pointer/CachedLLVMAliasIterator.h"
13
14
#include " phasar/PhasarLLVM/Pointer/FilteredLLVMAliasIterator.h"
14
- #include " phasar/Pointer/AliasAnalysisType.h"
15
- #include " phasar/Pointer/AliasInfoTraits.h"
16
- #include " phasar/Pointer/AliasResult.h"
17
- #include " phasar/Pointer/AliasSetOwner.h"
18
- #include " phasar/Utils/AnalysisProperties.h"
19
-
20
- #include " llvm/ADT/DenseMap.h"
21
- #include " llvm/ADT/DenseMapInfo.h"
22
- #include " llvm/ADT/Hashing.h"
23
- #include " llvm/ADT/PointerIntPair.h"
24
- #include " llvm/IR/Function.h"
25
- #include " llvm/Support/ErrorHandling.h"
26
-
27
- #include " nlohmann/json_fwd.hpp"
28
-
29
- #include < utility>
30
15
31
16
namespace llvm {
32
17
class Value ;
@@ -41,97 +26,23 @@ template <>
41
26
struct AliasInfoTraits <FilteredLLVMAliasSet>
42
27
: DefaultAATraits<const llvm::Value *, const llvm::Instruction *> {};
43
28
44
- class FilteredLLVMAliasSet {
29
+ class FilteredLLVMAliasSet : private FilteredLLVMAliasIterator ,
30
+ public CachedLLVMAliasIterator {
45
31
public:
46
- using alias_traits_t = AliasInfoTraits<FilteredLLVMAliasSet>;
47
- using n_t = alias_traits_t ::n_t ;
48
- using v_t = alias_traits_t ::v_t ;
49
- using AliasSetTy = alias_traits_t ::AliasSetTy;
50
- using AliasSetPtrTy = alias_traits_t ::AliasSetPtrTy;
51
- using AllocationSiteSetPtrTy = alias_traits_t ::AllocationSiteSetPtrTy;
52
-
53
- FilteredLLVMAliasSet (LLVMAliasIteratorRef AS) noexcept ;
54
-
55
- // --- API Functions:
56
-
57
- [[nodiscard]] inline bool isInterProcedural () const noexcept {
58
- return false ;
59
- };
60
-
61
- [[nodiscard]] AliasAnalysisType getAliasAnalysisType () const noexcept ;
62
-
63
- [[nodiscard]] AliasResult alias (const llvm::Value *V1, const llvm::Value *V2,
64
- const llvm::Instruction *I);
65
- [[nodiscard]] AliasResult alias (const llvm::Value *V1, const llvm::Value *V2,
66
- const llvm::Function *Fun);
67
-
68
- [[nodiscard]] AliasSetPtrTy getAliasSet (const llvm::Value *V,
69
- const llvm::Instruction *I);
70
- [[nodiscard]] AliasSetPtrTy getAliasSet (const llvm::Value *V,
71
- const llvm::Function *Fun);
72
-
73
- [[nodiscard]] AllocationSiteSetPtrTy
74
- getReachableAllocationSites (const llvm::Value *V, bool IntraProcOnly = false ,
75
- const llvm::Instruction *I = nullptr );
76
-
77
- // Checks if PotentialValue is in the reachable allocation sites of V.
78
- [[nodiscard]] bool isInReachableAllocationSites (
79
- const llvm::Value *V, const llvm::Value *PotentialValue,
80
- bool IntraProcOnly = false , const llvm::Instruction *I = nullptr );
81
-
82
- void mergeWith (const FilteredLLVMAliasSet & /* OtherPTI*/ ) {
83
- llvm::report_fatal_error (" Not Supported" );
84
- }
85
-
86
- void introduceAlias (const llvm::Value * /* V1*/ , const llvm::Value * /* V2*/ ,
87
- const llvm::Instruction * /* I*/ = nullptr ,
88
- AliasResult /* Kind*/ = AliasResult::MustAlias) {
89
- llvm::report_fatal_error (" Not Supported" );
90
- }
91
-
92
- void print (llvm::raw_ostream &OS = llvm::outs()) const ;
93
-
94
- [[nodiscard]] nlohmann::json getAsJson () const ;
95
-
96
- void printAsJson (llvm::raw_ostream &OS = llvm::outs()) const ;
97
-
98
- [[nodiscard]] AnalysisProperties getAnalysisProperties () const noexcept {
99
- return AnalysisProperties::None;
100
- }
101
-
102
- private:
103
- struct ReachableAllocationSitesKey {
104
- llvm::PointerIntPair<const llvm::Function *, 1 , bool > FunAndIntraProcOnly;
105
- v_t Value{};
106
- };
107
-
108
- struct ReachableAllocationSitesKeyDMI {
109
- inline static ReachableAllocationSitesKey getEmptyKey () noexcept {
110
- return {{}, llvm::DenseMapInfo<v_t >::getEmptyKey ()};
111
- }
112
- inline static ReachableAllocationSitesKey getTombstoneKey () noexcept {
113
- return {{}, llvm::DenseMapInfo<v_t >::getTombstoneKey ()};
114
- }
115
- inline static auto getHashValue (ReachableAllocationSitesKey Key) noexcept {
116
- return llvm::hash_combine (Key.FunAndIntraProcOnly .getOpaqueValue (),
117
- Key.Value );
118
- }
119
- inline static bool isEqual (ReachableAllocationSitesKey Key1,
120
- ReachableAllocationSitesKey Key2) noexcept {
121
- return Key1.FunAndIntraProcOnly == Key2.FunAndIntraProcOnly &&
122
- Key1.Value == Key2.Value ;
123
- }
124
- };
125
-
126
- FilteredLLVMAliasIterator AS;
127
- AliasSetOwner<AliasSetTy>::memory_resource_type MRes;
128
- AliasSetOwner<AliasSetTy> Owner;
129
- llvm::DenseMap<std::pair<const llvm::Function *, v_t >, AliasSetPtrTy>
130
- AliasSetMap;
131
- llvm::DenseMap<ReachableAllocationSitesKey, std::unique_ptr<AliasSetTy>,
132
- ReachableAllocationSitesKeyDMI>
133
- ReachableAllocationSitesMap;
32
+ using typename CachedLLVMAliasIterator::alias_traits_t ;
33
+ using typename CachedLLVMAliasIterator::AliasSetPtrTy;
34
+ using typename CachedLLVMAliasIterator::AliasSetTy;
35
+ using typename CachedLLVMAliasIterator::AllocationSiteSetPtrTy;
36
+ using typename CachedLLVMAliasIterator::n_t ;
37
+ using typename CachedLLVMAliasIterator::v_t ;
38
+
39
+ FilteredLLVMAliasSet (LLVMAliasIteratorRef Underlying) noexcept
40
+ : FilteredLLVMAliasIterator(Underlying),
41
+ CachedLLVMAliasIterator (
42
+ static_cast <FilteredLLVMAliasIterator *>(this )) {}
134
43
};
44
+
45
+ static_assert (std::is_convertible_v<FilteredLLVMAliasSet *, LLVMAliasInfoRef>);
135
46
} // namespace psr
136
47
137
48
#endif // PHASAR_PHASARLLVM_POINTER_FILTEREDLLVMALIASSET_H
0 commit comments