11
11
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IDEINSTINTERACTIONANALYSIS_H
12
12
13
13
#include " phasar/DataFlow/IfdsIde/DefaultEdgeFunctionSingletonCache.h"
14
+ #include " phasar/DataFlow/IfdsIde/EdgeFunction.h"
14
15
#include " phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h"
15
16
#include " phasar/DataFlow/IfdsIde/FlowFunctions.h"
16
17
#include " phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
@@ -949,59 +950,15 @@ class IDEInstInteractionAnalysisT
949
950
950
951
l_t computeTarget (ByConstRef<l_t > /* Src */ ) const { return Replacement; }
951
952
952
- static EdgeFunction<l_t > compose (EdgeFunctionRef<IIAAKillOrReplaceEF> This,
953
- const EdgeFunction<l_t > SecondFunction) {
954
-
955
- if (auto Default = defaultComposeOrNull (This, SecondFunction)) {
956
- return Default;
957
- }
958
-
959
- auto Cache = This.getCacheOrNull ();
960
- assert (Cache != nullptr && " We expect a cache, because "
961
- " IIAAKillOrReplaceEF is too large for SOO" );
962
-
963
- if (auto *AD = llvm::dyn_cast<IIAAAddLabelsEF>(SecondFunction)) {
964
- auto Union =
965
- IDEInstInteractionAnalysisT::joinImpl (This->Replacement , AD->Data );
966
- return Cache->createEdgeFunction (std::move (Union));
967
- }
968
-
969
- if (auto *KR = llvm::dyn_cast<IIAAKillOrReplaceEF>(SecondFunction)) {
970
- return SecondFunction;
971
- }
972
- llvm::report_fatal_error (
973
- " found unexpected edge function in 'IIAAKillOrReplaceEF'" );
953
+ static EdgeFunction<l_t >
954
+ compose (EdgeFunctionRef<IIAAKillOrReplaceEF> /* This*/ ,
955
+ const EdgeFunction<l_t > /* SecondFunction*/ ) {
956
+ llvm::report_fatal_error (" Implemented in 'extend'" );
974
957
}
975
958
976
- static EdgeFunction<l_t > join (EdgeFunctionRef<IIAAKillOrReplaceEF> This,
977
- const EdgeFunction<l_t > &OtherFunction) {
978
- // / XXX: Here, we underapproximate joins with EdgeIdentity
979
- if (llvm::isa<EdgeIdentity<l_t >>(OtherFunction)) {
980
- return This;
981
- }
982
-
983
- if (auto Default = defaultJoinOrNull (This, OtherFunction)) {
984
- return Default;
985
- }
986
-
987
- auto Cache = This.getCacheOrNull ();
988
- assert (Cache != nullptr && " We expect a cache, because "
989
- " IIAAKillOrReplaceEF is too large for SOO" );
990
-
991
- if (auto *AD = llvm::dyn_cast<IIAAAddLabelsEF>(OtherFunction)) {
992
- auto ADCache = OtherFunction.template getCacheOrNull <IIAAAddLabelsEF>();
993
- assert (ADCache);
994
- auto Union =
995
- IDEInstInteractionAnalysisT::joinImpl (This->Replacement , AD->Data );
996
- return ADCache->createEdgeFunction (std::move (Union));
997
- }
998
- if (auto *KR = llvm::dyn_cast<IIAAKillOrReplaceEF>(OtherFunction)) {
999
- auto Union = IDEInstInteractionAnalysisT::joinImpl (This->Replacement ,
1000
- KR->Replacement );
1001
- return Cache->createEdgeFunction (std::move (Union));
1002
- }
1003
- llvm::report_fatal_error (
1004
- " found unexpected edge function in 'IIAAKillOrReplaceEF'" );
959
+ static EdgeFunction<l_t > join (EdgeFunctionRef<IIAAKillOrReplaceEF> /* This*/ ,
960
+ const EdgeFunction<l_t > & /* OtherFunction*/ ) {
961
+ llvm::report_fatal_error (" Implemented in 'combine'" );
1005
962
}
1006
963
1007
964
bool operator ==(const IIAAKillOrReplaceEF &Other) const noexcept {
@@ -1044,55 +1001,15 @@ class IDEInstInteractionAnalysisT
1044
1001
return IDEInstInteractionAnalysisT::joinImpl (Src, Data);
1045
1002
}
1046
1003
1047
- static EdgeFunction<l_t > compose (EdgeFunctionRef<IIAAAddLabelsEF> This,
1048
- const EdgeFunction<l_t > &SecondFunction) {
1049
- if (auto Default = defaultComposeOrNull (This, SecondFunction)) {
1050
- return Default;
1051
- }
1052
-
1053
- auto Cache = This.getCacheOrNull ();
1054
- assert (Cache != nullptr && " We expect a cache, because "
1055
- " IIAAAddLabelsEF is too large for SOO" );
1056
-
1057
- if (auto *AD = llvm::dyn_cast<IIAAAddLabelsEF>(SecondFunction)) {
1058
- auto Union =
1059
- IDEInstInteractionAnalysisT::joinImpl (This->Data , AD->Data );
1060
- return Cache->createEdgeFunction (std::move (Union));
1061
- }
1062
- if (auto *KR = llvm::dyn_cast<IIAAKillOrReplaceEF>(SecondFunction)) {
1063
- return SecondFunction;
1064
- }
1065
- llvm::report_fatal_error (
1066
- " found unexpected edge function in 'IIAAAddLabelsEF'" );
1004
+ static EdgeFunction<l_t >
1005
+ compose (EdgeFunctionRef<IIAAAddLabelsEF> /* This*/ ,
1006
+ const EdgeFunction<l_t > & /* SecondFunction*/ ) {
1007
+ llvm::report_fatal_error (" Implemented in 'extend'" );
1067
1008
}
1068
1009
1069
- static EdgeFunction<l_t > join (EdgeFunctionRef<IIAAAddLabelsEF> This,
1070
- const EdgeFunction<l_t > &OtherFunction) {
1071
- // / XXX: Here, we underapproximate joins with EdgeIdentity
1072
- if (llvm::isa<EdgeIdentity<l_t >>(OtherFunction)) {
1073
- return This;
1074
- }
1075
-
1076
- if (auto Default = defaultJoinOrNull (This, OtherFunction)) {
1077
- return Default;
1078
- }
1079
-
1080
- auto Cache = This.getCacheOrNull ();
1081
- assert (Cache != nullptr && " We expect a cache, because "
1082
- " IIAAAddLabelsEF is too large for SOO" );
1083
-
1084
- if (auto *AD = llvm::dyn_cast<IIAAAddLabelsEF>(OtherFunction)) {
1085
- auto Union =
1086
- IDEInstInteractionAnalysisT::joinImpl (This->Data , AD->Data );
1087
- return Cache->createEdgeFunction (std::move (Union));
1088
- }
1089
- if (auto *KR = llvm::dyn_cast<IIAAKillOrReplaceEF>(OtherFunction)) {
1090
- auto Union =
1091
- IDEInstInteractionAnalysisT::joinImpl (This->Data , KR->Replacement );
1092
- return Cache->createEdgeFunction (std::move (Union));
1093
- }
1094
- llvm::report_fatal_error (
1095
- " found unexpected edge function in 'IIAAAddLabelsEF'" );
1010
+ static EdgeFunction<l_t > join (EdgeFunctionRef<IIAAAddLabelsEF> /* This*/ ,
1011
+ const EdgeFunction<l_t > & /* OtherFunction*/ ) {
1012
+ llvm::report_fatal_error (" Implemented in 'combine'" );
1096
1013
}
1097
1014
1098
1015
bool operator ==(const IIAAAddLabelsEF &Other) const noexcept {
@@ -1112,6 +1029,64 @@ class IDEInstInteractionAnalysisT
1112
1029
}
1113
1030
};
1114
1031
1032
+ const auto &getData (const EdgeFunction<l_t > &EF) {
1033
+ if (const auto *AddLabels = llvm::dyn_cast<IIAAAddLabelsEF>(EF)) {
1034
+ return AddLabels->Data ;
1035
+ }
1036
+ if (const auto *KillOrReplace = llvm::dyn_cast<IIAAKillOrReplaceEF>(EF)) {
1037
+ return KillOrReplace->Replacement ;
1038
+ }
1039
+ llvm::report_fatal_error (
1040
+ " found unexpected first edge function in 'getData': " +
1041
+ llvm::Twine (to_string (EF)));
1042
+ }
1043
+
1044
+ EdgeFunction<l_t > extend (const EdgeFunction<l_t > &FirstFunction,
1045
+ const EdgeFunction<l_t > &SecondFunction) override {
1046
+ if (auto Default = defaultComposeOrNull (FirstFunction, SecondFunction)) {
1047
+ return Default;
1048
+ }
1049
+
1050
+ const auto &ThisData = getData (FirstFunction);
1051
+
1052
+ if (auto *AD = llvm::dyn_cast<IIAAAddLabelsEF>(SecondFunction)) {
1053
+ auto Union = IDEInstInteractionAnalysisT::joinImpl (ThisData, AD->Data );
1054
+ return llvm::isa<IIAAAddLabelsEF>(FirstFunction)
1055
+ ? IIAAAddLabelsEFCache.createEdgeFunction (std::move (Union))
1056
+ : IIAAKillOrReplaceEFCache.createEdgeFunction (
1057
+ std::move (Union));
1058
+ }
1059
+
1060
+ llvm::report_fatal_error (
1061
+ " found unexpected second edge function in 'extend'" );
1062
+ }
1063
+
1064
+ EdgeFunction<l_t > combine (const EdgeFunction<l_t > &FirstFunction,
1065
+ const EdgeFunction<l_t > &OtherFunction) override {
1066
+ // / XXX: Here, we underapproximate joins with EdgeIdentity
1067
+ if (llvm::isa<EdgeIdentity<l_t >>(FirstFunction)) {
1068
+ return OtherFunction;
1069
+ }
1070
+ if (llvm::isa<EdgeIdentity<l_t >>(OtherFunction) &&
1071
+ !llvm::isa<AllTop<l_t >>(FirstFunction)) {
1072
+ return FirstFunction;
1073
+ }
1074
+
1075
+ if (auto Default = defaultJoinOrNull (FirstFunction, OtherFunction)) {
1076
+ return Default;
1077
+ }
1078
+
1079
+ const auto &ThisData = getData (FirstFunction);
1080
+ const auto &OtherData = getData (OtherFunction);
1081
+ auto Union = IDEInstInteractionAnalysisT::joinImpl (ThisData, OtherData);
1082
+
1083
+ if (llvm::isa<IIAAKillOrReplaceEF>(FirstFunction) &&
1084
+ llvm::isa<IIAAKillOrReplaceEF>(OtherFunction)) {
1085
+ return IIAAKillOrReplaceEFCache.createEdgeFunction (std::move (Union));
1086
+ }
1087
+ return IIAAAddLabelsEFCache.createEdgeFunction (std::move (Union));
1088
+ }
1089
+
1115
1090
// Provide functionalities for printing things and emitting text reports.
1116
1091
1117
1092
static void stripBottomResults (std::unordered_map<d_t , l_t > &Res) {
@@ -1173,7 +1148,7 @@ class IDEInstInteractionAnalysisT
1173
1148
}
1174
1149
if (const auto *H = llvm::dyn_cast<llvm::CallBase>(I)) {
1175
1150
if (!H->isIndirectCall () && H->getCalledFunction () &&
1176
- this -> ICF -> isHeapAllocatingFunction (H->getCalledFunction ())) {
1151
+ psr:: isHeapAllocatingFunction (H->getCalledFunction ())) {
1177
1152
Variables.insert (H);
1178
1153
}
1179
1154
}
0 commit comments