Skip to content

Commit 6326dc9

Browse files
authored
Update LLVM to 16 (#793)
* Make phasar compile with LLVM 16. One test (DIBasedTypeHierarchyTest) still fails * Get rid of deprecation warnings due to LLVM 16 * Fix DIBasedTypeHierarchyTest with LLVM 16 * bump llvm version in dependency installation script * bump llvm version in bootstrap script TODO: The bootstrap script urgently needs to be updated! (see the different ways of installing llvm/boost, etc.) * Start adding LLVM-17 compatibility * Add some deprecations for LLVM-17 compatibility * Fix removal of public Function::getBasicBlockList() in LLVM 16 * minor * Fix compilation after merge
1 parent eec9fbb commit 6326dc9

34 files changed

+289
-229
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
- name: Build Doxygen Docs
2929
shell: bash
3030
env:
31-
CXX: clang++-15
32-
CC: clang-15
31+
CXX: clang++-16
32+
CC: clang-16
3333
run: |
3434
cmake -S . -B build -DPHASAR_BUILD_DOC=ON
3535
cmake --build ./build --target doc_doxygen

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ option(USE_LLVM_FAT_LIB "Link against libLLVM.so instead of the individual LLVM
335335

336336
# LLVM
337337
if (NOT PHASAR_LLVM_VERSION)
338-
set(PHASAR_LLVM_VERSION 15)
338+
set(PHASAR_LLVM_VERSION 16)
339339
endif()
340340
include(add_llvm)
341341
add_llvm()

bootstrap.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ source ./utils/safeCommandsSet.sh
66

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

1111
NUM_THREADS=$(nproc)
12-
LLVM_RELEASE=llvmorg-15.0.7
12+
LLVM_RELEASE=llvmorg-16.0.6
1313
DO_UNIT_TEST=true
1414
DO_INSTALL=false
1515
BUILD_TYPE=Release

cmake/phasar_macros.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function(generate_ll_file)
8686
NAMES clang++-${PHASAR_LLVM_VERSION} clang++
8787
HINTS ${binary_hint_paths})
8888
find_program(opt REQUIRED
89-
NAMES opt-${PHASAR_LLVM_VERSION}4 opt
89+
NAMES opt-${PHASAR_LLVM_VERSION} opt
9090
HINTS ${binary_hint_paths})
9191

9292
set(IS_VALID_VERSION "")
@@ -212,7 +212,7 @@ function(generate_ll_file)
212212
add_custom_command(
213213
OUTPUT ${test_code_ll_file}
214214
COMMAND ${GEN_CMD} ${test_code_file_path} -o ${test_code_ll_file}
215-
COMMAND ${CMAKE_CXX_COMPILER_LAUNCHER} ${opt} -mem2reg -S ${test_code_ll_file} -o ${test_code_ll_file}
215+
COMMAND ${CMAKE_CXX_COMPILER_LAUNCHER} ${opt} -p mem2reg -S ${test_code_ll_file} -o ${test_code_ll_file}
216216
COMMENT ${GEN_CMD_COMMENT}
217217
DEPENDS ${GEN_LL_FILE}
218218
VERBATIM

include/phasar/ControlFlow/CallGraphData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define PHASAR_PHASARLLVM_CONTROLFLOW_CALLGRAPHDATA_H
1212

1313
#include "llvm/ADT/StringRef.h"
14+
#include "llvm/ADT/Twine.h"
1415
#include "llvm/Support/raw_ostream.h"
1516

1617
#include <string>

include/phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ template <typename L, uint8_t N> struct JoinEdgeFunction {
351351
if (const auto *Join = llvm::dyn_cast<JoinEdgeFunction>(EF)) {
352352
return {Join->OtherEF, Join->Seed};
353353
}
354-
return {llvm::makeArrayRef(EF), JLattice::top()};
354+
return {llvm::ArrayRef(EF), JLattice::top()};
355355
};
356356

357357
auto [LVec, LSeed] = GetEFArrayAndSeed(LHS);

include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
4545
/// Reads and parses the given LLVM IR file and owns the resulting IR Module.
4646
/// If an error occurs, an error message is written to stderr and subsequent
4747
/// calls to isValid() return false.
48+
explicit LLVMProjectIRDB(const llvm::Twine &IRFileName);
49+
50+
/// Reads and parses the given LLVM IR file and owns the resulting IR Module.
51+
/// If an error occurs, an error message is written to stderr and subsequent
52+
/// calls to isValid() return false.
53+
[[deprecated("When moving to the next LLVM version, opaque pointers support "
54+
"is removed completely. Please use one of the other "
55+
"constructors of LLVMProjectIRDB.")]]
4856
explicit LLVMProjectIRDB(const llvm::Twine &IRFileName,
49-
bool EnableOpaquePointers = LLVM_VERSION_MAJOR > 14);
57+
bool EnableOpaquePointers);
58+
5059
/// Initializes the new ProjectIRDB with the given IR Module _without_ taking
5160
/// ownership. The module is optionally being preprocessed.
5261
///
@@ -68,8 +77,16 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
6877
/// Parses the given LLVM IR file and owns the resulting IR Module.
6978
/// If an error occurs, an error message is written to stderr and subsequent
7079
/// calls to isValid() return false.
80+
explicit LLVMProjectIRDB(llvm::MemoryBufferRef Buf);
81+
82+
/// Parses the given LLVM IR file and owns the resulting IR Module.
83+
/// If an error occurs, an error message is written to stderr and subsequent
84+
/// calls to isValid() return false.
85+
[[deprecated("When moving to the next LLVM version, opaque pointers support "
86+
"is removed completely. Please use one of the other "
87+
"constructors of LLVMProjectIRDB.")]]
7188
explicit LLVMProjectIRDB(llvm::MemoryBufferRef Buf,
72-
bool EnableOpaquePointers = LLVM_VERSION_MAJOR > 14);
89+
bool EnableOpaquePointers);
7390

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

89106
[[nodiscard]] static llvm::ErrorOr<LLVMProjectIRDB>
90-
load(const llvm::Twine &IRFileName,
91-
bool EnableOpaquePointers = LLVM_VERSION_MAJOR > 14);
107+
load(const llvm::Twine &IRFileName);
108+
109+
[[nodiscard]] static LLVMProjectIRDB loadOrExit(const llvm::Twine &IRFileName,
110+
int ErrorExitCode = 1);
92111
[[nodiscard]] static LLVMProjectIRDB
93-
loadOrExit(const llvm::Twine &IRFileName,
94-
bool EnableOpaquePointers = LLVM_VERSION_MAJOR > 14,
95-
int ErrorExitCode = 1);
112+
loadOrExit(const llvm::Twine &IRFileName, bool EnableOpaquePointers) = delete;
96113

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

166183
[[nodiscard]] auto getAllInstructionsImpl() const noexcept {
167184
return llvm::map_range(
168-
llvm::makeArrayRef(IdToInst).drop_front(IdOffset),
185+
llvm::ArrayRef(IdToInst).drop_front(IdOffset),
169186
[](const llvm::Value *V) { return llvm::cast<llvm::Instruction>(V); });
170187
}
171188

include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEFeatureTaintAnalysis.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include "phasar/Utils/TypeTraits.h"
2323

2424
#include "llvm/ADT/FunctionExtras.h"
25-
#include "llvm/ADT/STLExtras.h"
2625
#include "llvm/ADT/SmallBitVector.h"
26+
#include "llvm/ADT/bit.h"
2727

2828
#include <cstdint>
2929
#include <functional>
@@ -48,7 +48,7 @@ struct IDEFeatureTaintEdgeFact {
4848
}
4949
#endif
5050

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

6464
void unionWith(uintptr_t Facts) {
65-
auto RequiredSize = llvm::findLastSet(Facts) + 1;
65+
size_t RequiredSize = llvm::bit_width(Facts);
6666
if (RequiredSize > Taints.size()) {
6767
Taints.resize(RequiredSize);
6868
}
@@ -247,7 +247,7 @@ class FeatureTaintGenerator {
247247
FeatureTaintGenerator(EdgeFactGenerator &&EFGen)
248248
: FeatureTaintGenerator(
249249
[EFGen](InstOrGlobal IG) {
250-
return !llvm::empty(std::invoke(EFGen, IG));
250+
return !std::empty(std::invoke(EFGen, IG));
251251
},
252252
std::forward<EdgeFactGenerator>(EFGen)) {}
253253

include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCA/EdgeValue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/Support/raw_os_ostream.h"
1919
#include "llvm/Support/raw_ostream.h"
2020

21+
#include <cmath>
2122
#include <variant>
2223

2324
namespace psr::glca {

include/phasar/PhasarLLVM/HelperAnalyses.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "phasar/PhasarLLVM/HelperAnalysisConfig.h"
1616
#include "phasar/PhasarLLVM/Pointer/LLVMAliasSetData.h"
1717

18+
#include "llvm/ADT/Twine.h"
19+
1820
#include <memory>
1921
#include <optional>
2022
#include <vector>

0 commit comments

Comments
 (0)