Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2aeaf74
Make phasar compile with LLVM 16. One test (DIBasedTypeHierarchyTest)…
fabianbs96 Jun 19, 2025
286979f
Get rid of deprecation warnings due to LLVM 16
fabianbs96 Jul 15, 2025
c47a496
Fix DIBasedTypeHierarchyTest with LLVM 16
fabianbs96 Jul 15, 2025
21e3af0
Merge branch 'development' into f-UpdateLLVM16
fabianbs96 Jul 15, 2025
52a8011
bump llvm version in dependency installation script
fabianbs96 Jul 15, 2025
79c04a4
bump llvm version in bootstrap script
fabianbs96 Jul 15, 2025
5dc64a0
Merge remote-tracking branch 'origin/development' into f-UpdateLLVM16
fabianbs96 Jul 26, 2025
e461a55
Start adding LLVM-17 compatibility
fabianbs96 Jul 26, 2025
6cb0a07
Add some deprecations for LLVM-17 compatibility
fabianbs96 Jul 26, 2025
4190db3
Merge remote-tracking branch 'origin/development' into f-UpdateLLVM16
fabianbs96 Sep 8, 2025
d9c9d16
Fix removal of public Function::getBasicBlockList() in LLVM 16
fabianbs96 Sep 8, 2025
ed66e12
minor
fabianbs96 Sep 8, 2025
acb89bd
Merge remote-tracking branch 'origin/development' into f-UpdateLLVM16
fabianbs96 Sep 8, 2025
b5142d3
Merge remote-tracking branch 'origin/development' into f-UpdateLLVM16
fabianbs96 Sep 23, 2025
5ba97fa
Merge branch 'development' into f-UpdateLLVM16
fabianbs96 Oct 25, 2025
dfe14e7
Fix compilation after merge
fabianbs96 Oct 25, 2025
4b0ffb2
Merge branch 'development' into f-UpdateLLVM16
fabianbs96 Nov 4, 2025
f3639c4
Merge branch 'development' into f-UpdateLLVM16
fabianbs96 Nov 8, 2025
5ba525c
Merge branch 'development' into f-UpdateLLVM16
fabianbs96 Nov 16, 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
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
- name: Build Doxygen Docs
shell: bash
env:
CXX: clang++-15
CC: clang-15
CXX: clang++-16
CC: clang-16
run: |
cmake -S . -B build -DPHASAR_BUILD_DOC=ON
cmake --build ./build --target doc_doxygen
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ option(USE_LLVM_FAT_LIB "Link against libLLVM.so instead of the individual LLVM

# LLVM
if (NOT PHASAR_LLVM_VERSION)
set(PHASAR_LLVM_VERSION 15)
set(PHASAR_LLVM_VERSION 16)
endif()
include(add_llvm)
add_llvm()
Expand Down
4 changes: 2 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ source ./utils/safeCommandsSet.sh

readonly PHASAR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PHASAR_INSTALL_DIR="/usr/local/phasar"
LLVM_INSTALL_DIR="/usr/local/llvm-15"
LLVM_INSTALL_DIR="/usr/local/llvm-16"

NUM_THREADS=$(nproc)
LLVM_RELEASE=llvmorg-15.0.7
LLVM_RELEASE=llvmorg-16.0.6
DO_UNIT_TEST=true
DO_INSTALL=false
BUILD_TYPE=Release
Expand Down
4 changes: 2 additions & 2 deletions cmake/phasar_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function(generate_ll_file)
NAMES clang++-${PHASAR_LLVM_VERSION} clang++
HINTS ${binary_hint_paths})
find_program(opt REQUIRED
NAMES opt-${PHASAR_LLVM_VERSION}4 opt
NAMES opt-${PHASAR_LLVM_VERSION} opt
HINTS ${binary_hint_paths})

set(IS_VALID_VERSION "")
Expand Down Expand Up @@ -212,7 +212,7 @@ function(generate_ll_file)
add_custom_command(
OUTPUT ${test_code_ll_file}
COMMAND ${GEN_CMD} ${test_code_file_path} -o ${test_code_ll_file}
COMMAND ${CMAKE_CXX_COMPILER_LAUNCHER} ${opt} -mem2reg -S ${test_code_ll_file} -o ${test_code_ll_file}
COMMAND ${CMAKE_CXX_COMPILER_LAUNCHER} ${opt} -p mem2reg -S ${test_code_ll_file} -o ${test_code_ll_file}
COMMENT ${GEN_CMD_COMMENT}
DEPENDS ${GEN_LL_FILE}
VERBATIM
Expand Down
1 change: 1 addition & 0 deletions include/phasar/ControlFlow/CallGraphData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define PHASAR_PHASARLLVM_CONTROLFLOW_CALLGRAPHDATA_H

#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ template <typename L, uint8_t N> struct JoinEdgeFunction {
if (const auto *Join = llvm::dyn_cast<JoinEdgeFunction>(EF)) {
return {Join->OtherEF, Join->Seed};
}
return {llvm::makeArrayRef(EF), JLattice::top()};
return {llvm::ArrayRef(EF), JLattice::top()};
};

auto [LVec, LSeed] = GetEFArrayAndSeed(LHS);
Expand Down
33 changes: 25 additions & 8 deletions include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
/// 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 = LLVM_VERSION_MAJOR > 14);
bool EnableOpaquePointers);

/// Initializes the new ProjectIRDB with the given IR Module _without_ taking
/// ownership. The module is optionally being preprocessed.
///
Expand All @@ -68,8 +77,16 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
/// 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);

/// 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 = LLVM_VERSION_MAJOR > 14);
bool EnableOpaquePointers);

LLVMProjectIRDB(const LLVMProjectIRDB &) = delete;
LLVMProjectIRDB &operator=(const LLVMProjectIRDB &) = delete;
Expand All @@ -87,12 +104,12 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
llvm::LLVMContext &Ctx) noexcept;

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

[[nodiscard]] static LLVMProjectIRDB loadOrExit(const llvm::Twine &IRFileName,
int ErrorExitCode = 1);
[[nodiscard]] static LLVMProjectIRDB
loadOrExit(const llvm::Twine &IRFileName,
bool EnableOpaquePointers = LLVM_VERSION_MAJOR > 14,
int ErrorExitCode = 1);
loadOrExit(const llvm::Twine &IRFileName, bool EnableOpaquePointers) = delete;

/// Also use the const overload
using ProjectIRDBBase::getFunction;
Expand Down Expand Up @@ -165,7 +182,7 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/bit.h"

#include <cstdint>
#include <functional>
Expand All @@ -48,7 +48,7 @@ struct IDEFeatureTaintEdgeFact {
}
#endif

llvm::SmallBitVector Ret(llvm::findLastSet(Bits) + 1);
llvm::SmallBitVector Ret(llvm::bit_width(Bits));
Ret.setBitsInMask((const uint32_t *)&Bits, sizeof(Bits));
return Ret;
}
Expand All @@ -62,7 +62,7 @@ struct IDEFeatureTaintEdgeFact {
explicit IDEFeatureTaintEdgeFact() noexcept { Taints.invalid(); }

void unionWith(uintptr_t Facts) {
auto RequiredSize = llvm::findLastSet(Facts) + 1;
size_t RequiredSize = llvm::bit_width(Facts);
if (RequiredSize > Taints.size()) {
Taints.resize(RequiredSize);
}
Expand Down Expand Up @@ -247,7 +247,7 @@ class FeatureTaintGenerator {
FeatureTaintGenerator(EdgeFactGenerator &&EFGen)
: FeatureTaintGenerator(
[EFGen](InstOrGlobal IG) {
return !llvm::empty(std::invoke(EFGen, IG));
return !std::empty(std::invoke(EFGen, IG));
},
std::forward<EdgeFactGenerator>(EFGen)) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/raw_ostream.h"

#include <cmath>
#include <variant>

namespace psr::glca {
Expand Down
2 changes: 2 additions & 0 deletions include/phasar/PhasarLLVM/HelperAnalyses.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "phasar/PhasarLLVM/HelperAnalysisConfig.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasSetData.h"

#include "llvm/ADT/Twine.h"

#include <memory>
#include <optional>
#include <vector>
Expand Down
1 change: 1 addition & 0 deletions include/phasar/PhasarLLVM/Pointer/LLVMAliasSetData.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMALIASSETDATA_H
#define PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMALIASSETDATA_H

#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"

#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMVFTABLEDATA_H_
#define PHASAR_PHASARLLVM_TYPEHIERARCHY_LLVMVFTABLEDATA_H_

#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"

#include <string>
Expand Down
1 change: 1 addition & 0 deletions lib/ControlFlow/CallGraphAnalysisType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ErrorHandling.h"

std::string psr::toString(CallGraphAnalysisType CGA) {
switch (CGA) {
Expand Down
44 changes: 31 additions & 13 deletions lib/PhasarLLVM/DB/LLVMProjectIRDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace psr {

[[deprecated]]
static void setOpaquePointersForCtx(llvm::LLVMContext &Ctx, bool Enable) {
#if LLVM_VERSION_MAJOR >= 15 && LLVM_VERSION_MAJOR < 17
if (!Enable) {
Expand Down Expand Up @@ -115,28 +116,19 @@ LLVMProjectIRDB::getParsedIRModuleOrErr(const llvm::Twine &IRFileName,
}

llvm::ErrorOr<LLVMProjectIRDB>
LLVMProjectIRDB::load(const llvm::Twine &IRFileName,
bool EnableOpaquePointers) {
auto FileOrErr =
llvm::MemoryBuffer::getFileOrSTDIN(IRFileName, /*IsText=*/true);
if (!FileOrErr) {
return FileOrErr.getError();
}

LLVMProjectIRDB::load(const llvm::Twine &IRFileName) {
auto Ctx = std::make_unique<llvm::LLVMContext>();

auto M = getParsedIRModuleOrErr(**FileOrErr, *Ctx);
auto M = getParsedIRModuleOrErr(IRFileName, *Ctx);
if (!M) {
return M.getError();
}

return LLVMProjectIRDB(std::move(*M), std::move(Ctx), EnableOpaquePointers);
return LLVMProjectIRDB(std::move(*M), std::move(Ctx));
}

LLVMProjectIRDB LLVMProjectIRDB::loadOrExit(const llvm::Twine &IRFileName,
bool EnableOpaquePointers,
int ErrorExitCode) {
auto Ret = load(IRFileName, EnableOpaquePointers);
auto Ret = load(IRFileName);
if (!Ret) {
llvm::WithColor::error()
<< "Could not load LLVM-" << LLVM_VERSION_MAJOR << " IR file "
Expand All @@ -147,6 +139,20 @@ LLVMProjectIRDB LLVMProjectIRDB::loadOrExit(const llvm::Twine &IRFileName,
return std::move(*Ret);
}

LLVMProjectIRDB::LLVMProjectIRDB(const llvm::Twine &IRFileName)
: Ctx(new llvm::LLVMContext()) {
auto M = getParsedIRModuleOrErr(IRFileName, *Ctx);

if (!M) {
return;
}

auto *NonConst = M->get();
Mod = std::move(M.get());
ModulesToSlotTracker::setMSTForModule(Mod.get());
preprocessModule(NonConst);
}

LLVMProjectIRDB::LLVMProjectIRDB(const llvm::Twine &IRFileName,
bool EnableOpaquePointers)
: Ctx(new llvm::LLVMContext()) {
Expand Down Expand Up @@ -253,6 +259,18 @@ LLVMProjectIRDB::LLVMProjectIRDB(std::unique_ptr<llvm::Module> Mod,
this->Ctx = std::move(Ctx);
}

LLVMProjectIRDB::LLVMProjectIRDB(llvm::MemoryBufferRef Buf)
: Ctx(new llvm::LLVMContext()) {
auto M = getParsedIRModuleOrErr(Buf, *Ctx);
if (!M) {
return;
}

auto *NonConst = M->get();
Mod = std::move(M.get());
ModulesToSlotTracker::setMSTForModule(Mod.get());
preprocessModule(NonConst);
}
LLVMProjectIRDB::LLVMProjectIRDB(llvm::MemoryBufferRef Buf,
bool EnableOpaquePointers)
: Ctx(new llvm::LLVMContext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ AbstractMemoryLocationImpl::AbstractMemoryLocationImpl(
AbstractMemoryLocationImpl::AbstractMemoryLocationImpl(
const llvm::Value *Baseptr, llvm::SmallVectorImpl<ptrdiff_t> &&Offsets,
unsigned Lifetime) noexcept
: AbstractMemoryLocationImpl(Baseptr, llvm::makeArrayRef(Offsets),
Lifetime) {}
: AbstractMemoryLocationImpl(Baseptr, llvm::ArrayRef(Offsets), Lifetime) {}
AbstractMemoryLocationImpl::AbstractMemoryLocationImpl(
const llvm::Value *Baseptr, llvm::ArrayRef<ptrdiff_t> Offsets,
unsigned Lifetime) noexcept
Expand All @@ -52,7 +51,7 @@ bool AbstractMemoryLocationImpl::isZero() const {
}

llvm::ArrayRef<ptrdiff_t> AbstractMemoryLocationImpl::offsets() const {
return llvm::makeArrayRef(this->getTrailingObjects<ptrdiff_t>(), NumOffsets);
return llvm::ArrayRef(this->getTrailingObjects<ptrdiff_t>(), NumOffsets);
}

auto AbstractMemoryLocationImpl::computeOffset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ IDEExtendedTaintAnalysis::getCallFlowFunction(n_t CallStmt, f_t DestFun) {
/// padding for now.
}
Offs +=
ptrdiff_t(DL.getTypeAllocSize(It->get()->getType()).getFixedSize());
ptrdiff_t(DL.getTypeAllocSize(It->get()->getType()).getFixedValue());
}
#ifdef XTAINT_DIAGNOSTICS
allTaintedValues.insert(ret.begin(), ret.end());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,6 @@ bool EdgeValue::isString() const { return VariantType == String; }

EdgeValue::Type EdgeValue::getKind() const { return VariantType; }

EdgeValue::operator bool() {
switch (VariantType) {
case Integer:
return !std::get<llvm::APInt>(ValVariant).isNullValue();
case FloatingPoint:
return std::get<llvm::APFloat>(ValVariant).isNonZero();
case String:
return !std::get<std::string>(ValVariant).empty();
default:
break;
}
return false;
}

bool operator==(const EdgeValue &Lhs, const EdgeValue &Rhs) {
if (Lhs.VariantType != Rhs.VariantType) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ z3::expr Z3BasedPathSensitivityManagerBase::filterOutUnreachableNodes(
llvm_unreachable("Adj nonempty and Ys empty is unexpected");
}
auto Y = Ys[0];
for (const auto &Constr : llvm::makeArrayRef(Ys).drop_front()) {
for (const auto &Constr : llvm::ArrayRef(Ys).drop_front()) {
Y = Y || Constr;
}
return Ctx.NodeConstraints[Vtx] = (X && Y).simplify();
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/Pointer/LLVMAliasSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void LLVMAliasSet::addPointer(FunctionAliasView AA, const llvm::DataLayout &DL,
Reps[ToMerge[0]]->getType()};
llvm::SmallVector<unsigned> ToRemove;

for (auto Idx : llvm::makeArrayRef(ToMerge).slice(1)) {
for (auto Idx : llvm::ArrayRef(ToMerge).slice(1)) {
mergeAliasSets(PTS, AliasSets[Reps[Idx]]);
if (auto [Unused, Inserted] = OccurringTypes.insert(Reps[Idx]->getType());
!Inserted) {
Expand Down
9 changes: 8 additions & 1 deletion lib/PhasarLLVM/Pointer/LLVMBasedAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool LLVMBasedAliasAnalysis::hasAliasInfo(const llvm::Function &Fun) const {
}

void LLVMBasedAliasAnalysis::computeAliasInfo(llvm::Function &Fun) {
llvm::PreservedAnalyses PA = FPM.run(Fun, FAM);
// llvm::PreservedAnalyses PA = FPM.run(Fun, FAM);
llvm::AAResults &AAR = FAM.getResult<llvm::AAManager>(Fun);
AAInfos.insert(std::make_pair(&Fun, &AAR));
}
Expand Down Expand Up @@ -81,6 +81,7 @@ LLVMBasedAliasAnalysis::LLVMBasedAliasAnalysis(LLVMProjectIRDB &IRDB,
default:
break;
}

// Note: The order of the alias analyses is important. See LLVM's source
// code for reference (e.g. registerAAAnalyses() in
// llvm/CodeGen/CodeGenPassBuilder.h)
Expand All @@ -90,7 +91,13 @@ LLVMBasedAliasAnalysis::LLVMBasedAliasAnalysis(LLVMProjectIRDB &IRDB,
AA.registerFunctionAnalysis<llvm::BasicAA>();
return AA;
});

PB.registerFunctionAnalyses(FAM);
if (PATy == AliasAnalysisType::CFLAnders) {
FAM.registerPass([] { return llvm::CFLAndersAA(); });
} else if (PATy == AliasAnalysisType::CFLSteens) {
FAM.registerPass([] { return llvm::CFLSteensAA(); });
}

if (!UseLazyEvaluation) {
for (auto &F : *IRDB.getModule()) {
Expand Down
4 changes: 2 additions & 2 deletions lib/PhasarLLVM/Pointer/external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
All files in the `llvm` subfolder are 1:1 copied from LLVM 14.0.6 and are subject to the LLVM license.
You can find a copy of the LLVM license [here](./LLVM-LICENSE.txt).

Note that we needed to copy these files, as LLVM removed them in the transition from version 14 to 15.
Note that we needed to copy these files, as LLVM removed them in the transition from version 14 to more recent LLVM versions.
To avoid LLVM from blocking PhASAR releases, we provide these files ourselves as a *temporary solution*.

We, as the PhASAR development core team, do not aim for maintaining the here provided LLVM code and will not add any modifications to it (bugfixes, enhancements, etc.).
We, as the PhASAR development core team, do not aim for maintaining the here provided LLVM code and will not add any modifications to it, except for compilation fixes when changing the LLVM version (bugfixes, enhancements, etc.).
Rather, we will add a custom replacement eventually.
Loading
Loading