diff --git a/lib/bap_llvm/llvm_disasm.cpp b/lib/bap_llvm/llvm_disasm.cpp index 41f9bb64f..2834fad24 100644 --- a/lib/bap_llvm/llvm_disasm.cpp +++ b/lib/bap_llvm/llvm_disasm.cpp @@ -37,7 +37,11 @@ #include #include +#if LLVM_VERSION_MAJOR >= 17 +#include +#else #include +#endif #include template @@ -464,7 +468,12 @@ class llvm_disassembler : public disassembler_interface { } else if (p == is_true) { return true; } else { +#if LLVM_VERSION_MAJOR >= 17 + // 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 +661,7 @@ struct create_llvm_disassembler : disasm_factory { static void parse_environment_options(const char *prog_name, const char *env_var) { #if LLVM_VERSION_MAJOR >= 12 - llvm::Optional env_value = llvm::sys::Process::GetEnv(llvm::StringRef(env_var)); + auto env_value = llvm::sys::Process::GetEnv(llvm::StringRef(env_var)); 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"