Skip to content

Commit b1a80a6

Browse files
committed
Update LLVM
1 parent 06288cd commit b1a80a6

22 files changed

Lines changed: 118 additions & 43 deletions

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ else()
139139
endif()
140140
use_component(${CLSPV_LIBCLC_SOURCE_DIR})
141141

142-
set(RUNTIMES_clspv--_LLVM_ENABLE_RUNTIMES "libclc" CACHE STRING "")
143-
set(RUNTIMES_clspv64--_LLVM_ENABLE_RUNTIMES "libclc" CACHE STRING "")
144-
set(LLVM_RUNTIME_TARGETS clspv--;clspv64-- CACHE STRING "")
142+
set(RUNTIMES_spirv32-unknown-vulkan_LLVM_ENABLE_RUNTIMES "libclc" CACHE STRING "")
143+
set(RUNTIMES_spirv64-unknown-vulkan_LLVM_ENABLE_RUNTIMES "libclc" CACHE STRING "")
144+
set(LLVM_RUNTIME_TARGETS spirv32-unknown-vulkan;spirv64-unknown-vulkan CACHE STRING "")
145145

146146
# Tell LLVM to build the native target (needed to build libclc).
147147
set(CLSPV_LLVM_TARGETS_TO_BUILD "Native")

cmake/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ add_custom_target(clspv64_builtin_library
116116
DEPENDS ${CLSPV64_LIBRARY_OUTPUT_FILE})
117117

118118
if (NOT DEFINED CLSPV_EXTERNAL_LIBCLC_DIR)
119-
set(CLSPV_LIBRARY_INPUT_FILE ${CLSPV_LLVM_BINARY_DIR}/lib/clang/${CLANG_EXECUTABLE_VERSION}/lib/spir--/libclc.bc)
120-
set(CLSPV64_LIBRARY_INPUT_FILE ${CLSPV_LLVM_BINARY_DIR}/lib/clang/${CLANG_EXECUTABLE_VERSION}/lib/spir64--/libclc.bc)
119+
set(CLSPV_LIBRARY_INPUT_FILE ${CLSPV_LLVM_BINARY_DIR}/lib/clang/${CLANG_EXECUTABLE_VERSION}/lib/spirv32-unknown-vulkan/libclc.bc)
120+
set(CLSPV64_LIBRARY_INPUT_FILE ${CLSPV_LLVM_BINARY_DIR}/lib/clang/${CLANG_EXECUTABLE_VERSION}/lib/spirv64-unknown-vulkan/libclc.bc)
121121
set(CLSPV_LIBRARY_DEP libclc)
122122
set(CLSPV64_LIBRARY_DEP libclc)
123123
else()
124-
set(CLSPV_LIBRARY_INPUT_FILE ${CLSPV_EXTERNAL_LIBCLC_DIR}/spir--/libclc.bc)
125-
set(CLSPV64_LIBRARY_INPUT_FILE ${CLSPV_EXTERNAL_LIBCLC_DIR}/spir64--/libclc.bc)
124+
set(CLSPV_LIBRARY_INPUT_FILE ${CLSPV_EXTERNAL_LIBCLC_DIR}/spirv32-unknown-vulkan/libclc.bc)
125+
set(CLSPV64_LIBRARY_INPUT_FILE ${CLSPV_EXTERNAL_LIBCLC_DIR}/spirv64-unknown-vulkan/libclc.bc)
126126
set(CLSPV_LIBRARY_DEP ${CLSPV_LIBRARY_INPUT_FILE})
127127
set(CLSPV64_LIBRARY_DEP ${CLSPV64_LIBRARY_INPUT_FILE})
128128
endif()

deps.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"subrepo" : "llvm/llvm-project",
77
"branch" : "main",
88
"subdir" : "third_party/llvm",
9-
"commit" : "6a9dac29a1aa4f3702c93a2a6d7172219438c59f"
9+
"commit" : "944cc03a4d68fe0f0002040b5e85400a068a0e74",
10+
"patches" : [
11+
{"patch": "patches/0001-SSAF-Fix-MSVC-template-parsing-error-in-Serializatio.patch"},
12+
]
1013
},
1114
{
1215
"name" : "SPIRV-Headers",
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
From 7e40076d7cff79d8412d5b1f40c36b9f4aaa1f76 Mon Sep 17 00:00:00 2001
2+
From: Romaric Jodin <rjodin@google.com>
3+
Date: Fri, 8 May 2026 16:14:06 +0200
4+
Subject: [PATCH] [SSAF] Fix MSVC template parsing error in SerializationFormat
5+
6+
This commit fixes a hard compilation error on Windows when building
7+
translation units that instantiate the `Add` registry template
8+
(such as `PointerFlowAnalysis.cpp`).
9+
10+
**Root Cause:**
11+
When compiling on Windows, Clang defaults to MSVC compatibility mode
12+
(`-fms-compatibility`). Under this mode, Clang's two-phase template
13+
lookup struggles to resolve function-local static variables
14+
(`SavedSerialize` and `SavedDeserialize`) captured by a local class
15+
(`ConcreteCodec`) inside an uninstantiated template. During Phase 1
16+
parsing, Clang incorrectly falls back to assuming these variables must
17+
be members of a dependent base class, rewriting them to
18+
`this->SavedSerialize`. During Phase 2 instantiation, compilation
19+
fails because the base class (`Codec`) has no such members.
20+
21+
**The Fix:**
22+
Hoisted `SavedSerialize` and `SavedDeserialize` out of the constructor
23+
scope, making them `static inline` members of the `Add` class template.
24+
This allows Clang's Phase 1 parser to perfectly resolve the symbols
25+
without relying on broken MSVC fallbacks.
26+
27+
**Why this is safe (Addressing the `dlopen` comment):**
28+
The original author explicitly commented that they avoided `static inline`
29+
class members to prevent Linux symbol visibility issues across shared
30+
library boundaries (`dlopen` with `RTLD_LOCAL`).
31+
32+
That concern is still honored by this fix. The visibility risk only applies
33+
if the `ConcreteCodec`'s *own* execution state relied directly on static
34+
members. By moving the static variables to the `Add` factory class,
35+
`ConcreteCodec` continues to store `SerFn` and `DesFn` as strictly
36+
**instance members**. The `ConcreteCodec` constructor safely snapshots
37+
the plugin's local copy of `Add::SavedSerialize` at the moment of
38+
instantiation. Since the virtual methods executed by the host still
39+
read exclusively from the isolated instance state, the runtime behavior
40+
remains completely identical and safe.
41+
---
42+
.../Core/Serialization/SerializationFormat.h | 7 +++++--
43+
1 file changed, 5 insertions(+), 2 deletions(-)
44+
45+
diff --git a/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormat.h b/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormat.h
46+
index fd261c6d9a72..9ab79dda3fc1 100644
47+
--- a/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormat.h
48+
+++ b/clang/include/clang/ScalableStaticAnalysisFramework/Core/Serialization/SerializationFormat.h
49+
@@ -133,6 +133,9 @@ protected:
50+
using TypedSerializerFn =
51+
llvm::function_ref<SerRet(const AnalysisResultT &, SerArgs...)>;
52+
53+
+ static inline TypedSerializerFn SavedSerialize;
54+
+ static inline DeserializerFn SavedDeserialize;
55+
+
56+
/// Takes the plugin's typed serializer and the deserializer, and
57+
/// inserts them into \c llvm::Registry<Codec>.
58+
Add(TypedSerializerFn TypedSerialize, DeserializerFn Deserialize) {
59+
@@ -154,8 +157,8 @@ protected:
60+
/// visibility issues across shared library boundaries on Linux
61+
/// (where \c dlopen with \c RTLD_LOCAL can give the host and
62+
/// plugin separate copies of \c static \c inline members).
63+
- static TypedSerializerFn SavedSerialize = TypedSerialize;
64+
- static DeserializerFn SavedDeserialize = Deserialize;
65+
+ SavedSerialize = TypedSerialize;
66+
+ SavedDeserialize = Deserialize;
67+
68+
/// Concrete subclass of \c Codec for \c AnalysisResultT.
69+
/// The \c serialize() override performs the downcast from
70+
--
71+
2.54.0.563.g4f69b47b94-goog
72+

test/MathBuiltins/cospi/cospi_double2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ entry:
1212

1313
declare spir_func <2 x double> @_Z5cospiDv2_d(<2 x double>)
1414

15-
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul <2 x double> %x, splat (double 0x400921FB54442D18)
15+
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul <2 x double> %x, splat (double f0x400921FB54442D18)
1616
; CHECK: [[cos:%[a-zA-Z0-9_.]+]] = call <2 x double> @llvm.cos.v2f64(<2 x double> [[mul]])
1717

test/MathBuiltins/cospi/cospi_float.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ entry:
1212

1313
declare spir_func float @_Z5cospif(float)
1414

15-
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul float %x, 0x400921FB60000000
15+
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul float %x, f0x40490FDB
1616
; CHECK: [[cos:%[a-zA-Z0-9_.]+]] = call float @llvm.cos.f32(float [[mul]])

test/MathBuiltins/cospi/cospi_float2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ entry:
1212

1313
declare spir_func <2 x float> @_Z5cospiDv2_f(<2 x float>)
1414

15-
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul <2 x float> %x, splat (float 0x400921FB60000000)
15+
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul <2 x float> %x, splat (float f0x40490FDB)
1616
; CHECK: [[cos:%[a-zA-Z0-9_.]+]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[mul]])

test/MathBuiltins/cospi/cospi_half.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ entry:
1212

1313
declare spir_func half @_Z5cospiDh(half)
1414

15-
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul half %x, 0xH4248
15+
; CHECK: [[mul:%[a-zA-Z0-9_.]+]] = fmul half %x, 3.140630e+00
1616
; CHECK: [[cos:%[a-zA-Z0-9_.]+]] = call half @llvm.cos.f16(half [[mul]])
1717

test/MathBuiltins/expm1/expm1_half.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ entry:
1313
declare spir_func half @_Z5expm1Dh(half %x)
1414

1515
; CHECK: [[exp:%[a-zA-Z0-9_.]+]] = call half @llvm.exp.f16(half %x)
16-
; CHECK: [[sub:%[a-zA-Z0-9_.]+]] = fsub half [[exp]], 0xH3C00
16+
; CHECK: [[sub:%[a-zA-Z0-9_.]+]] = fsub half [[exp]], 1.000000e+00
1717
; CHECK: ret half [[sub]]
1818

test/MathBuiltins/fdim/fdim_half.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ declare spir_func half @_Z4fdimDhDh(half, half)
1414

1515
; CHECK: [[sub:%[a-zA-Z0-9_.]+]] = fsub half %x, %y
1616
; CHECK: [[gt:%[a-zA-Z0-9_.]+]] = fcmp ugt half %x, %y
17-
; CHECK: [[sel:%[a-zA-Z0-9_.]+]] = select i1 [[gt]], half [[sub]], half 0xH0000
17+
; CHECK: [[sel:%[a-zA-Z0-9_.]+]] = select i1 [[gt]], half [[sub]], half 0.000000e+00
1818
; CHECK: ret half [[sel]]
1919

0 commit comments

Comments
 (0)