diff --git a/lib/bap_llvm/llvm_disasm.cpp b/lib/bap_llvm/llvm_disasm.cpp index 41f9bb64f..1aefbe63a 100644 --- a/lib/bap_llvm/llvm_disasm.cpp +++ b/lib/bap_llvm/llvm_disasm.cpp @@ -27,9 +27,10 @@ #include #include -#include -#include #include +#if LLVM_VERSION_MAJOR >= 16 +#include +#endif #include "disasm.hpp" #include "llvm_disasm.h" @@ -37,7 +38,11 @@ #include #include +#if LLVM_VERSION_MAJOR >= 17 +#include +#else #include +#endif #include template @@ -464,7 +469,12 @@ class llvm_disassembler : public disassembler_interface { } else if (p == is_true) { return true; } else { +#if LLVM_VERSION_MAJOR >= 16 + // MCInstrDesc needs to know its own address to access some implicit tables. + auto &d = ins_info->get(current.code); +#else auto d = ins_info->get(current.code); +#endif if (p == may_affect_control_flow) { return d.mayAffectControlFlow(mcinst, *reg_info); } else if (auto check = fun_of_pred(p)) { @@ -652,7 +662,11 @@ struct create_llvm_disassembler : disasm_factory { static void parse_environment_options(const char *prog_name, const char *env_var) { #if LLVM_VERSION_MAJOR >= 12 +#if LLVM_VERSION_MAJOR >= 16 + std::optional env_value = llvm::sys::Process::GetEnv(llvm::StringRef(env_var)); +#else llvm::Optional env_value = llvm::sys::Process::GetEnv(llvm::StringRef(env_var)); +#endif if (!env_value) return; diff --git a/lib/bap_llvm/llvm_loader_utils.hpp b/lib/bap_llvm/llvm_loader_utils.hpp index 286203265..39b8ae230 100644 --- a/lib/bap_llvm/llvm_loader_utils.hpp +++ b/lib/bap_llvm/llvm_loader_utils.hpp @@ -5,7 +5,11 @@ #include #include +#if LLVM_VERSION_MAJOR >= 17 +#include +#else #include +#endif #include "llvm_error_or.hpp" diff --git a/lib/bap_llvm/llvm_primitives.cpp b/lib/bap_llvm/llvm_primitives.cpp index 460376e79..2698dfd7b 100644 --- a/lib/bap_llvm/llvm_primitives.cpp +++ b/lib/bap_llvm/llvm_primitives.cpp @@ -1,6 +1,11 @@ #include +#include +#if LLVM_VERSION_MAJOR >= 17 +#include +#else #include +#endif #include "llvm_primitives.hpp"