Skip to content

Misc Changes #773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 90 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
d2c7bcb
replaced llvm-14 with llvm-15 in relevant files
mxHuber May 15, 2024
8056664
some changes
fabianbs96 May 17, 2024
54a56bc
more efficient call-graph
fabianbs96 May 17, 2024
4fd9d39
String-nbased vtable getter + CG-test with dbg info
fabianbs96 May 17, 2024
70734dc
minor in CG
fabianbs96 May 21, 2024
ab3fa86
annotation fix + test fix
mxHuber May 29, 2024
f703041
removed bitcasts and fixed tests
mxHuber Jun 3, 2024
b78d077
Fix Annotation.cpp + TaintConfigTest
fabianbs96 Jun 4, 2024
09e34aa
Quick-fix LLVMTypeHierarchyTest
fabianbs96 Jun 4, 2024
147ecd1
fix one IIA test
fabianbs96 Jun 4, 2024
fda53ef
Fix StringtestCpp for generalized LCA
fabianbs96 Jun 4, 2024
9b449d1
first half of tests fixed
mxHuber Jun 5, 2024
6b12b7b
fixed first half of tests
mxHuber Jun 5, 2024
bbe775a
fixed all but one test in IDEInstInteractionAnalysisTest
mxHuber Jun 6, 2024
c235afc
fixed all but two tests
mxHuber Jun 6, 2024
311cb68
Fix IIAFlowFact equality
fabianbs96 Jun 7, 2024
8c044ea
Merge branch 'development' into 'f-TestingAPIChanges'
fabianbs96 Jun 10, 2024
4c043d9
Re-add getVFTableGlobal
fabianbs96 Jun 10, 2024
04a895d
fixed some newly failed tests
mxHuber Jun 12, 2024
e31c5ae
trade soundness for precision in LLVMAliasSet
fabianbs96 Jun 12, 2024
b6f4a10
Merge remote-tracking branch 'upstream/development' into f-clang-15
mxHuber Jun 12, 2024
e8c7f65
ci.yml update
mxHuber Jun 12, 2024
c3081ed
Revert "fixed some newly failed tests"
mxHuber Jun 12, 2024
6ced614
pre-commit hook
mxHuber Jun 12, 2024
12a9d06
Two Tests + xtaint09 test fix for pipeline
mxHuber Jun 12, 2024
9f5902a
Basic Opaque Pointer Impl, bugged
mxHuber Jun 13, 2024
812e6cb
switching to DebugInfoFinder
mxHuber Jun 13, 2024
8f89d1d
re-add the quick-fix for LLVMTypeHierarchy
fabianbs96 Jun 16, 2024
2bfffa8
OpaquePtr type mapping, missing subroutines
mxHuber Jun 17, 2024
2a91b6d
Introducing a pass to save ptr types
mxHuber Jun 18, 2024
d581987
Revert "Introducing a pass to save ptr types"
mxHuber Jun 19, 2024
9eb9929
moving phasar to DIBasedTypeHierarchy
mxHuber Jun 19, 2024
0b7575e
full switch to DIBasedTypeHierarchy + Test fixes
mxHuber Jun 23, 2024
5b39a18
fixed PathTracingTest
mxHuber Jun 25, 2024
85b0f24
dtaresolver deprecated and test fixes
mxHuber Jul 1, 2024
16c4a8e
Fixed OTFTest
mxHuber Jul 1, 2024
0514c7d
trimmed trailing whitespace
mxHuber Jul 1, 2024
2d8c9d8
minor fixes
mxHuber Jul 10, 2024
4463625
readded TypeToDIType map for RTAResolver
mxHuber Jul 10, 2024
df7d190
pre-commit clang-format fix
mxHuber Jul 10, 2024
ce2c6e8
pre-commit clang-format llvmbasedicfg.cpp
mxHuber Jul 10, 2024
8a4d812
moved RTAResolver to DITypes
mxHuber Jul 10, 2024
fd11ada
implemented review suggestions
mxHuber Aug 4, 2024
9c7f378
Log error if trying to instantiate DTAResolver + minor
fabianbs96 Aug 6, 2024
022b426
Add breaking changes
fabianbs96 Aug 6, 2024
d482f4d
Merge branch 'development' into f-clang-15
fabianbs96 Aug 8, 2024
b4783b9
Also compare gep type in IIA EqualGEPDescriptor
fabianbs96 Aug 9, 2024
49707eb
Merge branch 'development' into f-clang-15
fabianbs96 Aug 9, 2024
a7aa1b9
Expose getDILocation()
fabianbs96 Sep 27, 2024
20a2d87
expose getSrcCodeFromIR for DebugLocation + minor
fabianbs96 Sep 27, 2024
3848eef
Merge branch 'development' into f-clang-15
fabianbs96 Oct 4, 2024
d07ee2b
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 Oct 4, 2024
7829bcb
Remove some unused includes
fabianbs96 Oct 4, 2024
4800fd0
Make TaintConfigData compatible with C++20
fabianbs Oct 4, 2024
24fc54e
Compatibility with opaque pointers
fabianbs Oct 4, 2024
628d768
Allow setting the LLVM version from higher-level projects
fabianbs Oct 5, 2024
2c04104
Getting rid of UB in CHAResolver
fabianbs Oct 6, 2024
a9cd897
Merge OpaquePointersIntegration #730
fabianbs96 Oct 7, 2024
825da2a
Start adding more sophisticated type extraction (WIP)
fabianbs Oct 7, 2024
8efd2f1
Handle function calls in getVarTypeFromIR
fabianbs96 Oct 8, 2024
afe65bb
better fallback handling for getDebugLocation, etc
fabianbs96 Oct 8, 2024
b939dbc
Better IntraMonoSolver dump
fabianbs96 Oct 22, 2024
535c114
minor
fabianbs96 Oct 22, 2024
8d05420
improve intra mono dump
fabianbs96 Oct 22, 2024
4a75fee
minor
fabianbs96 Oct 22, 2024
58138d2
expose getNonPureVirtualVFTEntry as namespace-scope function + fix bu…
fabianbs96 Oct 26, 2024
69600fd
Fix RTA resolver
fabianbs96 Nov 24, 2024
e65d4f1
Add missing include
fabianbs96 Nov 24, 2024
61a76e2
Fix solveIFDSProblem + cherry-pick fix of DIBasedTypeHierarchy::build…
fabianbs96 Nov 24, 2024
4819ee4
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 Dec 2, 2024
0841e38
dump functions from debugger
fabianbs96 Jan 25, 2025
55b6dd2
Remove unused-variable warning in release mode for CallGraph.h
fabianbs96 Feb 4, 2025
d5529d2
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 Mar 13, 2025
190e828
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 Mar 22, 2025
c4f5a54
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 Mar 26, 2025
f26005f
minor fix in CHA and RTA resolvers
fabianbs96 Mar 28, 2025
e97185e
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 Apr 6, 2025
6c89c99
Some cleanup
fabianbs96 Apr 6, 2025
96b710f
Add ome additional robustness to LLVMIRToSrc
fabianbs96 Apr 7, 2025
4949284
Fix AllBottom::compose + make FilteredLLVMAliasSet a bit more robust
fabianbs96 Apr 29, 2025
4bbe19f
Make getAllExitPoints more flexible + minor
fabianbs96 May 5, 2025
c95cc63
Handle atexit() in GlobalCtorsDtorsModel (not only __cxa_atexit())
fabianbs96 May 7, 2025
eba7d15
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 May 25, 2025
52c15ff
minor fix in FilteredLLVMAliasSet::isInReachableAllocationSites
fabianbs96 May 25, 2025
18c848a
pre-commit
fabianbs96 May 25, 2025
f259308
Merge branch 'development' into f-TestingAPIChanges
fabianbs96 May 31, 2025
3076b13
pre-commit
fabianbs96 May 31, 2025
e6bd1e5
Fix name
fabianbs96 May 31, 2025
9357394
Fix new CastInfo for EdgeFunction
fabianbs96 Jun 7, 2025
97c3913
Make LLVMProjectIRDB movable and add static function load() that retu…
fabianbs96 Jun 7, 2025
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
5 changes: 2 additions & 3 deletions include/phasar/DataFlow/IfdsIde/EdgeFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,7 @@ template <typename L> struct DenseMapInfo<psr::EdgeFunction<L>> {

// LLVM is currently overhauling its casting system. Use the new variant once
// possible!
// Note: The new variant (With CastInfo) is not tested yet!
#if LLVM_MAJOR < 15
#if LLVM_VERSION_MAJOR < 15

template <typename To, typename L>
struct isa_impl_cl<To, const psr::EdgeFunction<L>> {
Expand Down Expand Up @@ -876,7 +875,7 @@ cast_or_null(const psr::EdgeFunction<L> &EF) noexcept { // NOLINT
template <typename To, typename L>
struct CastIsPossible<To, psr::EdgeFunction<L>> {
static inline bool isPossible(const psr::EdgeFunction<L> &EF) noexcept {
return EF->template isa<To>();
return EF.template isa<To>();
}
};

Expand Down
213 changes: 117 additions & 96 deletions include/phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,67 @@ template <typename L> struct EdgeIdentity final {
const EdgeFunction<l_t> &OtherFunction);
};

template <typename L> struct ConstantEdgeFunction {
using l_t = L;
using JLattice = JoinLatticeTraits<L>;
using value_type = typename NonTopBotValue<l_t>::type;

[[nodiscard]] l_t computeTarget(ByConstRef<l_t> /*Source*/) const
noexcept(std::is_nothrow_constructible_v<l_t, const value_type &>) {
static_assert(IsEdgeFunction<ConstantEdgeFunction>);
return Value;
}

template <typename ConcreteEF, typename = std::enable_if_t<std::is_base_of_v<
ConstantEdgeFunction, ConcreteEF>>>
[[nodiscard]] static EdgeFunction<l_t>
compose(EdgeFunctionRef<ConcreteEF> This,
const EdgeFunction<l_t> &SecondFunction);

template <typename ConcreteEF, typename = std::enable_if_t<std::is_base_of_v<
ConstantEdgeFunction, ConcreteEF>>>
[[nodiscard]] static EdgeFunction<l_t>
join(EdgeFunctionRef<ConcreteEF> This,
const EdgeFunction<l_t> &OtherFunction);

[[nodiscard]] constexpr bool isConstant() const noexcept { return true; }

// -- constant data member

value_type Value{};
};

template <typename L, typename = std::enable_if_t<
CanEfficientlyPassByValue<ConstantEdgeFunction<L>>>>
[[nodiscard]] bool operator==(ConstantEdgeFunction<L> LHS,
ConstantEdgeFunction<L> RHS) noexcept {
return LHS.Value == RHS.Value;
}

template <typename L, typename = std::enable_if_t<
!CanEfficientlyPassByValue<ConstantEdgeFunction<L>>>>
[[nodiscard]] bool operator==(const ConstantEdgeFunction<L> &LHS,
const ConstantEdgeFunction<L> &RHS) noexcept {
return LHS.Value == RHS.Value;
}

template <typename L>
[[nodiscard]] llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS, ByConstRef<ConstantEdgeFunction<L>> Id) {
OS << "ConstantEF";
if constexpr (is_llvm_printable_v<
typename ConstantEdgeFunction<L>::value_type>) {
OS << '[' << Id.Value << ']';
}
return OS;
}

template <typename L> struct AllBottom final {
using l_t = L;
using JLattice = JoinLatticeTraits<L>;

[[no_unique_address]] std::conditional_t<HasJoinLatticeTraits<l_t>, EmptyType,
l_t>
BottomValue;
l_t> BottomValue;

[[nodiscard]] l_t computeTarget(ByConstRef<l_t> /*Source*/) const noexcept {
static_assert(std::is_trivially_copyable_v<AllBottom>);
Expand All @@ -61,7 +115,25 @@ template <typename L> struct AllBottom final {
[[nodiscard]] static EdgeFunction<l_t>
compose(EdgeFunctionRef<AllBottom> This,
const EdgeFunction<l_t> &SecondFunction) {
return SecondFunction.isConstant() ? SecondFunction : This;
if (SecondFunction.isConstant()) {
return SecondFunction;
}

if constexpr (HasJoinLatticeTraits<L>) {
auto ConstVal = SecondFunction.computeTarget(JLattice::bottom());
if (ConstVal == JLattice::bottom()) {
return This;
}

return ConstantEdgeFunction<L>{
NonTopBotValue<L>::unwrap(std::move(ConstVal))};
} else {
// Note: This used to be the default behavior, but it appears to be too
// restrictive
return This;
}

// return SecondFunction.isConstant() ? SecondFunction : This;
}

[[nodiscard]] static EdgeFunction<l_t>
Expand All @@ -85,8 +157,7 @@ template <typename L> struct AllTop final {
using JLattice = JoinLatticeTraits<L>;

[[no_unique_address]] std::conditional_t<HasJoinLatticeTraits<l_t>, EmptyType,
l_t>
TopValue;
l_t> TopValue;

[[nodiscard]] l_t computeTarget(ByConstRef<l_t> /*Source*/) const noexcept {
static_assert(std::is_trivially_copyable_v<AllTop>);
Expand Down Expand Up @@ -149,97 +220,6 @@ defaultComposeOrNull(const EdgeFunction<L> &This,
return nullptr;
}

template <typename L> struct ConstantEdgeFunction {
using l_t = L;
using JLattice = JoinLatticeTraits<L>;
using value_type = typename NonTopBotValue<l_t>::type;

[[nodiscard]] l_t computeTarget(ByConstRef<l_t> /*Source*/) const
noexcept(std::is_nothrow_constructible_v<l_t, const value_type &>) {
static_assert(IsEdgeFunction<ConstantEdgeFunction>);
return Value;
}

template <typename ConcreteEF, typename = std::enable_if_t<std::is_base_of_v<
ConstantEdgeFunction, ConcreteEF>>>
[[nodiscard]] static EdgeFunction<l_t>
compose(EdgeFunctionRef<ConcreteEF> This,
const EdgeFunction<l_t> &SecondFunction) {
if (auto Default = defaultComposeOrNull(This, SecondFunction)) {
return Default;
}

auto ConstVal = SecondFunction.computeTarget(This->Value);
if constexpr (!EdgeFunctionBase::IsSOOCandidate<ConstantEdgeFunction>) {
if (ConstVal == This->Value) {
return This;
}
}

if constexpr (AreEqualityComparable<decltype(JLattice::bottom()), l_t>) {
if (JLattice::bottom() == ConstVal) {
return AllBottom<l_t>{};
}
} else {
if (l_t(JLattice::bottom()) == ConstVal) {
return AllBottom<l_t>{};
}
}

if constexpr (AreEqualityComparable<decltype(JLattice::top()), l_t>) {
if (JLattice::top() == ConstVal) {
/// TODO: Can this ever happen?
return AllTop<l_t>{};
}
} else {
if (l_t(JLattice::top()) == ConstVal) {
/// TODO: Can this ever happen?
return AllTop<l_t>{};
}
}

return ConstantEdgeFunction{
NonTopBotValue<l_t>::unwrap(std::move(ConstVal))};
}

template <typename ConcreteEF, typename = std::enable_if_t<std::is_base_of_v<
ConstantEdgeFunction, ConcreteEF>>>
[[nodiscard]] static EdgeFunction<l_t>
join(EdgeFunctionRef<ConcreteEF> This,
const EdgeFunction<l_t> &OtherFunction);

[[nodiscard]] constexpr bool isConstant() const noexcept { return true; }

// -- constant data member

value_type Value{};
};

template <typename L, typename = std::enable_if_t<
CanEfficientlyPassByValue<ConstantEdgeFunction<L>>>>
[[nodiscard]] bool operator==(ConstantEdgeFunction<L> LHS,
ConstantEdgeFunction<L> RHS) noexcept {
return LHS.Value == RHS.Value;
}

template <typename L, typename = std::enable_if_t<
!CanEfficientlyPassByValue<ConstantEdgeFunction<L>>>>
[[nodiscard]] bool operator==(const ConstantEdgeFunction<L> &LHS,
const ConstantEdgeFunction<L> &RHS) noexcept {
return LHS.Value == RHS.Value;
}

template <typename L>
[[nodiscard]] llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS, ByConstRef<ConstantEdgeFunction<L>> Id) {
OS << "ConstantEF";
if constexpr (is_llvm_printable_v<
typename ConstantEdgeFunction<L>::value_type>) {
OS << '[' << Id.Value << ']';
}
return OS;
}

template <typename L> struct EdgeFunctionComposer {
using l_t = L;

Expand Down Expand Up @@ -461,6 +441,47 @@ EdgeFunction<L> EdgeIdentity<L>::join(EdgeFunctionRef<EdgeIdentity> This,
return OtherFunction.joinWith(This);
}

template <typename L>
template <typename ConcreteEF, typename>
EdgeFunction<L>
ConstantEdgeFunction<L>::compose(EdgeFunctionRef<ConcreteEF> This,
const EdgeFunction<L> &SecondFunction) {
if (auto Default = defaultComposeOrNull(This, SecondFunction)) {
return Default;
}

auto ConstVal = SecondFunction.computeTarget(This->Value);
if constexpr (!EdgeFunctionBase::IsSOOCandidate<ConstantEdgeFunction>) {
if (ConstVal == This->Value) {
return This;
}
}

if constexpr (AreEqualityComparable<decltype(JLattice::bottom()), L>) {
if (JLattice::bottom() == ConstVal) {
return AllBottom<L>{};
}
} else {
if (L(JLattice::bottom()) == ConstVal) {
return AllBottom<L>{};
}
}

if constexpr (AreEqualityComparable<decltype(JLattice::top()), L>) {
if (JLattice::top() == ConstVal) {
/// TODO: Can this ever happen?
return AllTop<L>{};
}
} else {
if (L(JLattice::top()) == ConstVal) {
/// TODO: Can this ever happen?
return AllTop<L>{};
}
}

return ConstantEdgeFunction{NonTopBotValue<L>::unwrap(std::move(ConstVal))};
}

template <typename L>
template <typename ConcreteEF, typename>
EdgeFunction<L>
Expand Down
2 changes: 0 additions & 2 deletions include/phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
#include "phasar/PhasarLLVM/ControlFlow/LLVMVFTableProvider.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h"
#include "phasar/PhasarLLVM/Utils/LLVMBasedContainerConfig.h"
#include "phasar/Utils/MaybeUniquePtr.h"
#include "phasar/Utils/Soundness.h"

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/raw_ostream.h"

Expand Down
9 changes: 9 additions & 0 deletions include/phasar/PhasarLLVM/ControlFlow/LLVMVFTableProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include "phasar/PhasarLLVM/TypeHierarchy/LLVMVFTable.h"

#include "llvm/ADT/StringMap.h"

#include <unordered_map>

namespace llvm {
Expand All @@ -38,7 +40,14 @@ class LLVMVFTableProvider {
[[nodiscard]] const LLVMVFTable *
getVFTableOrNull(const llvm::DIType *Type) const;

[[nodiscard]] const llvm::GlobalVariable *
getVFTableGlobal(const llvm::DIType *Type) const;

[[nodiscard]] const llvm::GlobalVariable *
getVFTableGlobal(llvm::StringRef ClearTypeName) const;

private:
llvm::StringMap<const llvm::GlobalVariable *> ClearNameTVMap;
std::unordered_map<const llvm::DIType *, LLVMVFTable> TypeVFTMap;
};
} // namespace psr
Expand Down
4 changes: 4 additions & 0 deletions include/phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class Resolver {

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

/// Whether the ICFG needs to reconsider all dynamic call-sites once there
/// have been changes through handlePossibleTargets().
///
/// Make false for performance (may be less sound then)
[[nodiscard]] virtual bool mutatesHelperAnalysisInformation() const noexcept {
// Conservatively returns true. Override if possible
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct SVFGCache;
/// Conforms to the ICFGBase CRTP interface.
///
/// Use this in the IDESolver or IFDSSolver to profit from the SparseIFDS or
/// SparseIDE optimization after Karakays et al. "Symbol-Specific Sparsification
/// SparseIDE optimization after Karakaya et al. "Symbol-Specific Sparsification
/// of Interprocedural Distributive Environment Problems"
/// <https://doi.org/10.48550/arXiv.2401.14813>
class SparseLLVMBasedICFG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct CFGTraits<SparseLLVMBasedICFGView> : CFGTraits<LLVMBasedCFG> {};
/// It still owns the sparse value-flow graphs.
///
/// Use this in the IDESolver or IFDSSolver to profit from the SparseIFDS or
/// SparseIDE optimization after Karakays et al. "Symbol-Specific Sparsification
/// SparseIDE optimization after Karakaya et al. "Symbol-Specific Sparsification
/// of Interprocedural Distributive Environment Problems"
/// <https://doi.org/10.48550/arXiv.2401.14813>
class SparseLLVMBasedICFGView
Expand Down
21 changes: 19 additions & 2 deletions include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/raw_ostream.h"

Expand Down Expand Up @@ -56,14 +57,25 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
/// ownership of it. The module is optionally being preprocessed.
explicit LLVMProjectIRDB(std::unique_ptr<llvm::Module> Mod,
bool DoPreprocessing = true);
/// Initializes the new ProjectIRDB with the given IR Module and takes
/// ownership of it. The module is optionally being preprocessed. Takes the
/// given LLVMContext and binds its lifetime to the lifetime of the
/// constructed ProjectIRDB
explicit LLVMProjectIRDB(std::unique_ptr<llvm::Module> Mod,
std::unique_ptr<llvm::LLVMContext> Ctx,
bool DoPreprocessing = true);

/// Parses the given LLVM IR file and owns the resulting IR Module.
/// If an error occurs, an error message is written to stderr and subsequent
/// calls to isValid() return false.
explicit LLVMProjectIRDB(llvm::MemoryBufferRef Buf,
bool EnableOpaquePointers = LLVM_VERSION_MAJOR > 14);

LLVMProjectIRDB(const LLVMProjectIRDB &) = delete;
LLVMProjectIRDB &operator=(LLVMProjectIRDB &) = delete;
LLVMProjectIRDB &operator=(const LLVMProjectIRDB &) = delete;

LLVMProjectIRDB(LLVMProjectIRDB &&) noexcept = default;
LLVMProjectIRDB &operator=(LLVMProjectIRDB &&) noexcept = default;

~LLVMProjectIRDB();

Expand All @@ -74,6 +86,10 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
getParsedIRModuleOrNull(llvm::MemoryBufferRef IRFileContent,
llvm::LLVMContext &Ctx) noexcept;

[[nodiscard]] static llvm::ErrorOr<LLVMProjectIRDB>
load(const llvm::Twine &IRFileName,
bool EnableOpaquePointers = LLVM_VERSION_MAJOR > 14);

/// Also use the const overload
using ProjectIRDBBase::getFunction;
/// Non-const overload
Expand Down Expand Up @@ -163,7 +179,8 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
/// the preprocessing as well
void preprocessModule(llvm::Module *NonConstMod);

llvm::LLVMContext Ctx;
// LLVMContext is not movable, so wrap it into a unique_ptr
std::unique_ptr<llvm::LLVMContext> Ctx;
MaybeUniquePtr<llvm::Module> Mod = nullptr;
size_t IdOffset = 0;
llvm::SmallVector<const llvm::Value *, 0> IdToInst;
Expand Down
Loading
Loading