-
Notifications
You must be signed in to change notification settings - Fork 146
SVF Pointer Analyses #767
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
fabianbs96
wants to merge
20
commits into
secure-software-engineering:development
Choose a base branch
from
fabianbs96:f-PhasarSVF
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
SVF Pointer Analyses #767
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8914e0e
Add SVF dependency + make the LLVMBasedAliasAnalysis polymorphic to a…
fabianbs96 3a37d48
Add public interface for SVFPointsToSet
fabianbs96 3a227df
Add SVFPointsToInfo + Fix PointsToInfoBase
fabianbs96 2fe2ec8
Fixes in PointsToInfo + add minimal tests
fabianbs96 d309744
Add CRTPBase utility
fabianbs96 fb2118c
New test + some cleanup
fabianbs96 b8f297b
Merge branch 'development' into f-PhasarSVF
fabianbs96 6bc1988
Fix build due to merge
fabianbs96 f21feb1
Merge branch 'development' into f-PhasarSVF
fabianbs96 dcef1a1
minor
fabianbs96 cc500ce
Simplify the SVF alias analyses + make FunctionAliasView more type-safe
fabianbs96 72b894f
minor
fabianbs96 6fe1312
Merge branch 'development' into f-PhasarSVF
fabianbs96 5c4f52b
Regain precision
fabianbs96 c782f0b
Get rid of UB + aim to resolve memory leaks with SVF
fabianbs96 ba75085
Merge branch 'development' into f-PhasarSVF
fabianbs96 a1250ca
Merge branch 'development' into f-PhasarSVF
fabianbs96 2bb1072
Fix SVF memory leak
fabianbs96 37bcaca
pre-commit with new clang-format version
fabianbs96 de0539d
Apply review comments
fabianbs96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,6 @@ | |
|
||
#cmakedefine PHASAR_HAS_SQLITE | ||
|
||
#cmakedefine PHASAR_USE_SVF | ||
|
||
#endif /* PHASAR_CONFIG_CONFIG_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2025 Fabian Schiebel. | ||
* 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_PHASARLLVM_POINTER_ALIASANALYSISVIEW_H | ||
#define PHASAR_PHASARLLVM_POINTER_ALIASANALYSISVIEW_H | ||
|
||
#include "phasar/Pointer/AliasAnalysisType.h" | ||
#include "phasar/Pointer/AliasResult.h" | ||
|
||
#include <memory> | ||
#include <type_traits> | ||
|
||
namespace llvm { | ||
class Value; | ||
class DataLayout; | ||
class Function; | ||
} // namespace llvm | ||
|
||
namespace psr { | ||
class LLVMProjectIRDB; | ||
|
||
class FunctionAliasView { | ||
public: | ||
template <typename T> | ||
using AliasCallbackTy = AliasResult (*)(T *, const llvm::Value *, | ||
const llvm::Value *, | ||
const llvm::DataLayout &); | ||
|
||
[[nodiscard]] AliasResult alias(const llvm::Value *V, const llvm::Value *Rep, | ||
const llvm::DataLayout &DL) { | ||
return Alias(Context, V, Rep, DL); | ||
} | ||
|
||
template < | ||
typename T, typename AliasFn, | ||
typename = std::enable_if_t<std::is_empty_v<AliasFn> && | ||
std::is_default_constructible_v<AliasFn>>> | ||
constexpr FunctionAliasView(T *Context, AliasFn /*Alias*/) noexcept | ||
: Context(Context), Alias(&callAlias<T, AliasFn>) {} | ||
|
||
private: | ||
template <typename T, typename AliasFn> | ||
static AliasResult callAlias(void *Context, const llvm::Value *V1, | ||
const llvm::Value *V2, | ||
const llvm::DataLayout &DL) { | ||
return AliasFn{}(static_cast<T *>(Context), V1, V2, DL); | ||
} | ||
|
||
void *Context{}; | ||
AliasCallbackTy<void> Alias{}; | ||
}; | ||
|
||
#define PSR_BIND_ALIASVIEW(Ctx, ...) \ | ||
::psr::FunctionAliasView { \ | ||
(Ctx), [] { \ | ||
struct DefaultConstructibleCallable { \ | ||
auto operator()(decltype(Ctx) Context, const llvm::Value *V1, \ | ||
const llvm::Value *V2, const llvm::DataLayout &DL) { \ | ||
return __VA_ARGS__(Context, V1, V2, DL); \ | ||
} \ | ||
}; \ | ||
return DefaultConstructibleCallable{}; \ | ||
}() \ | ||
} | ||
|
||
class AliasAnalysisView { | ||
public: | ||
constexpr AliasAnalysisView(AliasAnalysisType PATy) noexcept : PATy(PATy) {} | ||
|
||
virtual ~AliasAnalysisView() = default; | ||
|
||
[[nodiscard]] FunctionAliasView getAAResults(const llvm::Function *F) { | ||
assert(F != nullptr); | ||
return doGetAAResults(F); | ||
} | ||
|
||
void erase(llvm::Function *F) noexcept { | ||
assert(F != nullptr); | ||
doErase(F); | ||
} | ||
|
||
void clear() noexcept { doClear(); } | ||
|
||
[[nodiscard]] constexpr AliasAnalysisType | ||
getPointerAnalysisType() const noexcept { | ||
return PATy; | ||
}; | ||
|
||
[[nodiscard]] static std::unique_ptr<AliasAnalysisView> | ||
create(LLVMProjectIRDB &IRDB, bool UseLazyEvaluation, AliasAnalysisType PATy); | ||
|
||
private: | ||
static std::unique_ptr<AliasAnalysisView> | ||
createLLVMBasedAnalysis(LLVMProjectIRDB &IRDB, bool UseLazyEvaluation, | ||
AliasAnalysisType PATy); | ||
|
||
virtual FunctionAliasView doGetAAResults(const llvm::Function *F) = 0; | ||
virtual void doErase(llvm::Function *F) noexcept = 0; | ||
virtual void doClear() noexcept = 0; | ||
|
||
AliasAnalysisType PATy{}; | ||
}; | ||
|
||
} // namespace psr | ||
|
||
#endif // PHASAR_PHASARLLVM_POINTER_ALIASANALYSISVIEW_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add some documentation about the steps involved in using SVF from PhASAR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should add sth like that