/builds/2mk6rsew/0/parcoach/parcoach/src/aSSA/Utils.h
Line | Count | Source |
1 | | #ifndef UTILS_H |
2 | | #define UTILS_H |
3 | | |
4 | | #include "llvm/ADT/STLExtras.h" |
5 | | #include "llvm/Analysis/PostDominators.h" |
6 | | |
7 | | #include <vector> |
8 | | |
9 | | bool isCallSite(llvm::Instruction const *inst); |
10 | | |
11 | | std::string getValueLabel(llvm::Value const *v); |
12 | | std::string getCallValueLabel(llvm::Value const *v); |
13 | | |
14 | | std::vector<llvm::BasicBlock *> |
15 | | iterated_postdominance_frontier(llvm::PostDominatorTree &PDT, |
16 | | llvm::BasicBlock *BB); |
17 | | |
18 | | std::set<llvm::Value const *> |
19 | | computeIPDFPredicates(llvm::PostDominatorTree &PDT, llvm::BasicBlock *BB); |
20 | | |
21 | | llvm::Value const *getReturnValue(llvm::Function const *F); |
22 | | |
23 | | bool isIntrinsicDbgFunction(llvm::Function const *F); |
24 | | |
25 | | bool isIntrinsicDbgInst(llvm::Instruction const *I); |
26 | | |
27 | | bool functionDoesNotRet(llvm::Function const *F); |
28 | | |
29 | | llvm::Value const *getBasicBlockCond(llvm::BasicBlock const *BB); |
30 | | |
31 | | unsigned getBBSetIntersectionSize(const std::set<llvm::BasicBlock const *> S1, |
32 | | const std::set<llvm::BasicBlock const *> S2); |
33 | | |
34 | | unsigned |
35 | | getInstSetIntersectionSize(const std::set<llvm::Instruction const *> S1, |
36 | | const std::set<llvm::Instruction const *> S2); |
37 | | |
38 | | // This is a small helper to always get a valid - possibly empty - range |
39 | | // contained in a const container. |
40 | | // Motivation: operator[] is not const, llvm's lookup is const but obviously |
41 | | // returns a value and not a reference. |
42 | | // This attempts to bring the best of both approach: provide a range over the |
43 | | // contained set/map, using a default empty set/map if it does not exist in |
44 | | // the map. |
45 | | template <typename Container, typename KeyTy> |
46 | 293k | auto getRange(Container const &C, KeyTy K) { |
47 | 293k | static_assert(std::is_pointer_v<KeyTy>, |
48 | 293k | "getRange must have a KeyTy which is a pointer"); |
49 | 293k | static decltype(C.lookup(K)) const Empty; |
50 | 293k | auto It = C.find(K); |
51 | 293k | if (It != C.end()) { |
52 | 276k | return llvm::make_range(It->second.begin(), It->second.end()); |
53 | 276k | } else { |
54 | 16.3k | return llvm::make_range(Empty.begin(), Empty.end()); |
55 | 16.3k | } |
56 | 293k | } _Z8getRangeIN4llvm8ValueMapIPKNS0_8FunctionESt6vectorISt10unique_ptrI7MSSAChiSt14default_deleteIS7_EESaISA_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 17.9k | auto getRange(Container const &C, KeyTy K) { | 47 | 17.9k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 17.9k | "getRange must have a KeyTy which is a pointer"); | 49 | 17.9k | static decltype(C.lookup(K)) const Empty; | 50 | 17.9k | auto It = C.find(K); | 51 | 17.9k | if (It != C.end()) { | 52 | 1.82k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 16.1k | } else { | 54 | 16.1k | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 16.1k | } | 56 | 17.9k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8FunctionESt3mapIPNS0_8CallBaseESt10unique_ptrI7MSSAChiSt14default_deleteIS9_EESt4lessIS7_ESaISt4pairIKS7_SC_EEENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 4.18k | auto getRange(Container const &C, KeyTy K) { | 47 | 4.18k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 4.18k | "getRange must have a KeyTy which is a pointer"); | 49 | 4.18k | static decltype(C.lookup(K)) const Empty; | 50 | 4.18k | auto It = C.find(K); | 51 | 4.18k | if (It != C.end()) { | 52 | 4.18k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 4.18k | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 4.18k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8FunctionESt3mapIPNS0_8CallBaseES5_IjP7MSSAChiSt4lessIjESaISt4pairIKjS9_EEESA_IS7_ESaISC_IKS7_SG_EEENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 68.4k | auto getRange(Container const &C, KeyTy K) { | 47 | 68.4k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 68.4k | "getRange must have a KeyTy which is a pointer"); | 49 | 68.4k | static decltype(C.lookup(K)) const Empty; | 50 | 68.4k | auto It = C.find(K); | 51 | 68.4k | if (It != C.end()) { | 52 | 68.4k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 68.4k | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 68.4k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8FunctionESt3setIPNS0_8CallBaseESt4lessIS7_ESaIS7_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 16.1k | auto getRange(Container const &C, KeyTy K) { | 47 | 16.1k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 16.1k | "getRange must have a KeyTy which is a pointer"); | 49 | 16.1k | static decltype(C.lookup(K)) const Empty; | 50 | 16.1k | auto It = C.find(K); | 51 | 16.1k | if (It != C.end()) { | 52 | 16.1k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 16.1k | } else { | 54 | 1 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 1 | } | 56 | 16.1k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_10BasicBlockESt6vectorISt10unique_ptrI7MSSAPhiSt14default_deleteIS7_EESaISA_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEEPS2_EDaRKT_T0_ Line | Count | Source | 46 | 15.0k | auto getRange(Container const &C, KeyTy K) { | 47 | 15.0k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 15.0k | "getRange must have a KeyTy which is a pointer"); | 49 | 15.0k | static decltype(C.lookup(K)) const Empty; | 50 | 15.0k | auto It = C.find(K); | 51 | 15.0k | if (It != C.end()) { | 52 | 15.0k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 15.0k | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 15.0k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8LoadInstESt6vectorISt10unique_ptrI6MSSAMuSt14default_deleteIS7_EESaISA_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEEPS2_EDaRKT_T0_ Line | Count | Source | 46 | 43.9k | auto getRange(Container const &C, KeyTy K) { | 47 | 43.9k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 43.9k | "getRange must have a KeyTy which is a pointer"); | 49 | 43.9k | static decltype(C.lookup(K)) const Empty; | 50 | 43.9k | auto It = C.find(K); | 51 | 43.9k | if (It != C.end()) { | 52 | 43.9k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 43.9k | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 43.9k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_9StoreInstESt6vectorISt10unique_ptrI7MSSAChiSt14default_deleteIS7_EESaISA_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEEPS2_EDaRKT_T0_ Line | Count | Source | 46 | 26.4k | auto getRange(Container const &C, KeyTy K) { | 47 | 26.4k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 26.4k | "getRange must have a KeyTy which is a pointer"); | 49 | 26.4k | static decltype(C.lookup(K)) const Empty; | 50 | 26.4k | auto It = C.find(K); | 51 | 26.4k | if (It != C.end()) { | 52 | 26.4k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 26.4k | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 26.4k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_7PHINodeESt3setIPKNS0_5ValueESt4lessIS8_ESaIS8_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEEPS2_EDaRKT_T0_ Line | Count | Source | 46 | 49 | auto getRange(Container const &C, KeyTy K) { | 47 | 49 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 49 | "getRange must have a KeyTy which is a pointer"); | 49 | 49 | static decltype(C.lookup(K)) const Empty; | 50 | 49 | auto It = C.find(K); | 51 | 49 | if (It != C.end()) { | 52 | 49 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 49 | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 49 | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_11InstructionESt3setIPKNS0_8FunctionESt4lessIS8_ESaIS8_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEEPNS0_8CallInstEEDaRKT_T0_ Line | Count | Source | 46 | 12 | auto getRange(Container const &C, KeyTy K) { | 47 | 12 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 12 | "getRange must have a KeyTy which is a pointer"); | 49 | 12 | static decltype(C.lookup(K)) const Empty; | 50 | 12 | auto It = C.find(K); | 51 | 12 | if (It != C.end()) { | 52 | 12 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 12 | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 12 | } |
_Z8getRangeIN4llvm8ValueMapIPNS0_8CallBaseESt6vectorISt10unique_ptrI7MSSAChiSt14default_deleteIS6_EESaIS9_EENS0_14ValueMapConfigIS3_NS0_3sys10SmartMutexILb0EEEEEEEPNS0_8CallInstEEDaRKT_T0_ Line | Count | Source | 46 | 57.7k | auto getRange(Container const &C, KeyTy K) { | 47 | 57.7k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 57.7k | "getRange must have a KeyTy which is a pointer"); | 49 | 57.7k | static decltype(C.lookup(K)) const Empty; | 50 | 57.7k | auto It = C.find(K); | 51 | 57.7k | if (It != C.end()) { | 52 | 57.7k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 57.7k | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 57.7k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8CallBaseESt6vectorISt10unique_ptrI6MSSAMuSt14default_deleteIS7_EESaISA_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEEPNS0_8CallInstEEDaRKT_T0_ Line | Count | Source | 46 | 27.5k | auto getRange(Container const &C, KeyTy K) { | 47 | 27.5k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 27.5k | "getRange must have a KeyTy which is a pointer"); | 49 | 27.5k | static decltype(C.lookup(K)) const Empty; | 50 | 27.5k | auto It = C.find(K); | 51 | 27.5k | if (It != C.end()) { | 52 | 27.5k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 27.5k | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 27.5k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8FunctionESt3setIPKNS0_5ValueESt4lessIS8_ESaIS8_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 24 | auto getRange(Container const &C, KeyTy K) { | 47 | 24 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 24 | "getRange must have a KeyTy which is a pointer"); | 49 | 24 | static decltype(C.lookup(K)) const Empty; | 50 | 24 | auto It = C.find(K); | 51 | 24 | if (It != C.end()) { | 52 | 14 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 14 | } else { | 54 | 10 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 10 | } | 56 | 24 | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8FunctionESt3setIP7MSSAVarSt4lessIS7_ESaIS7_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 17 | auto getRange(Container const &C, KeyTy K) { | 47 | 17 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 17 | "getRange must have a KeyTy which is a pointer"); | 49 | 17 | static decltype(C.lookup(K)) const Empty; | 50 | 17 | auto It = C.find(K); | 51 | 17 | if (It != C.end()) { | 52 | 11 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 11 | } else { | 54 | 6 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 6 | } | 56 | 17 | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_10BasicBlockESt6vectorISt10unique_ptrI7MSSAPhiSt14default_deleteIS7_EESaISA_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 15.3k | auto getRange(Container const &C, KeyTy K) { | 47 | 15.3k | static_assert(std::is_pointer_v<KeyTy>, | 48 | 15.3k | "getRange must have a KeyTy which is a pointer"); | 49 | 15.3k | static decltype(C.lookup(K)) const Empty; | 50 | 15.3k | auto It = C.find(K); | 51 | 15.3k | if (It != C.end()) { | 52 | 15.1k | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 15.1k | } else { | 54 | 169 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 169 | } | 56 | 15.3k | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_5ValueESt3setIS4_St4lessIS4_ESaIS4_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 4 | auto getRange(Container const &C, KeyTy K) { | 47 | 4 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 4 | "getRange must have a KeyTy which is a pointer"); | 49 | 4 | static decltype(C.lookup(K)) const Empty; | 50 | 4 | auto It = C.find(K); | 51 | 4 | if (It != C.end()) { | 52 | 4 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 4 | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 4 | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_5ValueESt3setIP7MSSAVarSt4lessIS7_ESaIS7_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEES4_EDaRKT_T0_ Line | Count | Source | 46 | 3 | auto getRange(Container const &C, KeyTy K) { | 47 | 3 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 3 | "getRange must have a KeyTy which is a pointer"); | 49 | 3 | static decltype(C.lookup(K)) const Empty; | 50 | 3 | auto It = C.find(K); | 51 | 3 | if (It != C.end()) { | 52 | 1 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 2 | } else { | 54 | 2 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 2 | } | 56 | 3 | } |
_Z8getRangeIN4llvm8DenseMapIP7MSSAVarSt3setIPKNS0_5ValueESt4lessIS7_ESaIS7_EENS0_12DenseMapInfoIS3_vEENS0_6detail12DenseMapPairIS3_SB_EEEES3_EDaRKT_T0_ Line | Count | Source | 46 | 2 | auto getRange(Container const &C, KeyTy K) { | 47 | 2 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 2 | "getRange must have a KeyTy which is a pointer"); | 49 | 2 | static decltype(C.lookup(K)) const Empty; | 50 | 2 | auto It = C.find(K); | 51 | 2 | if (It != C.end()) { | 52 | 2 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 2 | } else { | 54 | 0 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 0 | } | 56 | 2 | } |
_Z8getRangeIN4llvm8DenseMapIP7MSSAVarSt3setIS3_St4lessIS3_ESaIS3_EENS0_12DenseMapInfoIS3_vEENS0_6detail12DenseMapPairIS3_S8_EEEES3_EDaRKT_T0_ Line | Count | Source | 46 | 1 | auto getRange(Container const &C, KeyTy K) { | 47 | 1 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 1 | "getRange must have a KeyTy which is a pointer"); | 49 | 1 | static decltype(C.lookup(K)) const Empty; | 50 | 1 | auto It = C.find(K); | 51 | 1 | if (It != C.end()) { | 52 | 0 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 1 | } else { | 54 | 1 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 1 | } | 56 | 1 | } |
_Z8getRangeIN4llvm8ValueMapIPKNS0_8FunctionESt3setIP11MemRegEntrySt4lessIS7_ESaIS7_EENS0_14ValueMapConfigIS4_NS0_3sys10SmartMutexILb0EEEEEEEPS2_EDaRKT_T0_ Line | Count | Source | 46 | 42 | auto getRange(Container const &C, KeyTy K) { | 47 | 42 | static_assert(std::is_pointer_v<KeyTy>, | 48 | 42 | "getRange must have a KeyTy which is a pointer"); | 49 | 42 | static decltype(C.lookup(K)) const Empty; | 50 | 42 | auto It = C.find(K); | 51 | 42 | if (It != C.end()) { | 52 | 2 | return llvm::make_range(It->second.begin(), It->second.end()); | 53 | 40 | } else { | 54 | 40 | return llvm::make_range(Empty.begin(), Empty.end()); | 55 | 40 | } | 56 | 42 | } |
|
57 | | |
58 | | #endif /* UTILS_H */ |