From ac973ce982b48da19b2566856435cec6c90d8996 Mon Sep 17 00:00:00 2001 From: Martin Mory Date: Wed, 2 Aug 2023 15:03:40 +0200 Subject: [PATCH 1/3] fix global handling in type state analysis --- .../DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp index 5033fff0b..b208de291 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp @@ -359,6 +359,11 @@ IDETypeStateAnalysis::getRetFlowFunction( RelAllocas.insert(Allocas.begin(), Allocas.end()); } Res.insert(RelAllocas.begin(), RelAllocas.end()); + if (llvm::isa(Source)) { + const auto &SourceAndAliases = + Analysis->getWMAliasesAndAllocas(Source); + Res.insert(SourceAndAliases.begin(), SourceAndAliases.end()); + }; return Res; } return {Source}; @@ -414,6 +419,8 @@ IDETypeStateAnalysis::getCallToRetFlowFunction( return killManyFlows(getWMAliasesAndAllocas(Arg.get())); } } + return killFlowIf( + [](d_t Source) { return llvm::isa(Source); }); } } return Identity::getInstance(); From 0226613718729ecde945c970ebd4ece7af13f2d5 Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Mon, 28 Aug 2023 21:13:29 +0200 Subject: [PATCH 2/3] Fix error due to update from dev --- .../DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp index dc46584b0..dc7b66314 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp @@ -207,7 +207,7 @@ auto IDETypeStateAnalysisBase::getCallToRetFlowFunction( return killManyFlows(getWMAliasesAndAllocas(Arg.get())); } } - return killFlowIf( + return killFlowIf( [](d_t Source) { return llvm::isa(Source); }); } } From 1b7e660d57e09f929ec99ea4c9729d809e85bbd9 Mon Sep 17 00:00:00 2001 From: Martin Mory Date: Fri, 17 Nov 2023 10:57:54 +0100 Subject: [PATCH 3/3] fix killing of globals: only kill if no declaration-only func is called --- .../DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp index dc7b66314..8b2dfdcf9 100644 --- a/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp +++ b/lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.cpp @@ -182,6 +182,7 @@ auto IDETypeStateAnalysisBase::getCallToRetFlowFunction( n_t CallSite, n_t /*RetSite*/, llvm::ArrayRef Callees) -> FlowFunctionPtrType { const auto *CS = llvm::cast(CallSite); + bool DeclarationOnlyCalleeFound = false; for (const auto *Callee : Callees) { std::string DemangledFname = llvm::demangle(Callee->getName().str()); // Generate the return value of factory functions from zero value @@ -189,6 +190,8 @@ auto IDETypeStateAnalysisBase::getCallToRetFlowFunction( return this->generateFromZero(CS); } + DeclarationOnlyCalleeFound |= Callee->isDeclaration(); + /// XXX: Revisit this: // Handle all functions that are not modeld with special semantics. @@ -207,10 +210,12 @@ auto IDETypeStateAnalysisBase::getCallToRetFlowFunction( return killManyFlows(getWMAliasesAndAllocas(Arg.get())); } } - return killFlowIf( - [](d_t Source) { return llvm::isa(Source); }); } } + if (!DeclarationOnlyCalleeFound) { + return killFlowIf( + [](d_t Source) { return llvm::isa(Source); }); + } return identityFlow(); }