From d3ab117c837e537fe0b7077bb9e4c3f018153945 Mon Sep 17 00:00:00 2001
Message-ID: <d3ab117c837e537fe0b7077bb9e4c3f018153945.1700681619.git.kai@dev.carbon-project.org>
From: =?UTF-8?q?Kai=20Wasserb=C3=A4ch?= <kai@dev.carbon-project.org>
Date: Wed, 22 Nov 2023 20:21:11 +0100
Subject: [PATCH] fix: ac/llvm: LLVM 18_ do not use llvm::createLoopSinkPass(),
 removed upstream
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There is no alternative named in upstream commit
<https://github.com/llvm/llvm-project/commit/b9975cec0ea0a2f10d65b7bd1197d9e1706cbd3d>,
that removes the legacy pass, therefore this commit should be considered
a workaround.

Workaround-for: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10192
Reference: https://github.com/llvm/llvm-project/pull/72811
Reference: https://github.com/llvm/llvm-project/commit/b9975cec0ea0a2f10d65b7bd1197d9e1706cbd3d
Signed-off-by: Kai Wasserbäch <kai@dev.carbon-project.org>
---
 src/amd/llvm/ac_llvm_helper.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/amd/llvm/ac_llvm_helper.cpp b/src/amd/llvm/ac_llvm_helper.cpp
index 40a4399e705..b995152ee36 100644
--- a/src/amd/llvm/ac_llvm_helper.cpp
+++ b/src/amd/llvm/ac_llvm_helper.cpp
@@ -307,8 +307,9 @@ LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_library_inf
    unwrap(passmgr)->add(createSROAPass());
    #endif
    /* TODO: restore IPSCCP */
-   if (LLVM_VERSION_MAJOR >= 16)
+   #if LLVM_VERSION_MAJOR >= 16 && LLVM_VERSION_MAJOR < 18
       unwrap(passmgr)->add(createLoopSinkPass());
+   #endif
    /* TODO: restore IPSCCP */
    unwrap(passmgr)->add(createLICMPass());
    unwrap(passmgr)->add(createCFGSimplificationPass());
-- 
2.42.0

