@@ -842,21 +842,22 @@ class IDEInstInteractionAnalysisT
842842 if (LLVMZeroValue::getInstance ()->isLLVMZeroValue (Source.getBase ())) {
843843 return {Source};
844844 }
845- // Pass global variables as is, if no function definition is available
846- // as they would be otherwise killed. Need llvm::Constant here to cover
847- // also ConstantExpr and ConstantAggregate.
848- if (OnlyDecls && llvm::isa<llvm::Constant>(Source.getBase ())) {
845+ // Pass variables as identity, if no function definition is available
846+ // as they would be otherwise killed.
847+ if (OnlyDecls) {
849848 return {Source};
850849 }
851- // Propagate if predicate does not hold, i.e., fact is not involved in
852- // the call
853- for ( const auto &Arg : CallSite-> args ()) {
854- if (Arg == Source && !Source. getBase ()-> getType ()-> isPointerTy ()) {
855- return {Source};
856- }
850+ // Do not global variables (if definitions of the callee function(s) are
851+ // available), since the effect of the callee on these values will be
852+ // modelled using combined getCallFlowFunction and
853+ // getReturnFlowFunction.
854+ if (llvm::isa<llvm::Constant>(Source. getBase ())) {
855+ return {};
857856 }
858- // Otherwise kill fact
859- return {};
857+ // Pass everything else as identity. In particular, also do not kill
858+ // pointer or reference parameters since this then also captures usages
859+ // oft he parameters, which we wish to compute using this analysis.
860+ return {Source};
860861 }
861862 };
862863 return std::make_shared<MapFactsAlongsideCallSite>(
@@ -1053,7 +1054,7 @@ class IDEInstInteractionAnalysisT
10531054 // obtain the label
10541055 if (OrigAlloca) {
10551056 if (auto *UEF = std::get_if<BitVectorSet<e_t >>(&UserEdgeFacts)) {
1056- UEF->insert (edgeFactGenToBitVectorSet (OrigAlloca));
1057+ UEF->insert (edgeFactGenForInstToBitVectorSet (OrigAlloca));
10571058 }
10581059 }
10591060 return IIAAKillOrReplaceEF::createEdgeFunction (UserEdgeFacts);
@@ -1166,6 +1167,15 @@ class IDEInstInteractionAnalysisT
11661167 // o_i
11671168 //
11681169 if (isZeroValue (CurrNode) && Op == SuccNode) {
1170+ // Constant variables should retain their own label
1171+ if (llvm::isa<llvm::Constant>(SuccNode.getBase ())) {
1172+ if (llvm::isa_and_nonnull<llvm::GlobalVariable>(SuccNode.getBase ())) {
1173+ if (auto *UEF = std::get_if<BitVectorSet<e_t >>(&UserEdgeFacts)) {
1174+ UEF->insert (edgeFactGenForGlobalVarToBitVectorSet (
1175+ llvm::dyn_cast<llvm::GlobalVariable>(SuccNode.getBase ())));
1176+ }
1177+ }
1178+ }
11691179 return IIAAAddLabelsEF::createEdgeFunction (UserEdgeFacts);
11701180 }
11711181 //
@@ -1743,14 +1753,24 @@ class IDEInstInteractionAnalysisT
17431753 static inline const l_t TopElement = Top{};
17441754 const bool OnlyConsiderLocalAliases = true ;
17451755
1746- inline BitVectorSet<e_t > edgeFactGenToBitVectorSet (n_t CurrInst) {
1756+ inline BitVectorSet<e_t > edgeFactGenForInstToBitVectorSet (n_t CurrInst) {
17471757 if (EdgeFactGen) {
17481758 auto Results = EdgeFactGen (CurrInst);
17491759 BitVectorSet<e_t > BVS (Results.begin (), Results.end ());
17501760 return BVS;
17511761 }
17521762 return {};
17531763 }
1764+
1765+ inline BitVectorSet<e_t >
1766+ edgeFactGenForGlobalVarToBitVectorSet (const llvm::GlobalVariable *GlobalVar) {
1767+ if (EdgeFactGen) {
1768+ auto Results = EdgeFactGen (GlobalVar);
1769+ BitVectorSet<e_t > BVS (Results.begin (), Results.end ());
1770+ return BVS;
1771+ }
1772+ return {};
1773+ }
17541774}; // namespace psr
17551775
17561776using IDEInstInteractionAnalysis = IDEInstInteractionAnalysisT<>;
0 commit comments