From f79617fe804ea6524651ff1bc3a91098d3199179 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= <marek.olsak@amd.com>
Date: Mon, 25 Sep 2023 15:57:33 -0400
Subject: [PATCH] amd/llvm: fix build with LLVM 18
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25388>
---
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 5e7a30a6cc2e3..e213f7e4be180 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -366,7 +366,11 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
builder.setEngineKind(EngineKind::JIT)
.setErrorStr(&Error)
.setTargetOptions(options)
+#if LLVM_VERSION_MAJOR >= 18
+ .setOptLevel((CodeGenOptLevel)OptLevel);
+#else
.setOptLevel((CodeGenOpt::Level)OptLevel);
+#endif
#if DETECT_OS_WINDOWS
/*
--
GitLab
<!DOCTYPE html>
<html class="gl-light ui-neutral with-header with-top-bar " lang="en">
<head prefix="og: http://ogp.me/ns#">
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>gallivm: handle llvm 16 atexit ordering problems. (b3cfec2f) · Commits · Mesa / mesa · GitLab</title>
<script>
//<![CDATA[
window.gon={};gon.math_rendering_limits_enabled=true;gon.features={"ciGraphqlPipelineMiniGraph":false};
//]]>
</script>
<link rel="stylesheet" href="/assets/application-bc8000290bc8c8c0ebadb5c9d96dac50df8244426ef375a23cfae334e9b100c2.css" media="all" />
<link rel="stylesheet" href="/assets/page_bundles/pipelines-147f0c35e12b857600d63ad57bd1505da553bee448fee17c49459845401fed79.css" media="all" /><link rel="stylesheet" href="/assets/page_bundles/commit_description-5653213c51a6c90453a926cfc5e5e71ad9b41881a20a408bef8a303cf175435c.css" media="all" /><link rel="stylesheet" href="/assets/page_bundles/work_items-4dbc32cca030ff7727ba26485149518edc039e72f1577ef00291805720518949.css" media="all" />
<link rel="stylesheet" href="/assets/application_utilities-d9a7b82eeacf5bfb8ceea81780b391ff56bc5b4332509ae17839f3590bce0ae9.css" media="all" />
<link rel="stylesheet" href="/assets/tailwind-c4fd78b89a0e3b72cbd08ce282e35067bb563355705f68ef5cb893962ccc7c32.css" media="all" />
<link rel="stylesheet" href="/assets/fonts-fae5d3f79948bd85f18b6513a025f863b19636e85b09a1492907eb4b1bb0557b.css" media="all" />
<link rel="stylesheet" href="/assets/highlight/themes/white-2ffecda73965655b02849f077e67509c64f03bf7959a10ee45a0147e79ab96fd.css" media="all" />
<link rel="preload" href="/assets/application_utilities-d9a7b82eeacf5bfb8ceea81780b391ff56bc5b4332509ae17839f3590bce0ae9.css" as="style" type="text/css">
<link rel="preload" href="/assets/application-bc8000290bc8c8c0ebadb5c9d96dac50df8244426ef375a23cfae334e9b100c2.css" as="style" type="text/css">
<link rel="preload" href="/assets/highlight/themes/white-2ffecda73965655b02849f077e67509c64f03bf7959a10ee45a0147e79ab96fd.css" as="style" type="text/css">
<script src="/assets/webpack/runtime.c3b445fb.bundle.js" defer="defer"></script>
<script src="/assets/webpack/main.aa8f43d1.chunk.js" defer="defer"></script>
<script src="/assets/webpack/graphql.e1f11a07.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.abuse_reports.show-pages.dashboard.issues-pages.dashboard.milestones.show-pages.-a65b27a2.97e0c257.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.abuse_reports.show-pages.dashboard.issues-pages.groups.boards-pages.groups.issue-8f3ec9c9.450d024d.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.abuse_reports.show-pages.dashboard.issues-pages.groups.boards-pages.groups.issue-181be4cb.80f39b87.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.groups.new-pages.import.gitlab_projects.new-pages.import.manifest.new-pages.projects.n-44c6c18e.227a132b.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.search.show-super_sidebar.4ea731a1.chunk.js" defer="defer"></script>
<script src="/assets/webpack/super_sidebar.ed4df32c.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.abuse_reports.show-pages.admin.topics.edit-pages.admin.topics.new-pages.dashboar-7469413d.4f86d3e8.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.abuse_reports.show-pages.admin.topics.edit-pages.admin.topics.new-pages.groups.i-56cf042c.01ecb85c.chunk.js" defer="defer"></script>
<script src="/assets/webpack/8.788661b8.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.abuse_reports.show-pages.admin.topics.edit-pages.admin.topics.new-pages.groups.i-79e94350.81fd5681.chunk.js" defer="defer"></script>
<script src="/assets/webpack/10.abcd7097.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.abuse_reports.show-pages.admin.topics.edit-pages.admin.topics.new-pages.groups.i-aa2a43bd.1d1306c9.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.admin.topics.edit-pages.admin.topics.new-pages.groups.milestones.edit-pages.groups.mil-d4098e09.740ed42b.chunk.js" defer="defer"></script>
<script src="/assets/webpack/26.3e8521dc.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.groups.milestones.edit-pages.groups.milestones.new-pages.groups.milestones.show-pages.-3a9ea570.d48dcdaa.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.projects.commit.pipelines-pages.projects.commit.rapid_diffs-pages.projects.commit.show.c0025a99.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.projects.commit.show-pages.projects.snippets.show-pages.snippets.show.cf9cdece.chunk.js" defer="defer"></script>
<script src="/assets/webpack/commons-pages.projects.commit.show-pages.projects.compare.show-pages.projects.wikis.diff.14466c81.chunk.js" defer="defer"></script>
<script src="/assets/webpack/pages.projects.commit.show.67c9270a.chunk.js" defer="defer"></script>
<meta content="object" property="og:type">
<meta content="GitLab" property="og:site_name">
<meta content="gallivm: handle llvm 16 atexit ordering problems. (b3cfec2f) · Commits · Mesa / mesa · GitLab" property="og:title">
<meta content="This is ported from amd ac_llvm_helper.cpp, thanks to Marek for the pointer. This is needed to avoid crashes due to atexit ordering between some piglit tests and mesa internals. Cc:..." property="og:description">
<meta content="https://gitlab.freedesktop.org/uploads/-/system/project/avatar/176/gears.png" property="og:image">
<meta content="64" property="og:image:width">
<meta content="64" property="og:image:height">
<meta content="https://gitlab.freedesktop.org/mesa/mesa/-/commit/b3cfec2fd824a52023c92fd5928f4f5c1cb449a0" property="og:url">
<meta content="summary" property="twitter:card">
<meta content="gallivm: handle llvm 16 atexit ordering problems. (b3cfec2f) · Commits · Mesa / mesa · GitLab" property="twitter:title">
<meta content="This is ported from amd ac_llvm_helper.cpp, thanks to Marek for the pointer. This is needed to avoid crashes due to atexit ordering between some piglit tests and mesa internals. Cc:..." property="twitter:description">
<meta content="https://gitlab.freedesktop.org/uploads/-/system/project/avatar/176/gears.png" property="twitter:image">
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="AioFgsl_omxJZyl5Q2D4GnKiXe47UFUKYPQW0znQbNIsHTFW0Bd4XCkZo8p5Pmlez7T9muUsVHMfGUAj9SBU6g" />
<meta name="csp-nonce" />
<meta name="action-cable-url" content="/-/cable" />
<link href="/-/manifest.json" rel="manifest">
<link rel="icon" type="image/png" href="/uploads/-/system/appearance/favicon/1/fdo-favicon.ico" id="favicon" data-original-href="/uploads/-/system/appearance/favicon/1/fdo-favicon.ico" />
<link rel="apple-touch-icon" type="image/x-icon" href="/assets/apple-touch-icon-b049d4bc0dd9626f31db825d61880737befc7835982586d015bded10b4435460.png" />
<link href="/search/opensearch.xml" rel="search" title="Search GitLab" type="application/opensearchdescription+xml">
<meta content="This is ported from amd ac_llvm_helper.cpp, thanks to Marek for the pointer. This is needed to avoid crashes due to atexit ordering between some piglit tests and mesa internals. Cc:..." name="description">
<meta content="#ececef" name="theme-color">
</head>
<body class="tab-width-8 gl-browser-generic gl-platform-other " data-find-file="/mesa/mesa/-/find_file/b3cfec2fd824a52023c92fd5928f4f5c1cb449a0" data-group="mesa" data-group-full-path="mesa" data-namespace-id="1155" data-page="projects:commit:show" data-page-type-id="b3cfec2fd824a52023c92fd5928f4f5c1cb449a0" data-project="mesa" data-project-full-path="mesa/mesa" data-project-id="176">
<script>
//<![CDATA[
gl = window.gl || {};
gl.GfmAutoComplete = gl.GfmAutoComplete || {};
gl.GfmAutoComplete.dataSources = {"members":"/mesa/mesa/-/autocomplete_sources/members?type=Commit\u0026type_id=b3cfec2fd824a52023c92fd5928f4f5c1cb449a0","issues":"/mesa/mesa/-/autocomplete_sources/issues","mergeRequests":"/mesa/mesa/-/autocomplete_sources/merge_requests","labels":"/mesa/mesa/-/autocomplete_sources/labels?type=Commit\u0026type_id=b3cfec2fd824a52023c92fd5928f4f5c1cb449a0","milestones":"/mesa/mesa/-/autocomplete_sources/milestones","commands":"/mesa/mesa/-/autocomplete_sources/commands?type=Commit\u0026type_id=b3cfec2fd824a52023c92fd5928f4f5c1cb449a0","snippets":"/mesa/mesa/-/autocomplete_sources/snippets","contacts":"/mesa/mesa/-/autocomplete_sources/contacts?type=Commit\u0026type_id=b3cfec2fd824a52023c92fd5928f4f5c1cb449a0","wikis":null};
//]]>
</script>
<script>
//<![CDATA[
gl = window.gl || {};
gl.client = {"isGeneric":true,"isOther":true};
//]]>
</script>
<header class="header-logged-out" data-testid="navbar">
<a class="gl-sr-only gl-accessibility" href="#content-body">Skip to content</a>
<div class="container-fluid">
<nav aria-label="Explore GitLab" class="header-logged-out-nav gl-display-flex gl-gap-3 gl-justify-content-space-between">
<div class="gl-display-flex gl-align-items-center gl-gap-1">
<span class="gl-sr-only">GitLab</span>
<a title="Homepage" id="logo" class="header-logged-out-logo has-tooltip" aria-label="Homepage" href="/"><img class="brand-header-logo lazy" alt="" data-src="/uploads/-/system/appearance/header_logo/1/fdo-logo-header.png" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" />
</a></div>
<ul class="gl-list-none gl-p-0 gl-m-0 gl-display-flex gl-gap-3 gl-align-items-center gl-flex-grow-1">
<li class="header-logged-out-nav-item">
<a class="" href="/explore">Explore</a>
</li>
</ul>
<ul class="gl-list-none gl-p-0 gl-m-0 gl-display-flex gl-gap-3 gl-align-items-center gl-justify-content-end">
<li class="header-logged-out-nav-item">
<a href="/users/sign_in?redirect_to_referer=yes">Sign in</a>
</li>
<li class="header-logged-out-nav-item">
<a class="gl-button btn btn-md btn-confirm " href="/users/sign_up"><span class="gl-button-text">
Register
</span>
</a></li>
</ul>
</nav>
</div>
</header>
<div class="layout-page page-with-super-sidebar">
<aside class="js-super-sidebar super-sidebar super-sidebar-loading" data-command-palette="{"project_files_url":"/mesa/mesa/-/files/b3cfec2fd824a52023c92fd5928f4f5c1cb449a0?format=json","project_blob_url":"/mesa/mesa/-/blob/b3cfec2fd824a52023c92fd5928f4f5c1cb449a0"}" data-force-desktop-expanded-sidebar="" data-root-path="/" data-sidebar="{"is_logged_in":false,"context_switcher_links":[{"title":"Explore","link":"/explore","icon":"compass"}],"current_menu_items":[{"id":"project_overview","title":"mesa","icon":null,"avatar":"/uploads/-/system/project/avatar/176/gears.png","entity_id":176,"link":"/mesa/mesa","pill_count":null,"link_classes":"shortcuts-project","is_active":false},{"id":"manage_menu","title":"Manage","icon":"users","avatar":null,"avatar_shape":"rect","entity_id":null,"link":"/mesa/mesa/activity","is_active":false,"pill_count":null,"items":[{"id":"activity","title":"Activity","icon":null,"avatar":null,"entity_id":null,"link":"/mesa/mesa/activity","pill_count":null,"link_classes":"shortcuts-project-activity","is_active":false},{"id":"members","title":"Members","icon":null,"avatar":null,"entity_id":null,"link":"/mesa/mesa/-/project_members","pill_count":null,"link_classes":null,"is_active":false},{"id":"labels","title":"Labels","icon":null,"avatar":null,"entity_id":null,"link":"/mesa/mesa/-/labels","pill_count":null,"link_classes":null,"is_active":false}],"separated":false},{"id":"plan_menu","title":"Plan","icon":"planning","avatar":null,"avatar_shape":"rect","entity_id":null,"link":"/mesa/mesa/-/issues","is_active":false,"pill_count":null,"items":[{"id":"project_issue_list","title":"Issues","icon":null,"avatar":null,"entity_id":null,"link":"/mesa/mesa/-/issues","pill_count":"3.7k","link_classes":"shortcuts-issues has-sub-items","is_active":false},{"id":"boards","title":"Issue boards","icon":null,"avatar":null,"entity_id":null,"link":"/mesa/mesa/-/boards","pill_count":null,"link_classes":"shortcuts-issue-boards","is_active":false},{"id":"milestones","title":"Milestones","icon":null,"avatar":null,"entity_id":null,"link":"/mesa/mesa/-/milestones","pill_count":null,"link_classes":null,"is_active":false}],"separated":false},{"id":"code_menu","title":"Code","icon":"code","avatar":null,"avatar_shape":"rect","entity_id":null,"link":"/mesa/mesa/-/merge_requests","is_active":true,"pill_count":null,"items":[{"id":"project_merge_request_list","title":"Merge requests","icon":nFrom b3cfec2fd824a52023c92fd5928f4f5c1cb449a0 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Thu, 4 Jan 2024 06:17:50 +1000
Subject: [PATCH] gallivm: handle llvm 16 atexit ordering problems.
This is ported from amd ac_llvm_helper.cpp, thanks to Marek for the pointer.
This is needed to avoid crashes due to atexit ordering between some piglit
tests and mesa internals.
Cc: mesa-stable
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26883>
---
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index e213f7e4be180..a5e84d708f2c6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -62,6 +62,7 @@
#include <llvm/Support/PrettyStackTrace.h>
#include <llvm/ExecutionEngine/ObjectCache.h>
#include <llvm/Support/TargetSelect.h>
+#include <llvm/CodeGen/SelectionDAGNodes.h>
#if LLVM_VERSION_MAJOR >= 15
#include <llvm/Support/MemoryBuffer.h>
#endif
@@ -100,6 +101,8 @@
#include "lp_bld_misc.h"
#include "lp_bld_debug.h"
+static void lp_run_atexit_for_destructors(void);
+
namespace {
class LLVMEnsureMultithreaded {
@@ -147,6 +150,7 @@ static void init_native_targets()
}
}
#endif
+ lp_run_atexit_for_destructors();
}
extern "C" void
@@ -623,3 +627,33 @@ lp_set_module_stack_alignment_override(LLVMModuleRef MRef, unsigned align)
M->setOverrideStackAlignment(align);
#endif
}
+
+using namespace llvm;
+
+class GallivmRunAtExitForStaticDestructors : public SDNode
+{
+public:
+ /* getSDVTList (protected) calls getValueTypeList (private), which contains static variables. */
+ GallivmRunAtExitForStaticDestructors(): SDNode(0, 0, DebugLoc(), getSDVTList(MVT::Other))
+ {
+ }
+};
+
+static void
+lp_run_atexit_for_destructors(void)
+{
+ /* LLVM >= 16 registers static variable destructors on the first compile, which gcc
+ * implements by calling atexit there. Before that, u_queue registers its atexit
+ * handler to kill all threads. Since exit() runs atexit handlers in the reverse order,
+ * the LLVM destructors are called first while shader compiler threads may still be
+ * running, which crashes in LLVM in SelectionDAG.cpp.
+ *
+ * The solution is to run the code that declares the LLVM static variables first,
+ * so that atexit for LLVM is registered first and u_queue is registered after that,
+ * which ensures that all u_queue threads are terminated before LLVM destructors are
+ * called.
+ *
+ * This just executes the code that declares static variables.
+ */
+ GallivmRunAtExitForStaticDestructors();
+}
--
GitLab
From 550cc685a76b609a3c3f358d554de6e9911510ec Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Thu, 18 Jan 2024 18:05:47 +1000
Subject: [PATCH] gallivm: fix coroutines with llvm 18
llvm 18 added an extra parameters to coro end which should just
take a null token always for us.
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27133>
---
src/gallium/auxiliary/gallivm/lp_bld_coro.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_coro.c b/src/gallium/auxiliary/gallivm/lp_bld_coro.c
index 0214dcf674203..75aaa7d2b84c9 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_coro.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_coro.c
@@ -89,13 +89,18 @@ LLVMValueRef lp_build_coro_free(struct gallivm_state *gallivm,
void lp_build_coro_end(struct gallivm_state *gallivm, LLVMValueRef coro_hdl)
{
- LLVMValueRef coro_end_args[2];
+ LLVMValueRef coro_end_args[3];
+ int num_args = 2;
coro_end_args[0] = coro_hdl;
coro_end_args[1] = LLVMConstInt(LLVMInt1TypeInContext(gallivm->context), 0, 0);
+#if LLVM_VERSION_MAJOR >= 18
+ coro_end_args[2] = LLVMConstNull(LLVMTokenTypeInContext(gallivm->context));
+ num_args++;
+#endif
lp_build_intrinsic(gallivm->builder,
"llvm.coro.end",
LLVMInt1TypeInContext(gallivm->context),
- coro_end_args, 2, 0);
+ coro_end_args, num_args, 0);
}
void lp_build_coro_resume(struct gallivm_state *gallivm, LLVMValueRef coro_hdl)
--
GitLab
From 99f0449987bec1f82cd42a06f40bb4a863a37792 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov@redhat.com>
Date: Mon, 11 Mar 2024 14:45:41 +0100
Subject: [PATCH] Pass no-verify-fixpoint option to instcombine in LLVM 18
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When LLVM 18 is used, pass the no-verify-fixpoint option when
running the instcombine pass. Otherwise LLVM may abort with an
error.
The background here is that this option is enabled by default for
testing purposes, because instcombine is normally only explicitly
invoked like this inside tests. If it is used in an actual
production pipeline, the no-verify-fixpoint option needs to be
enabled.
This should fix the issue reported at
https://bugzilla.redhat.com/show_bug.cgi?id=2268800.
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28101>
---
src/gallium/auxiliary/gallivm/lp_bld_init.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index cd2108f3a088d..1345d85b22439 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -609,7 +609,11 @@ gallivm_compile_module(struct gallivm_state *gallivm)
LLVMRunPasses(gallivm->module, passes, LLVMGetExecutionEngineTargetMachine(gallivm->engine), opts);
if (!(gallivm_perf & GALLIVM_PERF_NO_OPT))
+#if LLVM_VERSION_MAJOR >= 18
+ strcpy(passes, "sroa,early-cse,simplifycfg,reassociate,mem2reg,instsimplify,instcombine<no-verify-fixpoint>");
+#else
strcpy(passes, "sroa,early-cse,simplifycfg,reassociate,mem2reg,instsimplify,instcombine");
+#endif
else
strcpy(passes, "mem2reg");
--
GitLab
From a2ae6518c2d70dca9e3e9e93dc8e38a18f73c14e Mon Sep 17 00:00:00 2001
From: Konstantin Seurer <konstantin.seurer@gmail.com>
Date: Fri, 28 Apr 2023 23:15:48 +0200
Subject: [PATCH] gallivm: Fix gather/scatter types for newer llvm
The types changed with opaque pointer support.
Fixes a bunch of lavapipe regressions.
Cc: mesa-stable
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23293>
---
src/gallium/auxiliary/gallivm/lp_bld_gather.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_gather.c b/src/gallium/auxiliary/gallivm/lp_bld_gather.c
index b93251b444495..f55f2f3145e28 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_gather.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_gather.c
@@ -611,8 +611,14 @@ lp_build_masked_gather(struct gallivm_state *gallivm,
LLVMValueRef args[4];
char intrin_name[64];
+#if LLVM_VERSION_MAJOR >= 16
+ snprintf(intrin_name, 64, "llvm.masked.gather.v%ui%u.v%up0",
+ length, bit_size, length);
+#else
snprintf(intrin_name, 64, "llvm.masked.gather.v%ui%u.v%up0i%u",
length, bit_size, length, bit_size);
+#endif
+
args[0] = offset_ptr;
args[1] = lp_build_const_int32(gallivm, bit_size / 8);
args[2] = LLVMBuildICmp(builder, LLVMIntNE, exec_mask,
@@ -635,8 +641,14 @@ lp_build_masked_scatter(struct gallivm_state *gallivm,
LLVMValueRef args[4];
char intrin_name[64];
+#if LLVM_VERSION_MAJOR >= 16
+ snprintf(intrin_name, 64, "llvm.masked.scatter.v%ui%u.v%up0",
+ length, bit_size, length);
+#else
snprintf(intrin_name, 64, "llvm.masked.scatter.v%ui%u.v%up0i%u",
length, bit_size, length, bit_size);
+#endif
+
args[0] = value_vec;
args[1] = offset_ptr;
args[2] = lp_build_const_int32(gallivm, bit_size / 8);
--
GitLab