Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
73ae1b6
Add explicit ExplodedSuperGraph and a version of the IDESolver that f…
fabianbs96 Aug 24, 2022
b868728
Add more TODOs
fabianbs96 Aug 24, 2022
709405e
Add GraphTraits
fabianbs96 Aug 24, 2022
3d9df06
Add pathsDagTo (not tested yet)
fabianbs96 Aug 25, 2022
e35d04f
Add Z3 submodule
fabianbs96 Aug 25, 2022
ddef578
Set Z3 version
fabianbs96 Aug 25, 2022
e90df7b
Add Z3-related stuff (WIP)
fabianbs96 Aug 26, 2022
2c5c0d4
Added now basic functionality for path sensitivity (compiles, but not…
fabianbs96 Aug 26, 2022
91fa523
Implement LLVMPathConstraints
fabianbs96 Aug 26, 2022
cada9f1
Add unittest for PathTracking (C/C++ test files are still missing) an…
fabianbs96 Aug 26, 2022
a332b6d
Make a lot of the unittests work (still not completed)
fabianbs96 Aug 26, 2022
21d4cba
Fix Config propagation
fabianbs96 Aug 26, 2022
b898204
Finally, fix all unittests
fabianbs96 Aug 26, 2022
2a286bf
minor
fabianbs96 Sep 4, 2022
a9642e2
redirect z3 submodule
fabianbs96 Sep 6, 2022
848ba9b
Checkout the right z3 branch
fabianbs96 Sep 6, 2022
71891e6
bump z3
fabianbs96 Sep 12, 2022
c70b7ef
add bulk dag-generation (not tested yet)
fabianbs96 Sep 13, 2022
04e27d1
Merge branch 'f-PathTracingNew' of git.cs.uni-paderborn.de:pdschbrt/s…
fabianbs96 Sep 13, 2022
25bdbb7
Some more fixes
fabianbs96 Sep 19, 2022
3850866
Add filters to PSM
fabianbs96 Sep 19, 2022
d4de032
Better integrate filter into PSM
fabianbs96 Sep 19, 2022
d90415d
minor
fabianbs96 Sep 19, 2022
cc649e4
Improve on reverseDAG
fabianbs96 Sep 27, 2022
2b5de39
minor improvements in reverseDAG
fabianbs96 Sep 28, 2022
86b135b
Bump z3
fabianbs96 Oct 27, 2022
eb16d36
Fix depdendency issue with utils->config
fabianbs96 Oct 27, 2022
1bc75d1
Merge branch 'development' into f-PathTracingNew
fabianbs96 Oct 27, 2022
aaca44f
Fix bugs indiced by reverse merging from development + bump z3
fabianbs96 Oct 27, 2022
e6556c1
Make Z3 optional
fabianbs96 Oct 27, 2022
77370df
Workaround weird cmake behavior
fabianbs96 Oct 27, 2022
5508615
Fix seeds in exploded supergraph
fabianbs96 Oct 28, 2022
82792d9
Add forward minimize graph
fabianbs96 Nov 23, 2022
a9fb9da
Add one Test for forward minimize DAG
fabianbs96 Nov 23, 2022
dc2a8d4
Fix in createEquivalentGraphFrom
fabianbs96 Nov 24, 2022
2de5592
Fix filterOutUnreachableNodes
fabianbs96 Nov 24, 2022
6a5a777
Fix: DFAMinimizer edge comparison
fabianbs Jan 6, 2023
a68886a
Fix compilation on ubuntu22
fabianbs96 Jan 10, 2023
7d5f9ed
Improve createEquivalentGraphFrom
fabianbs96 Jan 10, 2023
a5a70ad
Merge remote-tracking branch 'mainline-phasar/development' into f-Pat…
fabianbs96 Mar 3, 2023
96caeac
Resolve errors due to merging
fabianbs96 Mar 3, 2023
327aa97
Fix z3 dependency
fabianbs96 Mar 16, 2023
fa1f243
Fix UAF when copying an ExplicitESG
fabianbs96 Mar 17, 2023
0449984
Get rid of NodeRef::DSI
fabianbs96 Mar 17, 2023
628552b
Merge branch 'development' into f-PathTracingNew
boehmseb May 17, 2023
58454de
Fix compile error due to merge
fabianbs96 May 22, 2023
3f4031e
minor
fabianbs96 May 22, 2023
657c51f
More const in Table
fabianbs96 May 22, 2023
27acc99
Give the PathTracing Filters more power
fabianbs96 May 30, 2023
e39dec8
Fix null error
fabianbs96 May 31, 2023
0d51cc1
Merge branch 'development' into f-PathTracingNew
fabianbs96 Jul 3, 2023
a916416
Fix Path Tracing with chaotic edge saving due to new Worklist structu…
fabianbs96 Jul 3, 2023
0494607
Some cleanup
fabianbs96 Jul 4, 2023
35c3eff
pre-commit
fabianbs96 Jul 4, 2023
bd0a758
Merge branch 'development' into f-PathTracingNew
fabianbs96 Jul 6, 2023
ef4b179
Merge branch 'development' into f-PathTracingNew
fabianbs96 Jul 31, 2023
74f8432
Apply some review comments
fabianbs96 Aug 1, 2023
2d90c08
Merge branch 'development' into f-PathTracingNew
fabianbs96 Aug 2, 2023
ea76bc1
Write ESG to temp file instead of hard-coded file
fabianbs96 Aug 2, 2023
58a8d35
minor
fabianbs96 Aug 6, 2023
2aa2099
Merge branch 'development' into f-PathTracingNew
fabianbs96 Aug 15, 2023
e0735d8
pre-commitIDESolver.h
fabianbs96 Aug 15, 2023
9136cad
pre-commit Utilities.h
fabianbs96 Aug 15, 2023
a2ab5fa
trailing whitespace IDESolver.h
fabianbs96 Aug 15, 2023
c130b40
Merge branch 'development' into f-PathTracingNew
MMory Aug 17, 2023
d491f6f
Fix errors due to merge
fabianbs96 Aug 18, 2023
df3511d
Merge branch 'development' into f-PathTracingNew
fabianbs96 Aug 24, 2023
5cdca10
Integrate free-functions NToString and DToString into ExplicitESG
fabianbs96 Aug 25, 2023
7d3d9a8
Adapt invariants due to chaotic solving (worklist vs recursion)
fabianbs96 Aug 25, 2023
6d08380
Merge branch 'development' into f-PathTracingNew
fabianbs96 Aug 28, 2023
f3666e9
Merge branch 'development' into f-PathTracingNew
fabianbs96 Aug 28, 2023
8072869
Merge branch 'development' into f-PathTracingNew
fabianbs96 Sep 21, 2023
56ec0a6
Add LLVMSSA version of pathsDagTo as temporary solution until f-IDESo…
fabianbs96 Oct 25, 2023
917bd83
Merge branch 'development' into f-PathTracingNew
fabianbs96 Oct 25, 2023
b947c1e
minor
fabianbs96 Oct 25, 2023
1a15261
Use system z3
fabianbs96 Nov 10, 2023
1d51399
Merge branch 'development' into f-PathTracingNew
fabianbs96 Nov 13, 2023
57b0f81
Find z3 from psr installation
fabianbs96 Nov 15, 2023
f7402d3
Assert size overflow
fabianbs96 Nov 19, 2023
d9a0fee
Enable Z3 in CI
fabianbs96 Nov 19, 2023
a478f9b
fix naming issue
fabianbs96 Nov 19, 2023
ad9d08e
Merge branch 'development' into f-PathTracingNew
fabianbs96 Nov 19, 2023
566adcc
Merge branch 'development' into f-PathTracingNew
fabianbs96 Nov 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Checks: '-*,
modernize-*,
-modernize-use-trailing-return-type,
performance-*,
clang-analyzer-*,
clang-analyzer-*
'

FormatStyle: LLVM
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ matrix.build }} \
-DBUILD_SWIFT_TESTS=ON \
-DPHASAR_DEBUG_LIBDEPS=ON \
-DPHASAR_USE_Z3=ON \
${{ matrix.flags }} \
-G Ninja
cmake --build .
Expand Down
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.9)
cmake_minimum_required (VERSION 3.14)

# Avoid IPO/LTO Warnings:
cmake_policy(SET CMP0069 NEW)
Expand Down Expand Up @@ -150,6 +150,8 @@ option(PHASAR_BUILD_UNITTESTS "Build all tests (default is ON)" ON)

option(PHASAR_BUILD_OPENSSL_TS_UNITTESTS "Build OPENSSL typestate tests (require OpenSSL, default is OFF)" OFF)

option(PHASAR_USE_Z3 "Build the phasar_llvm_pathsensitivity library with Z3 support for constraint solving (default is OFF)" OFF)

option(PHASAR_BUILD_IR "Build IR test code (default is ON)" ON)

option(PHASAR_ENABLE_CLANG_TIDY_DURING_BUILD "Run clang-tidy during build (default is OFF)" OFF)
Expand Down Expand Up @@ -259,11 +261,13 @@ add_subdirectory(external/json)
# The following workaround may collapse or become unnecessary once the issue is
# changed or fixed in nlohmann_json_schema_validator.

#Override option of nlohmann_json_schema_validator to not build its tests
# Override option of nlohmann_json_schema_validator to not build its tests
set(BUILD_TESTS OFF CACHE BOOL "Build json-schema-validator-tests")

if (PHASAR_IN_TREE)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json_schema_validator)

set (PHASAR_USE_Z3 OFF)
endif()

# Json Schema Validator
Expand Down Expand Up @@ -337,6 +341,21 @@ if(NOT LLVM_ENABLE_RTTI AND NOT PHASAR_IN_TREE)
message(FATAL_ERROR "PhASAR requires a LLVM version that is built with RTTI")
endif()

# Z3 Solver
if(PHASAR_USE_Z3)
# This z3-version is the same version LLVM requires; however, we cannot just use Z3 via the LLVM interface
# as it lacks some functionality (such as z3::expr::simplify()) that we require
find_package(Z3 4.7.1 REQUIRED)

if(NOT TARGET z3)
add_library(z3 IMPORTED SHARED)
set_property(TARGET z3 PROPERTY
IMPORTED_LOCATION ${Z3_LIBRARIES})
set_property(TARGET z3 PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR})
endif()
endif(PHASAR_USE_Z3)

# Clang
option(BUILD_PHASAR_CLANG "Build the phasar_clang library (default is ON)" ON)

Expand Down
5 changes: 5 additions & 0 deletions Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ find_package(LLVM 14 REQUIRED CONFIG)

set(PHASAR_USE_LLVM_FAT_LIB @USE_LLVM_FAT_LIB@)
set(PHASAR_BUILD_DYNLIB @PHASAR_BUILD_DYNLIB@)
set(PHASAR_USE_Z3 @PHASAR_USE_Z3@)

if (PHASAR_USE_Z3)
find_dependency(Z3)
endif()

set(PHASAR_COMPONENTS
utils
Expand Down
3 changes: 3 additions & 0 deletions include/phasar/DataFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "phasar/DataFlow/IfdsIde/Solver/IDESolver.h"
#include "phasar/DataFlow/IfdsIde/Solver/IFDSSolver.h"
#include "phasar/DataFlow/IfdsIde/Solver/JumpFunctions.h"
#include "phasar/DataFlow/IfdsIde/Solver/PathAwareIDESolver.h"
#include "phasar/DataFlow/IfdsIde/Solver/PathEdge.h"
#include "phasar/DataFlow/IfdsIde/SolverResults.h"
#include "phasar/DataFlow/IfdsIde/SpecialSummaries.h"
Expand All @@ -32,5 +33,7 @@
#include "phasar/DataFlow/Mono/IntraMonoProblem.h"
#include "phasar/DataFlow/Mono/Solver/InterMonoSolver.h"
#include "phasar/DataFlow/Mono/Solver/IntraMonoSolver.h"
#include "phasar/DataFlow/PathSensitivity/PathSensitivityConfig.h"
#include "phasar/DataFlow/PathSensitivity/PathSensitivityManager.h"

#endif // PHASAR_DATAFLOW_H
22 changes: 22 additions & 0 deletions include/phasar/DataFlow/IfdsIde/Solver/ESGEdgeKind.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/******************************************************************************
* Copyright (c) 2022 Philipp Schubert.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of LICENSE.txt.
*
* Contributors:
* Fabian Schiebel and others
*****************************************************************************/

#ifndef PHASAR_DATAFLOW_IFDSIDE_SOLVER_ESGEDGEKIND_H
#define PHASAR_DATAFLOW_IFDSIDE_SOLVER_ESGEDGEKIND_H

namespace psr {
enum class ESGEdgeKind { Normal, Call, CallToRet, SkipUnknownFn, Ret, Summary };

constexpr bool isInterProc(ESGEdgeKind Kind) noexcept {
return Kind == ESGEdgeKind::Call || Kind == ESGEdgeKind::Ret;
}

} // namespace psr

#endif // PHASAR_DATAFLOW_IFDSIDE_SOLVER_ESGEDGEKIND_H
27 changes: 18 additions & 9 deletions include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
#include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h"
#include "phasar/DataFlow/IfdsIde/InitialSeeds.h"
#include "phasar/DataFlow/IfdsIde/Solver/ESGEdgeKind.h"
#include "phasar/DataFlow/IfdsIde/Solver/FlowEdgeFunctionCache.h"
#include "phasar/DataFlow/IfdsIde/Solver/IDESolverAPIMixin.h"
#include "phasar/DataFlow/IfdsIde/Solver/JumpFunctions.h"
Expand Down Expand Up @@ -297,20 +298,25 @@ class IDESolver
}
});

bool HasNoCalleeInformation = true;

// for each possible callee
for (f_t SCalledProcN : Callees) { // still line 14
// check if a special summary for the called procedure exists
FlowFunctionPtrType SpecialSum =
CachedFlowEdgeFunctions.getSummaryFlowFunction(n, SCalledProcN);

// if a special summary is available, treat this as a normal flow
// and use the summary flow and edge functions

if (SpecialSum) {
HasNoCalleeInformation = false;
PHASAR_LOG_LEVEL(DEBUG, "Found and process special summary");
for (n_t ReturnSiteN : ReturnSiteNs) {
container_type Res = computeSummaryFlowFunction(SpecialSum, d1, d2);
INC_COUNTER("SpecialSummary-FF Application", 1, Full);
ADD_TO_HISTOGRAM("Data-flow facts", Res.size(), 1, Full);
saveEdges(n, ReturnSiteN, d2, Res, false);
saveEdges(n, ReturnSiteN, d2, Res, ESGEdgeKind::Summary);
for (d_t d3 : Res) {
EdgeFunction<l_t> SumEdgFnE =
CachedFlowEdgeFunctions.getSummaryEdgeFunction(n, d2,
Expand Down Expand Up @@ -341,7 +347,8 @@ class IDESolver
}
// if startPointsOf is empty, the called function is a declaration
for (n_t SP : StartPointsOf) {
saveEdges(n, SP, d2, Res, true);
HasNoCalleeInformation = false;
saveEdges(n, SP, d2, Res, ESGEdgeKind::Call);
// for each result node of the call-flow function
for (d_t d3 : Res) {
using TableCell = typename Table<n_t, d_t, EdgeFunction<l_t>>::Cell;
Expand Down Expand Up @@ -382,7 +389,7 @@ class IDESolver
RetFunction, d3, d4, n, Container{d2});
ADD_TO_HISTOGRAM("Data-flow facts", ReturnedFacts.size(), 1,
Full);
saveEdges(eP, RetSiteN, d4, ReturnedFacts, true);
saveEdges(eP, RetSiteN, d4, ReturnedFacts, ESGEdgeKind::Ret);
// for each target value of the function
for (d_t d5 : ReturnedFacts) {
// update the caller-side summary function
Expand Down Expand Up @@ -439,7 +446,9 @@ class IDESolver
container_type ReturnFacts =
computeCallToReturnFlowFunction(CallToReturnFF, d1, d2);
ADD_TO_HISTOGRAM("Data-flow facts", ReturnFacts.size(), 1, Full);
saveEdges(n, ReturnSiteN, d2, ReturnFacts, false);
saveEdges(n, ReturnSiteN, d2, ReturnFacts,
HasNoCalleeInformation ? ESGEdgeKind::SkipUnknownFn
: ESGEdgeKind::CallToRet);
for (d_t d3 : ReturnFacts) {
EdgeFunction<l_t> EdgeFnE =
CachedFlowEdgeFunctions.getCallToRetEdgeFunction(n, d2, ReturnSiteN,
Expand Down Expand Up @@ -478,7 +487,7 @@ class IDESolver
INC_COUNTER("FF Queries", 1, Full);
const container_type Res = computeNormalFlowFunction(FlowFunc, d1, d2);
ADD_TO_HISTOGRAM("Data-flow facts", Res.size(), 1, Full);
saveEdges(n, nPrime, d2, Res, false);
saveEdges(n, nPrime, d2, Res, ESGEdgeKind::Normal);
for (d_t d3 : Res) {
EdgeFunction<l_t> g =
CachedFlowEdgeFunctions.getNormalEdgeFunction(n, d2, nPrime, d3);
Expand Down Expand Up @@ -690,12 +699,12 @@ class IDESolver
}

virtual void saveEdges(n_t SourceNode, n_t SinkStmt, d_t SourceVal,
const container_type &DestVals, bool InterP) {
const container_type &DestVals, ESGEdgeKind Kind) {
if (!SolverConfig.recordEdges()) {
return;
}
Table<n_t, n_t, std::map<d_t, container_type>> &TgtMap =
(InterP) ? ComputedInterPathEdges : ComputedIntraPathEdges;
(isInterProc(Kind)) ? ComputedInterPathEdges : ComputedIntraPathEdges;
TgtMap.get(SourceNode, SinkStmt)[SourceVal].insert(DestVals.begin(),
DestVals.end());
}
Expand Down Expand Up @@ -833,7 +842,7 @@ class IDESolver
const container_type Targets =
computeReturnFlowFunction(RetFunction, d1, d2, c, Entry.second);
ADD_TO_HISTOGRAM("Data-flow facts", Targets.size(), 1, Full);
saveEdges(n, RetSiteC, d2, Targets, true);
saveEdges(n, RetSiteC, d2, Targets, ESGEdgeKind::Ret);
// for each target value at the return site
// line 23
for (d_t d5 : Targets) {
Expand Down Expand Up @@ -902,7 +911,7 @@ class IDESolver
const container_type Targets = computeReturnFlowFunction(
RetFunction, d1, d2, Caller, Container{ZeroValue});
ADD_TO_HISTOGRAM("Data-flow facts", Targets.size(), 1, Full);
saveEdges(n, RetSiteC, d2, Targets, true);
saveEdges(n, RetSiteC, d2, Targets, ESGEdgeKind::Ret);
for (d_t d5 : Targets) {
EdgeFunction<l_t> f5 =
CachedFlowEdgeFunctions.getReturnEdgeFunction(
Expand Down
69 changes: 69 additions & 0 deletions include/phasar/DataFlow/IfdsIde/Solver/PathAwareIDESolver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/******************************************************************************
* Copyright (c) 2022 Philipp Schubert.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of LICENSE.txt.
*
* Contributors:
* Fabian Schiebel and others
*****************************************************************************/

#ifndef PHASAR_DATAFLOW_IFDSIDE_SOLVER_PATHAWAREIDESOLVER_H
#define PHASAR_DATAFLOW_IFDSIDE_SOLVER_PATHAWAREIDESOLVER_H

#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
#include "phasar/DataFlow/IfdsIde/Solver/ESGEdgeKind.h"
#include "phasar/DataFlow/IfdsIde/Solver/IDESolver.h"
#include "phasar/DataFlow/PathSensitivity/ExplodedSuperGraph.h"
#include "phasar/Utils/Logger.h"

namespace psr {
template <typename AnalysisDomainTy,
typename Container = std::set<typename AnalysisDomainTy::d_t>>
class PathAwareIDESolver : public IDESolver<AnalysisDomainTy, Container> {
using base_t = IDESolver<AnalysisDomainTy, Container>;

public:
using domain_t = AnalysisDomainTy;
using n_t = typename base_t::n_t;
using d_t = typename base_t::d_t;
using i_t = typename base_t::i_t;
using container_type = typename base_t::container_type;

explicit PathAwareIDESolver(
IDETabulationProblem<domain_t, container_type> &Problem, const i_t *ICF)
: base_t(Problem, ICF), ESG(Problem.getZeroValue()) {

if (Problem.getIFDSIDESolverConfig().autoAddZero()) {
PHASAR_LOG_LEVEL(
WARNING,
"The PathAwareIDESolver is initialized with the option 'autoAddZero' "
"being set. This might degrade the quality of the computed paths!");
}
}

[[nodiscard]] const ExplodedSuperGraph<domain_t> &
getExplicitESG() const &noexcept {
return ESG;
}

[[nodiscard]] ExplodedSuperGraph<domain_t> &&getExplicitESG() &&noexcept {
return std::move(ESG);
}

private:
void saveEdges(n_t Curr, n_t Succ, d_t CurrNode,
const container_type &SuccNodes, ESGEdgeKind Kind) override {
ESG.saveEdges(std::move(Curr), std::move(CurrNode), std::move(Succ),
SuccNodes, Kind);
}

ExplodedSuperGraph<domain_t> ESG;
};

template <typename ProblemTy>
PathAwareIDESolver(ProblemTy &)
-> PathAwareIDESolver<typename ProblemTy::ProblemAnalysisDomain>;

} // namespace psr

#endif // PHASAR_DATAFLOW_IFDSIDE_SOLVER_PATHAWAREIDESOLVER_H
1 change: 1 addition & 0 deletions include/phasar/DataFlow/IfdsIde/SolverResults.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class OwningSolverResults
[[nodiscard]] operator SolverResults<N, D, L>() const &noexcept {
return get();
}

operator SolverResults<N, D, L>() && = delete;

private:
Expand Down
Loading