https://github.com/sarnex updated 
https://github.com/llvm/llvm-project/pull/186484

>From f0a023a7936aea6c874e0dd9afc95587e3cba869 Mon Sep 17 00:00:00 2001
From: Nick Sarnie <[email protected]>
Date: Fri, 13 Mar 2026 11:30:57 -0700
Subject: [PATCH 1/2] [CodeGen] Fix C++ global dtor for non-zero program AS
 targets

Signed-off-by: Nick Sarnie <[email protected]>
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp     | 8 ++++++--
 clang/test/CodeGenSPIRV/global-dtor.cpp | 7 +++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGenSPIRV/global-dtor.cpp

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 8a06051a1c730..6d21db0e26f5e 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2979,8 +2979,12 @@ static void emitGlobalDtorWithCXAAtExit(CodeGenFunction 
&CGF,
       /*IsVariadic=*/false, /*IsCXXMethod=*/false));
   QualType fnType =
       Context.getFunctionType(Context.VoidTy, {Context.VoidPtrTy}, EPI);
-  llvm::Constant *dtorCallee = cast<llvm::Constant>(dtor.getCallee());
-  dtorCallee = CGF.CGM.getFunctionPointer(dtorCallee, fnType);
+  llvm::Value *dtorCallee = dtor.getCallee();
+  dtorCallee =
+      CGF.CGM.getFunctionPointer(cast<llvm::Constant>(dtorCallee), fnType);
+
+  if (dtorCallee->getType()->getPointerAddressSpace() != AddrAS)
+    dtorCallee = CGF.performAddrSpaceCast(dtorCallee, AddrPtrTy);
 
   if (!addr)
     // addr is null when we are trying to register a dtor annotated with
diff --git a/clang/test/CodeGenSPIRV/global-dtor.cpp 
b/clang/test/CodeGenSPIRV/global-dtor.cpp
new file mode 100644
index 0000000000000..da3b1e333a80e
--- /dev/null
+++ b/clang/test/CodeGenSPIRV/global-dtor.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple spirv64-intel %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: all spir_func addrspace(9) i32 @__cxa_atexit(ptr addrspace(4) 
addrspacecast (ptr addrspace(9) @{{.*}} to ptr addrspace(4)),
+struct S {
+  ~S() {}
+};
+S s;

>From ae7141e0b9fa7a8bdc18612cac2c24a986721070 Mon Sep 17 00:00:00 2001
From: Nick Sarnie <[email protected]>
Date: Fri, 13 Mar 2026 12:46:49 -0700
Subject: [PATCH 2/2] add release notes

Signed-off-by: Nick Sarnie <[email protected]>
---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 031d7405e7f58..534ea9d91c786 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -352,6 +352,7 @@ Bug Fixes to C++ Support
 - Fixed a crash when `explicit(bool)` is used with an incomplete enumeration. 
(#GH183887)
 - Fixed a crash on ``typeid`` of incomplete local types during template 
instantiation. (#GH63242), (#GH176397)
 - Fixed a crash when an immediate-invoked ``consteval`` lambda is used as an 
invalid initializer. (#GH185270)
+- Fixed an assertion failure when using a global destructor with a target with 
a non-default program address space. (#GH186484)
 
 - Inherited constructors in ``dllexport`` classes are now exported for 
ABI-compatible cases, matching 
   MSVC behavior. Constructors with variadic arguments or callee-cleanup 
parameters are not yet supported 
@@ -384,6 +385,7 @@ Miscellaneous Clang Crashes Fixed
 - Fixed an assertion failure in ObjC++ ARC when binding a rvalue reference to 
reference with different lifetimes (#GH178524)
 - Fixed a crash when subscripting a vector type with large unsigned integer 
values. (#GH180563)
 - Fixed a crash when evaluating ``__is_bitwise_cloneable`` on invalid record 
types. (#GH183707)
+- Fixed an assertion failure when casting a function pointer with a target 
with a non-default program address space. (#GH186210)
 
 OpenACC Specific Changes
 ------------------------

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to