diff --git a/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h b/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h index 68ee40cb8..9ae1b0a2d 100644 --- a/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h +++ b/include/phasar/DataFlow/IfdsIde/Solver/IterativeIDESolver.h @@ -474,7 +474,7 @@ class IterativeIDESolver return true; } - auto NewEF = EF.joinWith(std::move(LocalEF)); + auto NewEF = Problem.combine(EF, std::move(LocalEF)); assert(NewEF != nullptr); if (NewEF != EF) { @@ -540,7 +540,7 @@ class IterativeIDESolver return; } - auto NewEF = EF.joinWith(std::move(LocalEF)); + auto NewEF = Problem.combine(EF, std::move(LocalEF)); assert(NewEF != nullptr); if (NewEF != EF) { @@ -622,10 +622,11 @@ class IterativeIDESolver auto FactId = FactCompressor.getOrInsert(Fact); auto EF = [&] { if constexpr (ComputeValues) { - return SourceEF.composeWith(FECache.getNormalEdgeFunction( + auto NEF = FECache.getNormalEdgeFunction( Problem, AtInstruction, CSFact, Succ, Fact, combineIds(AtInstructionId, SuccId), - combineIds(PropagatedFactId, FactId))); + combineIds(PropagatedFactId, FactId)); + return Problem.extend(SourceEF, std::move(NEF)); } else { return EdgeFunctionPtrType{}; } @@ -694,10 +695,11 @@ class IterativeIDESolver auto EF = [&] { if constexpr (ComputeValues) { - return SourceEF.composeWith(FECache.getCallToRetEdgeFunction( + auto CEF = FECache.getCallToRetEdgeFunction( Problem, AtInstruction, CSFact, RetSite, Fact, Callees /*Vec*/, combineIds(AtInstructionId, RetSiteId), - combineIds(PropagatedFactId, FactId))); + combineIds(PropagatedFactId, FactId)); + return Problem.extend(SourceEF, std::move(CEF)); } else { return EdgeFunctionPtrType{}; } @@ -835,10 +837,11 @@ class IterativeIDESolver auto CallEF = [&] { if constexpr (ComputeValues) { - return SourceEF.composeWith(FECache.getCallEdgeFunction( + auto CEF = FECache.getCallEdgeFunction( Problem, AtInstruction, CSFact, Callee, Fact, combineIds(AtInstructionId, CalleeId), - combineIds(CSFactId, FactId))); + combineIds(CSFactId, FactId)); + return Problem.extend(SourceEF, std::move(CEF)); } else { return EdgeFunctionPtrType{}; } @@ -900,7 +903,7 @@ class IterativeIDESolver Problem, AtInstruction, CSFact, RetSite, Fact, combineIds(AtInstructionId, RetSiteId), combineIds(CSFactId, FactId)); - return EF ? SourceEF.composeWith(std::move(EF)) : SourceEF; + return EF ? Problem.extend(SourceEF, std::move(EF)) : SourceEF; } else { return EdgeFunctionPtrType{}; } @@ -939,8 +942,8 @@ class IterativeIDESolver Problem, CallSite, Callee, ExitInst, SummaryFact, RetSite, RetFact, ExitId, combineIds(CSId, RSId), combineIds(SummaryFactId, RetFactId)); - return CallEF.composeWith(Summary.second) - .composeWith(std::move(RetEF)); + return Problem.extend(Problem.extend(CallEF, Summary.second), + std::move(RetEF)); } else { return EdgeFunctionPtrType{}; } @@ -954,16 +957,15 @@ class IterativeIDESolver } void processInterJobs() { - - llvm::errs() << "processInterJobs: " << CallWL.size() - << " relevant calls\n"; + PHASAR_LOG_LEVEL(INFO, "processInterJobs: " << CallWL.size() + << " relevant calls"); /// Here, no other job is running concurrently, so we save and reset the /// CallWL, such that we can start concurrent jobs in the loop below std::vector RelevantCalls(CallWL.begin(), CallWL.end()); scope_exit FinishedInterCalls = [] { - llvm::errs() << "> end inter calls\n"; + PHASAR_LOG_LEVEL(INFO, "> end inter calls"); }; if constexpr (EnableStatistics) { @@ -1250,14 +1252,14 @@ class IterativeIDESolver } void runGC() { - llvm::errs() << "runGC() with " << CandidateFunctionsForGC.count() - << " candidates\n"; + PHASAR_LOG_LEVEL(INFO, "runGC() with " << CandidateFunctionsForGC.count() + << " candidates"); size_t NumCollectedFuns = 0; scope_exit FinishGC = [&NumCollectedFuns] { - llvm::errs() << "> Finished GC run (collected " << NumCollectedFuns - << " functions)\n"; + PHASAR_LOG_LEVEL(INFO, "> Finished GC run (collected " << NumCollectedFuns + << " functions)"); }; auto FinalCandidates = getCollectableFunctions(); diff --git a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h index 9cca9dc15..b021f7b5a 100644 --- a/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h +++ b/include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h @@ -374,4 +374,13 @@ class IDEFeatureTaintAnalysis } // namespace psr +namespace std { +template <> struct hash { + size_t + operator()(const psr::IDEFeatureTaintEdgeFact &EdgeFact) const noexcept { + return hash_value(EdgeFact); + } +}; +} // namespace std + #endif // PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_PROBLEMS_IDEFEATURETAINTANALYSIS_H diff --git a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysisTest.cpp b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysisTest.cpp index 243cb2d6a..351a4efd3 100644 --- a/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysisTest.cpp +++ b/unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysisTest.cpp @@ -4,7 +4,6 @@ #include "phasar/DataFlow/IfdsIde/Solver/IDESolver.h" #include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h" #include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h" -#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMSolverResults.h" #include "phasar/PhasarLLVM/HelperAnalyses.h" #include "phasar/PhasarLLVM/Pointer/LLVMAliasSet.h" #include "phasar/PhasarLLVM/SimpleAnalysisConstructor.h" @@ -102,8 +101,11 @@ class IDEFeatureTaintAnalysisTest : public ::testing::Test { // psr::Logger::initializeStderrLogger(SeverityLevel::DEBUG); // } - IDESolver IIASolver(IIAProblem, &HA->getICFG()); + IDESolver IIASolver(&IIAProblem, &HA->getICFG()); + // IterativeIDESolver IIASolver(&IIAProblem, &HA->getICFG()); IIASolver.solve(); + + auto Results = IIASolver.getSolverResults(); // if (PrintDump) { // // IRDB->emitPreprocessedIR(llvm::outs()); // IIASolver.dumpResults(); @@ -115,7 +117,7 @@ class IDEFeatureTaintAnalysisTest : public ::testing::Test { for (const auto &[FunName, SrcLine, VarName, LatticeVal] : GroundTruth) { const auto *Fun = IRDB->getFunctionDefinition(FunName); const auto *IRLine = getNthInstruction(Fun, SrcLine); - auto ResultMap = IIASolver.resultsAt(IRLine); + auto ResultMap = Results.resultsAt(IRLine); assert(IRLine && "Could not retrieve IR line!"); bool FactFound = false; for (auto &[Fact, Value] : ResultMap) { @@ -142,17 +144,17 @@ class IDEFeatureTaintAnalysisTest : public ::testing::Test { IIASolver.dumpResults(llvm::errs()); llvm::errs() << "\n======================================================\n"; - printDump(HA->getProjectIRDB(), IIASolver.getSolverResults()); + printDump(HA->getProjectIRDB(), Results); } } void TearDown() override {} // See vara::PhasarTaintAnalysis::taintsForInst - [[nodiscard]] inline std::set - taintsForInst(const llvm::Instruction *Inst, - SolverResults SR) { + [[nodiscard]] inline std::set taintsForInst( + const llvm::Instruction *Inst, + GenericSolverResults SR) { if (const auto *Ret = llvm::dyn_cast(Inst)) { if (Ret->getNumOperands() == 0) { @@ -187,10 +189,11 @@ class IDEFeatureTaintAnalysisTest : public ::testing::Test { return AggregatedTaints; } - void printDump(const LLVMProjectIRDB &IRDB, - SolverResults - SR) { + void + printDump(const LLVMProjectIRDB &IRDB, + GenericSolverResults + SR) { const llvm::Function *CurrFun = nullptr; for (const auto *Inst : IRDB.getAllInstructions()) { if (CurrFun != Inst->getFunction()) {