You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The usual way to set up a destructor call for a local static is to use atexit, but HLSL doesn't have one of those. Instead, we currently add the destructor to the global destructor vector and generate it at the bottom of the entry function:
The flaw in this is that it will be called regardless of whether the construtor was encountered at all. This is inconsistent with how C++ operates and potentially damaging. Instead, we need to reuse the guard variable and bit offset that is used to ensure the constructor only gets called once:
To do this, we'll have to keep some map of the variable and offset to the associated destructor call. That could either be added to the CXXGLobalDtorsOrStermFinalizers vector or stored in a map within CGHLSLRuntime for use when generating the global destructor calls.
This is specific to the version of HLSL that adds destructors, which looks to be 202x.
The text was updated successfully, but these errors were encountered:
The usual way to set up a destructor call for a local static is to use atexit, but HLSL doesn't have one of those. Instead, we currently add the destructor to the global destructor vector and generate it at the bottom of the entry function: https://github.com/llvm/llvm-project/blob/f05145cd31e92c73301e308a6e13c581af3076ce/clang/lib/CodeGen/MicrosoftCXXABI.cpp#L2385-L2387
The flaw in this is that it will be called regardless of whether the construtor was encountered at all. This is inconsistent with how C++ operates and potentially damaging. Instead, we need to reuse the guard variable and bit offset that is used to ensure the constructor only gets called once:
To do this, we'll have to keep some map of the variable and offset to the associated destructor call. That could either be added to the CXXGLobalDtorsOrStermFinalizers vector or stored in a map within CGHLSLRuntime for use when generating the global destructor calls.
This is specific to the version of HLSL that adds destructors, which looks to be 202x.
The usual way to set up a destructor call for a local static is to use atexit, but HLSL doesn't have one of those. Instead, we currently add the destructor to the global destructor vector and generate it at the bottom of the entry function:
llvm-project/clang/lib/CodeGen/MicrosoftCXXABI.cpp
Lines 2385 to 2387 in f05145c
The flaw in this is that it will be called regardless of whether the construtor was encountered at all. This is inconsistent with how C++ operates and potentially damaging. Instead, we need to reuse the guard variable and bit offset that is used to ensure the constructor only gets called once:
llvm-project/clang/lib/CodeGen/MicrosoftCXXABI.cpp
Lines 2704 to 2708 in f05145c
To do this, we'll have to keep some map of the variable and offset to the associated destructor call. That could either be added to the CXXGLobalDtorsOrStermFinalizers vector or stored in a map within CGHLSLRuntime for use when generating the global destructor calls.
This is specific to the version of HLSL that adds destructors, which looks to be 202x.
The text was updated successfully, but these errors were encountered: