Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/******************************************************************************
* 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, mxHuber and others
*****************************************************************************/

#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDEALIASINFOTABULATIONPROBLEM_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDEALIASINFOTABULATIONPROBLEM_H

Expand Down Expand Up @@ -38,17 +47,14 @@ class IDEAliasAwareDefaultFlowFunctionsImpl

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunctionImpl(n_t Curr,
n_t /*Succ*/);
[[nodiscard]] FlowFunctionPtrType getCallFlowFunctionImpl(n_t CallInst,
f_t CalleeFun);
[[nodiscard]] FlowFunctionPtrType getRetFlowFunctionImpl(n_t CallSite,
f_t /*CalleeFun*/,
n_t ExitInst,
n_t /*RetSite*/);
[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunctionImpl(n_t CallSite, n_t /*RetSite*/,
llvm::ArrayRef<f_t> /*Callees*/);
using IDENoAliasDefaultFlowFunctionsImpl::getCallFlowFunctionImpl;
using IDENoAliasDefaultFlowFunctionsImpl::getCallToRetFlowFunctionImpl;

private:
protected:
LLVMAliasInfoRef AS;
};
} // namespace detail
Expand All @@ -58,22 +64,7 @@ class DefaultAliasAwareIDEProblem
: public IDETabulationProblem<AnalysisDomainTy>,
protected detail::IDEAliasAwareDefaultFlowFunctionsImpl {
public:
using ProblemAnalysisDomain = AnalysisDomainTy;
using d_t = typename AnalysisDomainTy::d_t;
using n_t = typename AnalysisDomainTy::n_t;
using f_t = typename AnalysisDomainTy::f_t;
using t_t = typename AnalysisDomainTy::t_t;
using v_t = typename AnalysisDomainTy::v_t;
using l_t = typename AnalysisDomainTy::l_t;
using i_t = typename AnalysisDomainTy::i_t;
using db_t = typename AnalysisDomainTy::db_t;

using ConfigurationTy = HasNoConfigurationType;

using FlowFunctionType = FlowFunction<d_t>;
using FlowFunctionPtrType = typename FlowFunctionType::FlowFunctionPtrType;

using container_type = typename FlowFunctionType::container_type;
using typename IDETabulationProblem<AnalysisDomainTy>::db_t;

/// Constructs an IDETabulationProblem with the usual arguments + alias
/// information.
Expand All @@ -86,9 +77,11 @@ class DefaultAliasAwareIDEProblem
std::optional<d_t>
ZeroValue) noexcept(std::is_nothrow_move_constructible_v<d_t>)
: IDETabulationProblem<AnalysisDomainTy>(IRDB, std::move(EntryPoints),
std::move(ZeroValue)),
ZeroValue),
detail::IDEAliasAwareDefaultFlowFunctionsImpl(AS) {}

using detail::IDEAliasAwareDefaultFlowFunctionsImpl::getAliasInfo;

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
Expand Down Expand Up @@ -129,6 +122,8 @@ class DefaultAliasAwareIFDSProblem
: IFDSTabulationProblem(IRDB, std::move(EntryPoints), ZeroValue),
detail::IDEAliasAwareDefaultFlowFunctionsImpl(AS) {}

using detail::IDEAliasAwareDefaultFlowFunctionsImpl::getAliasInfo;

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/******************************************************************************
* 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, mxHuber and others
*****************************************************************************/

#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDENOALIASINFOTABULATIONPROBLEM_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDENOALIASINFOTABULATIONPROBLEM_H

Expand Down Expand Up @@ -48,21 +57,6 @@ class DefaultNoAliasIDEProblem
: public IDETabulationProblem<AnalysisDomainTy>,
protected detail::IDENoAliasDefaultFlowFunctionsImpl {
public:
using ProblemAnalysisDomain = AnalysisDomainTy;
using d_t = typename AnalysisDomainTy::d_t;
using n_t = typename AnalysisDomainTy::n_t;
using f_t = typename AnalysisDomainTy::f_t;
using t_t = typename AnalysisDomainTy::t_t;
using v_t = typename AnalysisDomainTy::v_t;
using l_t = typename AnalysisDomainTy::l_t;
using i_t = typename AnalysisDomainTy::i_t;
using db_t = typename AnalysisDomainTy::db_t;

using ConfigurationTy = HasNoConfigurationType;

using FlowFunctionType = FlowFunction<d_t>;
using FlowFunctionPtrType = typename FlowFunctionType::FlowFunctionPtrType;

using IDETabulationProblem<AnalysisDomainTy>::IDETabulationProblem;

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/******************************************************************************
* 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, mxHuber and others
*****************************************************************************/

#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_DEFAULTREACHABLEALLOCATIONSITESIDEPROBLEM_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_DEFAULTREACHABLEALLOCATIONSITESIDEPROBLEM_H

#include "phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h"

// Forward declaration of types for which we only use its pointer or ref type
namespace llvm {
class Value;
class Instruction;
class Function;
} // namespace llvm

namespace psr {

namespace detail {
class IDEReachableAllocationSitesDefaultFlowFunctionsImpl
: private IDENoAliasDefaultFlowFunctionsImpl {
public:
using typename IDENoAliasDefaultFlowFunctionsImpl::d_t;
using typename IDENoAliasDefaultFlowFunctionsImpl::f_t;
using typename IDENoAliasDefaultFlowFunctionsImpl::FlowFunctionPtrType;
using typename IDENoAliasDefaultFlowFunctionsImpl::FlowFunctionType;
using typename IDENoAliasDefaultFlowFunctionsImpl::n_t;

using IDENoAliasDefaultFlowFunctionsImpl::isFunctionModeled;

[[nodiscard]] constexpr LLVMAliasInfoRef getAliasInfo() const noexcept {
return AS;
}

constexpr IDEReachableAllocationSitesDefaultFlowFunctionsImpl(
LLVMAliasInfoRef AS) noexcept
: AS(AS) {
assert(AS && "You must provide an alias information handle!");
}

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunctionImpl(n_t Curr,
n_t /*Succ*/);
[[nodiscard]] FlowFunctionPtrType getCallFlowFunctionImpl(n_t CallInst,
f_t CalleeFun);
[[nodiscard]] FlowFunctionPtrType getRetFlowFunctionImpl(n_t CallSite,
f_t /*CalleeFun*/,
n_t ExitInst,
n_t /*RetSite*/);

using IDENoAliasDefaultFlowFunctionsImpl::getCallToRetFlowFunctionImpl;

protected:
LLVMAliasInfoRef AS;
};
} // namespace detail

template <typename AnalysisDomainTy>
class DefaultReachableAllocationSitesIDEProblem
: public IDETabulationProblem<AnalysisDomainTy>,
protected detail::IDEReachableAllocationSitesDefaultFlowFunctionsImpl {
public:
using typename IDETabulationProblem<AnalysisDomainTy>::db_t;

/// Constructs an IDETabulationProblem with the usual arguments + alias
/// information.
///
/// \note It is useful to use an instance of FilteredAliasSet for the alias
/// information to lower suprious aliases
explicit DefaultReachableAllocationSitesIDEProblem(
const ProjectIRDBBase<db_t> *IRDB, LLVMAliasInfoRef AS,
std::vector<std::string> EntryPoints,
std::optional<d_t>
ZeroValue) noexcept(std::is_nothrow_move_constructible_v<d_t>)
: IDETabulationProblem<AnalysisDomainTy>(IRDB, std::move(EntryPoints),
ZeroValue),
detail::IDEReachableAllocationSitesDefaultFlowFunctionsImpl(AS) {}

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
}

[[nodiscard]] FlowFunctionPtrType
getCallFlowFunction(n_t CallInst, f_t CalleeFun) override {
return getCallFlowFunctionImpl(CallInst, CalleeFun);
}

[[nodiscard]] FlowFunctionPtrType getRetFlowFunction(n_t CallSite,
f_t CalleeFun,
n_t ExitInst,
n_t RetSite) override {
return getRetFlowFunctionImpl(CallSite, CalleeFun, ExitInst, RetSite);
}

[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
llvm::ArrayRef<f_t> Callees) override {
return getCallToRetFlowFunctionImpl(CallSite, RetSite, Callees);
}
};

class DefaultReachableAllocationSitesIFDSProblem
: public IFDSTabulationProblem<LLVMIFDSAnalysisDomainDefault>,
protected detail::IDEReachableAllocationSitesDefaultFlowFunctionsImpl {
public:
/// Constructs an IFDSTabulationProblem with the usual arguments + alias
/// information.
///
/// \note It is useful to use an instance of FilteredAliasSet for the alias
/// information to lower suprious aliases
explicit DefaultReachableAllocationSitesIFDSProblem(
const ProjectIRDBBase<db_t> *IRDB, LLVMAliasInfoRef AS,
std::vector<std::string> EntryPoints,
d_t ZeroValue) noexcept(std::is_nothrow_move_constructible_v<d_t>)
: IFDSTabulationProblem(IRDB, std::move(EntryPoints), ZeroValue),
detail::IDEReachableAllocationSitesDefaultFlowFunctionsImpl(AS) {}

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
}

[[nodiscard]] FlowFunctionPtrType
getCallFlowFunction(n_t CallInst, f_t CalleeFun) override {
return getCallFlowFunctionImpl(CallInst, CalleeFun);
}

[[nodiscard]] FlowFunctionPtrType getRetFlowFunction(n_t CallSite,
f_t CalleeFun,
n_t ExitInst,
n_t RetSite) override {
return getRetFlowFunctionImpl(CallSite, CalleeFun, ExitInst, RetSite);
}

[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
llvm::ArrayRef<f_t> Callees) override {
return getCallToRetFlowFunctionImpl(CallSite, RetSite, Callees);
}
};

} // namespace psr

#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/******************************************************************************
* 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, bulletspace and others
*****************************************************************************/
#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_FUNCTIONDATAFLOWFACTS_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_FUNCTIONDATAFLOWFACTS_H

#include "phasar/Utils/DefaultValue.h"

#include "llvm/ADT/StringMap.h"
Expand Down Expand Up @@ -75,3 +86,5 @@ class FunctionDataFlowFacts {
};

} // namespace psr::library_summary

#endif // PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_FUNCTIONDATAFLOWFACTS_H
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/******************************************************************************
* 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, bulletspace and others
*****************************************************************************/

#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_LLVMFUNCTIONDATAFLOWFACTS_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_LLVMFUNCTIONDATAFLOWFACTS_H

#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h"
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/FunctionDataFlowFacts.h"
#include "phasar/Utils/DefaultValue.h"
Expand Down Expand Up @@ -73,3 +85,5 @@ class LLVMFunctionDataFlowFacts {
std::unordered_map<const llvm::Function *, ParameterMappingTy> LLVMFdff;
};
} // namespace psr::library_summary

#endif // PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_LLVMFUNCTIONDATAFLOWFACTS_H
14 changes: 13 additions & 1 deletion include/phasar/PhasarLLVM/DataFlow/IfdsIde/LibCSummary.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#pragma once
/******************************************************************************
* 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, bulletspace and others
*****************************************************************************/

#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_LIBCSUMMARY_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_LIBCSUMMARY_H

namespace psr {
namespace library_summary {
Expand All @@ -7,3 +17,5 @@ class FunctionDataFlowFacts;

[[nodiscard]] const library_summary::FunctionDataFlowFacts &getLibCSummary();
} // namespace psr

#endif // PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_LIBCSUMMARY_H
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ auto detail::IDEAliasAwareDefaultFlowFunctionsImpl::getNormalFlowFunctionImpl(
Curr, Succ);
}

auto detail::IDEAliasAwareDefaultFlowFunctionsImpl::getCallFlowFunctionImpl(
n_t CallInst, f_t CalleeFun) -> FlowFunctionPtrType {
return this->IDENoAliasDefaultFlowFunctionsImpl::getCallFlowFunctionImpl(
CallInst, CalleeFun);
}

static void populateWithMayAliases(LLVMAliasInfoRef AS, container_type &Facts,
const llvm::Instruction *Context) {
container_type Tmp = Facts;
Expand Down Expand Up @@ -92,11 +86,3 @@ auto detail::IDEAliasAwareDefaultFlowFunctionsImpl::getRetFlowFunctionImpl(

return FFTemplates::killAllFlows();
}

auto detail::IDEAliasAwareDefaultFlowFunctionsImpl::
getCallToRetFlowFunctionImpl(n_t CallSite, n_t RetSite,
llvm::ArrayRef<f_t> Callees)
-> FlowFunctionPtrType {
return this->IDENoAliasDefaultFlowFunctionsImpl::getCallToRetFlowFunctionImpl(
CallSite, RetSite, Callees);
}
Loading
Loading