Fix a llvm compilation error
authorYonghong Song <yhs@fb.com>
Sun, 27 Nov 2022 01:41:33 +0000 (17:41 -0800)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 22 Feb 2024 14:17:55 +0000 (15:17 +0100)
With latest llvm16, I got the following compilation error:
  /.../src/cc/bpf_module.cc: In member function ‘void ebpf::BPFModule::dump_ir(llvm::Module&)’:
  /.../src/cc/bpf_module.cc:259:15: error: ‘PrintModulePass’ was not declared in this scope
     MPM.addPass(PrintModulePass(errs()));
                 ^~~~~~~~~~~~~~~
  ...

The error is due to the llvm patch https://reviews.llvm.org/D138081.
Fix the issue by adjust corresponding header file locaiton
as in the above llvm patch.

Signed-off-by: Yonghong Song <yhs@fb.com>
src/cc/bpf_module.cc

index 97f4518c838ec7f86753b0ae00a9652c94c5f97d..f48df7af244ce9e101555d76aac3bae09fcbe390 100644 (file)
 
 #include <llvm/ExecutionEngine/MCJIT.h>
 #include <llvm/ExecutionEngine/SectionMemoryManager.h>
+#if LLVM_MAJOR_VERSION >= 16
+#include <llvm/IRPrinter/IRPrintingPasses.h>
+#else
 #include <llvm/IR/IRPrintingPasses.h>
+#endif
 #include <llvm/IR/LLVMContext.h>
 #include <llvm/IR/Module.h>