Skip to content

Commit 51ed40e

Browse files
authored
Merge branch 'development' into f-FilteredAliasSet
2 parents 51a17e0 + 488da6a commit 51ed40e

File tree

36 files changed

+168
-122
lines changed

36 files changed

+168
-122
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,12 @@ else()
293293
endif()
294294

295295
# SQL
296-
find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)
297-
find_library(SQLITE3_LIBRARY NAMES sqlite3)
296+
find_package(SQLite3)
297+
if(SQLite3_FOUND)
298+
set(PHASAR_HAS_SQLITE ON)
299+
else()
300+
set(PHASAR_HAS_SQLITE OFF)
301+
endif()
298302

299303
option(USE_LLVM_FAT_LIB "Link against libLLVM.so instead of the individual LLVM libraries if possible (default is OFF; always on if BUILD_SHARED_LIBS is ON)" OFF)
300304

bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters
108108

109109
echo "installing phasar dependencies..."
110110
if [ -x "$(command -v pacman)" ]; then
111-
yes | sudo pacman -Syu --needed which zlib sqlite3 python3 doxygen gcc python-pip ninja cmake
111+
yes | sudo pacman -Syu --needed which zlib python3 doxygen gcc ninja cmake
112112
else
113113
./utils/InstallAptDependencies.sh
114114
fi

cmake/phasar_macros.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ function(generate_ll_file)
7676
set(GEN_C_FLAGS -fno-discard-value-names -emit-llvm -S -w)
7777
set(GEN_CMD_COMMENT "[LL]")
7878

79+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
80+
list(APPEND GEN_CXX_FLAGS -Xclang -no-opaque-pointers)
81+
endif()
82+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
83+
list(APPEND GEN_C_FLAGS -Xclang -no-opaque-pointers)
84+
endif()
85+
7986
if(GEN_LL_MEM2REG)
8087
list(APPEND GEN_CXX_FLAGS -Xclang -disable-O0-optnone)
8188
list(APPEND GEN_C_FLAGS -Xclang -disable-O0-optnone)
@@ -121,7 +128,7 @@ function(generate_ll_file)
121128
add_custom_command(
122129
OUTPUT ${test_code_ll_file}
123130
COMMAND ${GEN_CMD} ${test_code_file_path} -o ${test_code_ll_file}
124-
COMMAND ${CMAKE_CXX_COMPILER_LAUNCHER} opt -mem2reg -S ${test_code_ll_file} -o ${test_code_ll_file}
131+
COMMAND ${CMAKE_CXX_COMPILER_LAUNCHER} opt -mem2reg -S -opaque-pointers=0 ${test_code_ll_file} -o ${test_code_ll_file}
125132
COMMENT ${GEN_CMD_COMMENT}
126133
DEPENDS ${GEN_LL_FILE}
127134
VERBATIM

config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
#cmakedefine DYNAMIC_LOG
1010
#cmakedefine BUILD_PHASAR_CLANG
1111

12+
#cmakedefine PHASAR_HAS_SQLITE
13+
1214
#endif /* PHASAR_CONFIG_CONFIG_H */

include/phasar/DB.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
#ifndef PHASAR_DB_H
1111
#define PHASAR_DB_H
1212

13-
#include "phasar/DB/Hexastore.h"
13+
#include "phasar/Config/phasar-config.h"
1414
#include "phasar/DB/ProjectIRDBBase.h"
15+
16+
#ifdef PHASAR_HAS_SQLITE
17+
#include "phasar/DB/Hexastore.h"
1518
#include "phasar/DB/Queries.h"
19+
#endif
1620

1721
#endif // PHASAR_DB_H

include/phasar/DB/Hexastore.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
#ifndef PHASAR_DB_HEXASTORE_H_
1111
#define PHASAR_DB_HEXASTORE_H_
1212

13-
#include "phasar/DB/Queries.h"
13+
#include "phasar/Config/phasar-config.h"
14+
#ifndef PHASAR_HAS_SQLITE
15+
#error \
16+
"Hexastore requires SQLite3. Please install libsqlite3-dev and reconfigure PhASAR."
17+
#endif
1418

1519
#include "llvm/Support/raw_ostream.h"
1620

17-
#include "boost/format.hpp"
18-
#include "sqlite3.h"
19-
2021
#include <array>
2122
#include <string>
2223
#include <vector>
2324

25+
struct sqlite3;
26+
2427
namespace psr {
2528
/**
2629
* @brief Holds the results of a query to the Hexastore.
@@ -51,6 +54,7 @@ struct HSResult {
5154
LHS.Object == RHS.Object;
5255
}
5356
};
57+
5458
/**
5559
* A Hexastore is an efficient approach to store large graphs.
5660
* This approach is based on the paper "Database-Backed Program Analysis

include/phasar/DataFlow/Mono/Solver/InterMonoSolver.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <unordered_map>
2525
#include <unordered_set>
2626
#include <utility>
27-
#include <vector>
2827

2928
namespace psr {
3029

@@ -368,18 +367,8 @@ template <typename AnalysisDomainTy, unsigned K> class InterMonoSolver {
368367
}
369368
// Compute the data-flow facts using the respective kind of flows
370369
if (ICF->isCallSite(Src)) {
371-
// Handle call flow(s)
372-
if (!isIntraEdge(Edge)) {
373-
// real call
374-
for (auto &[Ctx, Facts] : Analysis[Src]) {
375-
processCall(Edge); // TODO: decompose into processCall and
376-
// processCallToRet
377-
}
378-
} else {
379-
// call-to-return
380-
processCall(
381-
Edge); // TODO: decompose into processCall and processCallToRet
382-
}
370+
// Handle call flow(s) and call-to-return flow
371+
processCall(Edge);
383372
} else if (ICF->isExitInst(Src)) {
384373
// Handle return flow
385374
processExit(Edge);

include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
namespace psr {
4343
class LLVMTypeHierarchy;
4444
class LLVMProjectIRDB;
45+
class Resolver;
4546

4647
class LLVMBasedICFG;
4748
template <> struct CFGTraits<LLVMBasedICFG> : CFGTraits<LLVMBasedCFG> {};
@@ -87,6 +88,11 @@ class LLVMBasedICFG : public LLVMBasedCFG, public ICFGBase<LLVMBasedICFG> {
8788
LLVMAliasInfoRef PT = nullptr,
8889
Soundness S = Soundness::Soundy,
8990
bool IncludeGlobals = true);
91+
explicit LLVMBasedICFG(LLVMProjectIRDB *IRDB, Resolver &CGResolver,
92+
llvm::ArrayRef<std::string> EntryPoints = {},
93+
LLVMTypeHierarchy *TH = nullptr,
94+
Soundness S = Soundness::Soundy,
95+
bool IncludeGlobals = true);
9096

9197
/// Creates an ICFG with an already given call-graph
9298
explicit LLVMBasedICFG(CallGraph<n_t, f_t> CG, LLVMProjectIRDB *IRDB,
@@ -157,6 +163,10 @@ class LLVMBasedICFG : public LLVMBasedCFG, public ICFGBase<LLVMBasedICFG> {
157163
[[nodiscard]] llvm::Function *buildCRuntimeGlobalCtorsDtorsModel(
158164
llvm::Module &M, llvm::ArrayRef<llvm::Function *> UserEntryPoints);
159165

166+
void initialize(LLVMProjectIRDB *IRDB, Resolver &CGResolver,
167+
llvm::ArrayRef<std::string> EntryPoints,
168+
LLVMTypeHierarchy *TH, Soundness S, bool IncludeGlobals);
169+
160170
// ---
161171

162172
CallGraph<const llvm::Instruction *, const llvm::Function *> CG;

include/phasar/PhasarLLVM/ControlFlow/Resolver/OTFResolver.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ class Value;
3535

3636
namespace psr {
3737

38-
class LLVMBasedICFG;
3938
class LLVMTypeHierarchy;
4039

4140
class OTFResolver : public Resolver {
4241
protected:
43-
LLVMBasedICFG &ICF;
4442
LLVMAliasInfoRef PT;
4543

4644
public:
47-
OTFResolver(LLVMProjectIRDB &IRDB, LLVMTypeHierarchy &TH, LLVMBasedICFG &ICF,
45+
OTFResolver(LLVMProjectIRDB &IRDB, LLVMTypeHierarchy &TH,
4846
LLVMAliasInfoRef PT);
4947

5048
~OTFResolver() override = default;

include/phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ namespace psr {
3636
class LLVMProjectIRDB;
3737
class LLVMTypeHierarchy;
3838
enum class CallGraphAnalysisType;
39-
class LLVMBasedICFG;
4039
class LLVMPointsToInfo;
4140

4241
[[nodiscard]] std::optional<unsigned>
@@ -83,9 +82,10 @@ class Resolver {
8382

8483
[[nodiscard]] virtual std::string str() const = 0;
8584

86-
static std::unique_ptr<Resolver>
87-
create(CallGraphAnalysisType Ty, LLVMProjectIRDB *IRDB, LLVMTypeHierarchy *TH,
88-
LLVMBasedICFG *ICF = nullptr, LLVMAliasInfoRef PT = nullptr);
85+
static std::unique_ptr<Resolver> create(CallGraphAnalysisType Ty,
86+
LLVMProjectIRDB *IRDB,
87+
LLVMTypeHierarchy *TH,
88+
LLVMAliasInfoRef PT = nullptr);
8989
};
9090
} // namespace psr
9191

0 commit comments

Comments
 (0)