77 * Philipp Schubert and others
88 *****************************************************************************/
99
10- #ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEINSTINTERACTIONALYSIS_H_
11- #define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEINSTINTERACTIONALYSIS_H_
10+ #ifndef PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEINSTINTERACTIONALYSIS_H
11+ #define PHASAR_PHASARLLVM_IFDSIDE_PROBLEMS_IDEINSTINTERACTIONALYSIS_H
1212
1313#include < functional>
1414#include < initializer_list>
@@ -293,9 +293,6 @@ class IDEInstInteractionAnalysisT
293293 }
294294 container_type Facts;
295295 Facts.insert (Src);
296- if (IDEInstInteractionAnalysisT::isZeroValueImpl (Src)) {
297- return Facts;
298- }
299296 // y/Y now obtains its new value(s) from x/X
300297 // If a value is stored that holds we must generate all potential
301298 // memory locations the store might write to.
@@ -304,6 +301,12 @@ class IDEInstInteractionAnalysisT
304301 Facts.insert (Store->getPointerOperand ());
305302 Facts.insert (PointerPTS->begin (), PointerPTS->end ());
306303 }
304+ // ... or from zero, if a constant literal is stored to y
305+ if (llvm::isa<llvm::ConstantData>(Store->getValueOperand ()) &&
306+ IDEInstInteractionAnalysisT::isZeroValueImpl (Src)) {
307+ Facts.insert (Store->getPointerOperand ());
308+ Facts.insert (PointerPTS->begin (), PointerPTS->end ());
309+ }
307310 return Facts;
308311 }
309312 };
@@ -384,11 +387,22 @@ class IDEInstInteractionAnalysisT
384387 ~IIAAFlowFunction () override = default ;
385388
386389 container_type computeTargets (d_t Src) override {
390+ // Override old value, i.e., kill value that is written to and
391+ // generate from value that is stored.
392+ if (Store->getPointerOperand () == Src) {
393+ return {};
394+ }
387395 container_type Facts;
388396 Facts.insert (Src);
397+ // y now obtains its new value from x
389398 if (Store->getValueOperand () == Src) {
390399 Facts.insert (Store->getPointerOperand ());
391400 }
401+ // ... or from zero, if a constant literal is stored to y
402+ if (llvm::isa<llvm::ConstantData>(Store->getValueOperand ()) &&
403+ IDEInstInteractionAnalysisT::isZeroValueImpl (Src)) {
404+ Facts.insert (Store->getPointerOperand ());
405+ }
392406 LOG_IF_ENABLE ([&]() {
393407 for (const auto s : Facts) {
394408 BOOST_LOG_SEV (lg::get (), DFADEBUG)
@@ -552,7 +566,7 @@ class IDEInstInteractionAnalysisT
552566 }
553567 }
554568 }
555- // Just use the auto mapping for values, pointer parameters and global
569+ // Just use the auto mapping for values; pointer parameters and global
556570 // variables are killed and handled by getCallFlowfunction() and
557571 // getRetFlowFunction().
558572 // However, if only declarations are available as callee targets we would
@@ -573,9 +587,18 @@ class IDEInstInteractionAnalysisT
573587 globals here (as they are propagated via call- and
574588 ret-functions. */
575589 ,
576- [](const llvm::CallBase * /* CS */ , const llvm::Value * /* V */ ) {
577- return false ; // treat as not involved in the call since this also
578- // caputes usages of the parameter
590+ [](const llvm::CallBase * /* CS */ , const llvm::Value *V) {
591+ // Treat global variables as involved, since we wish to have them
592+ // handled by getCallFlowFunction() and getRetFlowFunction() to model
593+ // potential effects of the callee.
594+ // Constants covers global variables as well as ConstantExpr and
595+ // ConstantAggregate
596+ if (llvm::isa<llvm::Constant>(V)) {
597+ return true ;
598+ }
599+ // Treat all other values as not involved in the call since this also
600+ // captures usages of the parameter.
601+ return false ;
579602 });
580603 }
581604
@@ -631,7 +654,7 @@ class IDEInstInteractionAnalysisT
631654 d_t SuccNode) override {
632655 LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), DFADEBUG)
633656 << " Process edge: " << llvmIRToShortString (CurrNode) << " --"
634- << llvmIRToShortString (Curr) << " --> "
657+ << llvmIRToString (Curr) << " --> "
635658 << llvmIRToShortString (SuccNode));
636659 //
637660 // Zero --> Zero edges
@@ -746,7 +769,7 @@ class IDEInstInteractionAnalysisT
746769 BOOST_LOG_SEV (lg::get (), DFADEBUG)
747770 << " at '" << llvmIRToString (Curr) << " '\n " ;
748771 }());
749- return IIAAKillOrReplaceEF ::createEdgeFunction (UserEdgeFacts);
772+ return IIAAAddLabelsEF ::createEdgeFunction (UserEdgeFacts);
750773 }
751774 // Kill all labels that are propagated along the edge of the value that
752775 // is overridden.
@@ -1080,13 +1103,13 @@ class IDEInstInteractionAnalysisT
10801103 l_t Replacement;
10811104
10821105 explicit IIAAKillOrReplaceEF () : Replacement(BitVectorSet<e_t >()) {
1083- LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), DFADEBUG)
1084- << " IIAAKillOrReplaceEF" );
1106+ // LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), DFADEBUG)
1107+ // << "IIAAKillOrReplaceEF");
10851108 }
10861109
10871110 explicit IIAAKillOrReplaceEF (l_t Replacement) : Replacement(Replacement) {
1088- LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), DFADEBUG)
1089- << " IIAAKillOrReplaceEF" );
1111+ // LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), DFADEBUG)
1112+ // << "IIAAKillOrReplaceEF");
10901113 }
10911114
10921115 ~IIAAKillOrReplaceEF () override = default ;
@@ -1095,9 +1118,9 @@ class IDEInstInteractionAnalysisT
10951118
10961119 std::shared_ptr<EdgeFunction<l_t >>
10971120 composeWith (std::shared_ptr<EdgeFunction<l_t >> SecondFunction) override {
1098- LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), DFADEBUG)
1099- << " IIAAKillOrReplaceEF::composeWith(): " << this ->str ()
1100- << " * " << SecondFunction->str ());
1121+ // LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), DFADEBUG)
1122+ // << "IIAAKillOrReplaceEF::composeWith(): " << this->str()
1123+ // << " * " << SecondFunction->str());
11011124 if (auto *AT = dynamic_cast <AllTop<l_t > *>(SecondFunction.get ())) {
11021125 return this ->shared_from_this ();
11031126 }
@@ -1193,7 +1216,7 @@ class IDEInstInteractionAnalysisT
11931216 const l_t Data;
11941217
11951218 explicit IIAAAddLabelsEF (l_t Data) : Data(Data) {
1196- LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), DFADEBUG) << " IIAAAddLabelsEF" );
1219+ // LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), DFADEBUG) << "IIAAAddLabelsEF");
11971220 }
11981221
11991222 ~IIAAAddLabelsEF () override = default ;
@@ -1204,9 +1227,10 @@ class IDEInstInteractionAnalysisT
12041227
12051228 std::shared_ptr<EdgeFunction<l_t >>
12061229 composeWith (std::shared_ptr<EdgeFunction<l_t >> SecondFunction) override {
1207- LOG_IF_ENABLE (BOOST_LOG_SEV (lg::get (), DFADEBUG)
1208- << " IIAAAddLabelEF::composeWith(): " << this ->str () << " * "
1209- << SecondFunction->str ());
1230+ // LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), DFADEBUG)
1231+ // << "IIAAAddLabelEF::composeWith(): " << this->str() << "
1232+ // * "
1233+ // << SecondFunction->str());
12101234 if (auto *AT = dynamic_cast <AllTop<l_t > *>(SecondFunction.get ())) {
12111235 return this ->shared_from_this ();
12121236 }
0 commit comments