Skip to content
Open
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
5 changes: 4 additions & 1 deletion BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## development HEAD

*None*
- Removed the CRTP-template `ProjectIRDBBase`. Use the concept `ProjectIRDB` instead.
- Remove `EdgeFunction<L>::equals`. Use `operator==` instead.
- Remove ctor-overloads of `LLVMProjectIRDB` that use the `EnableOpaquePointers` parameter. LLVM is removing support for opaque pointers. Use the other ctors instead.
- Removed type-trait `has_getAsJson`, as it is not used in our codebase anymore. We switched from `getAsJson` to `printAsJson` a while ago.

## v2604

Expand Down
1 change: 0 additions & 1 deletion include/phasar/DB.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@

#include "phasar/Config/phasar-config.h"
#include "phasar/DB/ProjectIRDB.h"
#include "phasar/DB/ProjectIRDBBase.h"

#endif // PHASAR_DB_H
7 changes: 7 additions & 0 deletions include/phasar/DB/ProjectIRDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,11 @@ concept ProjectIRDB =

requires ProjectSymbolTable<T>;
};

// NOLINTNEXTLINE(readability-identifier-naming)
auto IRDBGetFunctionDef(const ProjectIRDB auto *IRDB) noexcept {
return [IRDB](llvm::StringRef Name) {
return IRDB->getFunctionDefinition(Name);
};
}
} // namespace psr
8 changes: 0 additions & 8 deletions include/phasar/DB/ProjectIRDBBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,6 @@ class LLVM_DEPRECATED(
}
};

template <typename DB>
// NOLINTNEXTLINE(readability-identifier-naming)
auto IRDBGetFunctionDef(const ProjectIRDBBase<DB> *IRDB) noexcept {
return [IRDB](llvm::StringRef Name) {
return IRDB->getFunctionDefinition(Name);
};
}

} // namespace psr

#endif // PHASAR_DB_PROJECTIRDBBASE_H
9 changes: 0 additions & 9 deletions include/phasar/DataFlow/IfdsIde/EdgeFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,6 @@ class [[clang::trivial_abi]] EdgeFunction final : EdgeFunctionBase {
LHS.VTAndHeapAlloc.getPointer()->equals(LHS.EF, RHS.EF);
}

template <IsEdgeFunction ConcreteEF>
requires(!std::is_same_v<EdgeFunction, std::decay_t<ConcreteEF>>)
[[nodiscard]] PSR_DEPRECATED(
"With C++20, we do not need this helper anymore, use operator== instead",
"operator==") bool equals(EdgeFunctionRef<ConcreteEF> Other)
const noexcept {
return *this == Other;
}

template <IsEdgeFunction ConcreteEF>
requires(!std::is_same_v<EdgeFunction, std::decay_t<ConcreteEF>>)
[[nodiscard]] bool
Expand Down
1 change: 0 additions & 1 deletion include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "phasar/Config/Configuration.h"
#include "phasar/ControlFlow/SparseCFGProvider.h"
#include "phasar/DB/ProjectIRDBBase.h"
#include "phasar/DataFlow/IfdsIde/EdgeFunction.h"
#include "phasar/DataFlow/IfdsIde/EdgeFunctionStats.h"
#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/Domain/AnalysisDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct AnalysisDomain {
// Inter-procedural control flow --- Specifies the type of the
// inter-procedural control-flow graph to be used.
using i_t = void;
// The ProjectIRDB type to use. Must inherit from the ProjectIRDBBase CRTP
// The ProjectIRDB type to use. Must conform to the ProjectIRDB concept
// template
using db_t = void;
// Lattice element --- Specifies the type of the underlying lattice; the value
Expand Down
109 changes: 43 additions & 66 deletions include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#ifndef PHASAR_PHASARLLVM_DB_LLVMPROJECTIRDB_H
#define PHASAR_PHASARLLVM_DB_LLVMPROJECTIRDB_H

#include "phasar/DB/ProjectIRDBBase.h"
#include "phasar/PhasarLLVM/Utils/LLVMBasedContainerConfig.h"
#include "phasar/Utils/MaybeUniquePtr.h"

Expand All @@ -29,37 +28,21 @@
#include <memory>

namespace psr {
class LLVMProjectIRDB;

template <> struct ProjectIRDBTraits<LLVMProjectIRDB> {
/// \brief Project IR Database that manages a LLVM IR module.
class LLVMProjectIRDB {

public:
using n_t = const llvm::Instruction *;
using f_t = const llvm::Function *;
using m_t = const llvm::Module *;
using g_t = const llvm::GlobalVariable *;
};

/// \brief Project IR Database that manages a LLVM IR module.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
#pragma GCC diagnostic pop
friend ProjectIRDBBase;

public:
/// Reads and 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(const llvm::Twine &IRFileName);

/// Reads and 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.
[[deprecated("When moving to the next LLVM version, opaque pointers support "
"is removed completely. Please use one of the other "
"constructors of LLVMProjectIRDB.")]]
explicit LLVMProjectIRDB(const llvm::Twine &IRFileName,
bool EnableOpaquePointers);

/// Initializes the new ProjectIRDB with the given IR Module _without_ taking
/// ownership. The module is optionally being preprocessed.
///
Expand All @@ -83,15 +66,6 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
/// calls to isValid() return false.
explicit LLVMProjectIRDB(llvm::MemoryBufferRef Buf);

/// 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.
[[deprecated("When moving to the next LLVM version, opaque pointers support "
"is removed completely. Please use one of the other "
"constructors of LLVMProjectIRDB.")]]
explicit LLVMProjectIRDB(llvm::MemoryBufferRef Buf,
bool EnableOpaquePointers);

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

Expand All @@ -115,27 +89,37 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
[[nodiscard]] static LLVMProjectIRDB
loadOrExit(const llvm::Twine &IRFileName, bool EnableOpaquePointers) = delete;

/// Also use the const overload
using ProjectIRDBBase::getFunction;
/// Non-const overload
[[nodiscard]] llvm::Function *getFunction(llvm::StringRef FunctionName) {
assert(isValid());
return Mod->getFunction(FunctionName);
}
/// Returns the function if available, nullptr/nullopt otherwise.
[[nodiscard]] f_t getFunction(llvm::StringRef FunctionName) const {
assert(isValid());
return Mod->getFunction(FunctionName);
}

/// Also use the const overload
using ProjectIRDBBase::getFunctionDefinition;
/// Non-const overload
/// Returns a mutable pointer to the function's definition if available, null
/// otherwise.
[[nodiscard]] llvm::Function *
getFunctionDefinition(llvm::StringRef FunctionName);

/// Also use the const overload
using ProjectIRDBBase::getModule;
/// Non-const overload
/// Returns the function's definition if available, null otherwise.
[[nodiscard]] f_t getFunctionDefinition(llvm::StringRef FunctionName) const;

/// Returns the managed module
[[nodiscard]] llvm::Module *getModule() noexcept { return Mod.get(); }

/// Returns the managed module
[[nodiscard]] const llvm::Module *getModule() const noexcept {
return Mod.get();
}

/// Similar to getInstruction(size_t), but is also able to return global
/// variables by id
[[nodiscard]] const llvm::Value *getValueFromId(size_t Id) const noexcept {
assert(isValid());
return Id < IdToInst.size() ? IdToInst[Id] : nullptr;
}

Expand Down Expand Up @@ -167,70 +151,64 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
/// Returns a range of all global variables (and global constants, e.g, string
/// literals) in the managed module
[[nodiscard]] auto getAllGlobals() const {
assert(isValid());
return llvm::map_range(std::as_const(*Mod).globals(),
Ref2PointerConverter<llvm::GlobalVariable>{});
}

explicit operator bool() const noexcept { return isValid(); }

private:
[[nodiscard]] m_t getModuleImpl() const noexcept { return Mod.get(); }
[[nodiscard]] bool debugInfoAvailableImpl() const;
[[nodiscard]] FunctionRange getAllFunctionsImpl() const {
return llvm::map_range(ProjectIRDBBase::getModule()->functions(),
[[nodiscard]] bool debugInfoAvailable() const;
[[nodiscard]] FunctionRange getAllFunctions() const {
return llvm::map_range(getModule()->functions(),
Ref2PointerConverter<llvm::Function>{});
}
[[nodiscard]] f_t getFunctionImpl(llvm::StringRef FunctionName) const {
return Mod->getFunction(FunctionName);
}
[[nodiscard]] f_t
getFunctionDefinitionImpl(llvm::StringRef FunctionName) const;
[[nodiscard]] bool
hasFunctionImpl(llvm::StringRef FunctionName) const noexcept {

[[nodiscard]] bool hasFunction(llvm::StringRef FunctionName) const noexcept {
assert(isValid());
return Mod->getFunction(FunctionName) != nullptr;
}
[[nodiscard]] f_t getFunctionOfImpl(n_t Inst) const {
assert(Inst != nullptr);
return Inst->getFunction();
}

[[nodiscard]] g_t getGlobalVariable(llvm::StringRef GlobalVariableName) const;
[[nodiscard]] g_t
getGlobalVariableImpl(llvm::StringRef GlobalVariableName) const;
[[nodiscard]] g_t
getGlobalVariableDefinitionImpl(llvm::StringRef GlobalVariableName) const;
[[nodiscard]] size_t getNumInstructionsImpl() const noexcept {
getGlobalVariableDefinition(llvm::StringRef GlobalVariableName) const;

[[nodiscard]] size_t getNumInstructions() const noexcept {
return IdToInst.size() - IdOffset;
}
[[nodiscard]] size_t getNumFunctionsImpl() const noexcept {
[[nodiscard]] size_t getNumFunctions() const noexcept {
assert(isValid());
return Mod->size();
}
[[nodiscard]] size_t getNumGlobalsImpl() const noexcept {
[[nodiscard]] size_t getNumGlobals() const noexcept {
assert(isValid());
return Mod->global_size();
}

[[nodiscard]] n_t getInstructionImpl(size_t Id) const noexcept {
[[nodiscard]] n_t getInstruction(size_t Id) const noexcept {
// Effectively make use of integer overflow here...
if (Id - IdOffset < IdToInst.size() - IdOffset) {
return llvm::cast<llvm::Instruction>(IdToInst[Id]);
}
return n_t{};
}

[[nodiscard]] auto getAllInstructionsImpl() const noexcept {
[[nodiscard]] auto getAllInstructions() const noexcept {
return llvm::map_range(
llvm::ArrayRef(IdToInst).drop_front(IdOffset),
[](const llvm::Value *V) { return llvm::cast<llvm::Instruction>(V); });
}

[[nodiscard]] size_t getInstructionIdImpl(n_t Inst) const {
[[nodiscard]] size_t getInstructionId(n_t Inst) const {
auto It = InstToId.find(Inst);
assert(It != InstToId.end());
return It->second;
}
[[nodiscard]] bool isValidImpl() const noexcept;
[[nodiscard]] bool isValid() const noexcept;

void dumpImpl() const;
void dump() const;

private:
void initInstructionIds();
/// XXX Later we might get rid of the metadata IDs entirely and therefore of
/// the preprocessing as well
Expand All @@ -250,7 +228,6 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
const llvm::Value *fromMetaDataId(const LLVMProjectIRDB &IRDB,
llvm::StringRef Id);

extern template class ProjectIRDBBase<LLVMProjectIRDB>;
} // namespace psr

#endif // PHASAR_PHASARLLVM_DB_LLVMPROJECTIRDB_H
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class DefaultAllocSitesAwareIDEProblem
/// \note It is useful to use an instance of FilteredAliasSet for the alias
/// information to lower suprious aliases
explicit DefaultAllocSitesAwareIDEProblem(
const ProjectIRDBBase<db_t> *IRDB, LLVMAliasInfoRef AS,
const db_t *IRDB, LLVMAliasInfoRef AS,
std::vector<std::string> EntryPoints,
std::optional<d_t>
ZeroValue) noexcept(std::is_nothrow_move_constructible_v<d_t>)
Expand Down
9 changes: 0 additions & 9 deletions include/phasar/Utils/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,6 @@ constexpr size_t variant_idx = detail::variant_idx<Var, T>::value;

template <typename Container>
using ElementType = typename detail::ElementType<Container>::type;
template <typename T, typename Enable = void>
struct [[deprecated("getAsJson should not be used anymore. Use printAsJson "
"instead")]] has_getAsJson : std::false_type {}; // NOLINT
template <typename T>
struct [[deprecated(
"getAsJson should not be used anymore. Use printAsJson "
"instead")]] has_getAsJson<T, std::void_t<decltype(std::declval<const T>()
.getAsJson())>>
: std::true_type {}; // NOLINT

struct TrueFn {
template <typename... Args>
Expand Down
2 changes: 0 additions & 2 deletions lib/DB/DB.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export module phasar.db;
export namespace psr {
using psr::IRDBGetFunctionDef;
using psr::ProjectIRDB;
using psr::ProjectIRDBBase;
using psr::ProjectIRDBTraits;
using psr::ProjectSymbolTable;

} // namespace psr
1 change: 0 additions & 1 deletion lib/PhasarLLVM/DB/DB.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export module phasar.llvm.db;
export namespace psr {
using psr::fromMetaDataId;
using psr::LLVMProjectIRDB;
using psr::ProjectIRDBTraits;
} // namespace psr
Loading
Loading