From e33f0631d8dcabe65cea4b14b2774123c7da1be9 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <kparzysz@quicinc.com>
Date: Mon, 3 Apr 2023 07:54:32 -0700
Subject: [PATCH] [LLVM] Add guard for #include
 <llvm/Transforms/IPO/PassManagerBuilder.h>

The file llvm/Transforms/IPO/PassManagerBuilder.h has been removed in
LLVM 17, as a part of the transition to the new pass manager. Add a LLVM
version guard around the #include.
---
 src/target/llvm/codegen_amdgpu.cc | 2 ++
 src/target/llvm/codegen_nvptx.cc  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/target/llvm/codegen_amdgpu.cc b/src/target/llvm/codegen_amdgpu.cc
index 327f23af2c73..a177aa7f6828 100644
--- a/src/target/llvm/codegen_amdgpu.cc
+++ b/src/target/llvm/codegen_amdgpu.cc
@@ -42,7 +42,9 @@
 #include <llvm/Support/SourceMgr.h>
 #include <llvm/Support/raw_ostream.h>
 #include <llvm/Target/TargetMachine.h>
+#if TVM_LLVM_VERSION < 170
 #include <llvm/Transforms/IPO/PassManagerBuilder.h>
+#endif
 #include <llvm/Transforms/Utils/Cloning.h>
 #include <tvm/runtime/c_runtime_api.h>
 #include <tvm/runtime/device_api.h>
diff --git a/src/target/llvm/codegen_nvptx.cc b/src/target/llvm/codegen_nvptx.cc
index ec561667c1b0..e64a2dc5b93d 100644
--- a/src/target/llvm/codegen_nvptx.cc
+++ b/src/target/llvm/codegen_nvptx.cc
@@ -45,7 +45,9 @@
 #include <llvm/Support/SourceMgr.h>
 #include <llvm/Support/raw_ostream.h>
 #include <llvm/Target/TargetMachine.h>
+#if TVM_LLVM_VERSION < 170
 #include <llvm/Transforms/IPO/PassManagerBuilder.h>
+#endif
 #include <tvm/runtime/device_api.h>
 
 #include <memory>