Files
llvm-project/clang/test/CodeGenSPIRV/global-dtor.cpp
Nick Sarnie 50a5462b2c [CodeGen] Fix C++ global dtor for non-zero program AS targets (#186484)
In codegen for C++ global destructors, we pass a pointer to the
destructor to be called at program exit as the first arg to the
`__cxa_atexit` function.

If the target's default program AS and default AS are not equal, we need
to emit an addrspacecast from the program AS to the generic AS (which is
used as the argument type for the first arg of `__cxa_atexit`) in the
function call.

---------

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-03-16 14:09:38 +00:00

8 lines
239 B
C++

// 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;