summaryrefslogtreecommitdiff
path: root/user/mesa/llvm18.patch
blob: 660bacb91a13546be3b545d7f5e82c55e7a952f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
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="{&quot;project_files_url&quot;:&quot;/mesa/mesa/-/files/b3cfec2fd824a52023c92fd5928f4f5c1cb449a0?format=json&quot;,&quot;project_blob_url&quot;:&quot;/mesa/mesa/-/blob/b3cfec2fd824a52023c92fd5928f4f5c1cb449a0&quot;}" data-force-desktop-expanded-sidebar="" data-root-path="/" data-sidebar="{&quot;is_logged_in&quot;:false,&quot;context_switcher_links&quot;:[{&quot;title&quot;:&quot;Explore&quot;,&quot;link&quot;:&quot;/explore&quot;,&quot;icon&quot;:&quot;compass&quot;}],&quot;current_menu_items&quot;:[{&quot;id&quot;:&quot;project_overview&quot;,&quot;title&quot;:&quot;mesa&quot;,&quot;icon&quot;:null,&quot;avatar&quot;:&quot;/uploads/-/system/project/avatar/176/gears.png&quot;,&quot;entity_id&quot;:176,&quot;link&quot;:&quot;/mesa/mesa&quot;,&quot;pill_count&quot;:null,&quot;link_classes&quot;:&quot;shortcuts-project&quot;,&quot;is_active&quot;:false},{&quot;id&quot;:&quot;manage_menu&quot;,&quot;title&quot;:&quot;Manage&quot;,&quot;icon&quot;:&quot;users&quot;,&quot;avatar&quot;:null,&quot;avatar_shape&quot;:&quot;rect&quot;,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/activity&quot;,&quot;is_active&quot;:false,&quot;pill_count&quot;:null,&quot;items&quot;:[{&quot;id&quot;:&quot;activity&quot;,&quot;title&quot;:&quot;Activity&quot;,&quot;icon&quot;:null,&quot;avatar&quot;:null,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/activity&quot;,&quot;pill_count&quot;:null,&quot;link_classes&quot;:&quot;shortcuts-project-activity&quot;,&quot;is_active&quot;:false},{&quot;id&quot;:&quot;members&quot;,&quot;title&quot;:&quot;Members&quot;,&quot;icon&quot;:null,&quot;avatar&quot;:null,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/-/project_members&quot;,&quot;pill_count&quot;:null,&quot;link_classes&quot;:null,&quot;is_active&quot;:false},{&quot;id&quot;:&quot;labels&quot;,&quot;title&quot;:&quot;Labels&quot;,&quot;icon&quot;:null,&quot;avatar&quot;:null,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/-/labels&quot;,&quot;pill_count&quot;:null,&quot;link_classes&quot;:null,&quot;is_active&quot;:false}],&quot;separated&quot;:false},{&quot;id&quot;:&quot;plan_menu&quot;,&quot;title&quot;:&quot;Plan&quot;,&quot;icon&quot;:&quot;planning&quot;,&quot;avatar&quot;:null,&quot;avatar_shape&quot;:&quot;rect&quot;,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/-/issues&quot;,&quot;is_active&quot;:false,&quot;pill_count&quot;:null,&quot;items&quot;:[{&quot;id&quot;:&quot;project_issue_list&quot;,&quot;title&quot;:&quot;Issues&quot;,&quot;icon&quot;:null,&quot;avatar&quot;:null,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/-/issues&quot;,&quot;pill_count&quot;:&quot;3.7k&quot;,&quot;link_classes&quot;:&quot;shortcuts-issues has-sub-items&quot;,&quot;is_active&quot;:false},{&quot;id&quot;:&quot;boards&quot;,&quot;title&quot;:&quot;Issue boards&quot;,&quot;icon&quot;:null,&quot;avatar&quot;:null,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/-/boards&quot;,&quot;pill_count&quot;:null,&quot;link_classes&quot;:&quot;shortcuts-issue-boards&quot;,&quot;is_active&quot;:false},{&quot;id&quot;:&quot;milestones&quot;,&quot;title&quot;:&quot;Milestones&quot;,&quot;icon&quot;:null,&quot;avatar&quot;:null,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/-/milestones&quot;,&quot;pill_count&quot;:null,&quot;link_classes&quot;:null,&quot;is_active&quot;:false}],&quot;separated&quot;:false},{&quot;id&quot;:&quot;code_menu&quot;,&quot;title&quot;:&quot;Code&quot;,&quot;icon&quot;:&quot;code&quot;,&quot;avatar&quot;:null,&quot;avatar_shape&quot;:&quot;rect&quot;,&quot;entity_id&quot;:null,&quot;link&quot;:&quot;/mesa/mesa/-/merge_requests&quot;,&quot;is_active&quot;:true,&quot;pill_count&quot;:null,&quot;items&quot;:[{&quot;id&quot;:&quot;project_merge_request_list&quot;,&quot;title&quot;:&quot;Merge requests&quot;,&quot;icon&quot;: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